How to make Apple Script do a terminal command

Hey,
I am wondering how can I make an AppleScript do the following command :
"networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
Please mention step by step since I'm new to AppleScript
Best Regards,
Nadav.

To run a terminal command it is usually sufficient to use do shell script. So for your command it would be
do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
note if the command requires administrator privileges you would need to do
do shell script "command"  with administrator privileges
will prompt for the password when the script is run.
do shell script "command" user name "me" password "mypassword" with administrator privileges
will store the password and username in the script. More convenient but much less secure.
See do shell script in AppleScript

Similar Messages

  • How to make a script for a terminal command

    I need to find instructions on how to create a script to automatically run the following Terminal command;
    Sudo chmod 755 /private/var/spool/cups. It will also need to include the admin password as you will be prompted to enter it after the command line is entered. Apparently the only way to get Quark 7 to print adobe pdf's is to open a terminal window and type the command every time the machine is rebooted. This is a temporary fix and I do not want the MAC users to have to type the command.
    Thanks
    Sal

    This Script works here. Get you the error, when you save or checks the syntax?
    When you use in AppleScript the entry with administrator privileges, is sudo optional. This says only, if everyone can use the sudo command inside of the 5 minutes limit without to write the password again or not.
    The Syntax do shell script "sudo chmod 755 "private/var/spool/cups" password "***" doesn´t work, because you need the entry with administrator privileges for the execution as privileged user.

  • HT1420 How to make Apple ID and iCloud the same Id?

    How to make Apple ID and iCloud ID the same after they have been created?
    iTunes keeps asking for ID and passwords that were created differently.

    You can't im afraid. I wanted to do the same and got the following from Apple:
    I am sorry, you cannot update your email address to MobileMe address as each Apple ID is unique.
    Ross, I would like to let you know that, you cannot change your Apple ID if it was at any time a .Mac or MobileMe email address, even if your subscription has ended or been canceled.
    The email address that ends in .me is already an Apple ID as well, as when you set up a MobileMe email its automatically set up as an Apple ID. So you cannot use this email address on another account. It is permanently associated with your MobileMe Apple ID.
    This article provides helpful information when choosing which Apple ID to use with iCloud:
    Apple IDs and iCloud
    http://support.apple.com/kb/HT4895
    This page also covers topics such as moving MobileMe accounts to iCloud, managing your Apple ID, and how to get content purchased with multiple Apple IDs onto your iOS device.
    I hope this information was helpful. If you require further assistance, please do not hesitate to reply to this email and I will be more than happy to assist you further.
    Sincerely,
    Thenmozhi
    iTunes Store Customer Support
    http://www.apple.com/support/itunes/ww/
    I wrote back and tried to escialte the issue but got no where. The whole thing is very disappointing and I hope Apple sort it out eventually.

  • HT5625 how to make apple id?

    how to make apple id?

    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/wa/createAppleId?loca lang=en_US

  • How to make apple tv view external hard drive

    i want to know how I can make apple tv recognize an external hard drive

    You can't.  It can only see content in iTunes or iCloud.  What ever you have on the hard drive you need to add to iTunes.

  • How to make apple maps default on my mac?

    I want apple maps to default on my map, e.g.., when I need to send meeting location address in calendar.

    Hi ajjacoby14,
    To make iTunes the default application to use for playing music, use the steps found in this article -
    iTunes for Windows: How to make iTunes the default application for music and audio files
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • How to make powershell script.

    How to make script that copy content from notepad to other notepad and reverse the text?

    If you mean a .txt file then there's three aspects to your question.
    Open a file and read the text
    Reverse the text
    Save the text into a new file
    For point one, this technet article is good:
    http://technet.microsoft.com/en-us/library/ee692806.aspx
    For point two you could turn the text into one or more strings, then convert those into arrays, loop through them and then re-assemble them. This article shows you most of that:
    http://technet.microsoft.com/en-us/library/ee692804.aspx
    And finally you need to save that text as a file, there's lots of ways but the Out-File cmdlet is the simplest.
    This might also be of use:
    http://www.ehow.com/how_7174023_write-basic-powershell-script.html

  • How to make AE script folder?

    Hi, i want to ask something about script in after effect CS6. I have many script in my AE and I think its quite difficult to find the script i want. So, how to make script folder in AE or maybe group of script? So if I want to use the script i can find it easier....
    Thank you and sorry for my bad english...

    // create a new FolderItem in project, with name “comps”
    var compFolder = app.project. items.addFolder(“comps”);
    AE CS3 Scripting guide, page 78

  • How to make apple id without credit

    Can you help me , i have not credit card and want to make apple ID to download some apps.  how can i make apple id without any credit card

    See this... http://support.apple.com/kb/ht2534

  • How to make a script to convert RGB to CMYK as black 100%?

    Hi guy
    my customer sent me a book (144 pages) for print but all of them are RGB and Tiff, she scan them. there are on the page some texts and pictures. The text are R=30 G=30 B=30.I think if I can make a script I will do it very soon to black 100%, but unfortunately I dont know anything to make script 
    anybody can help me ?anybody can make it for me ?

    We need to know some more information.
    1. The book consists of 144 pages, and each page is in fact an RGB image in TIFF format.
        Correct?
        That means, the text is already rasterized, but with low resolution (no more than 300ppi).
        A very bad starting point, in my humble opinion. For offset printing this is not acceptable.
    2. Is the printing process offset printing or by digital printing?
    Nevertheless we may think about a conversion of these images into CMYK K-only (one plate
    per page) . 
    a) Increase contrast until R=G=B=0 for text.
    b) Convert each image into Grayscale, using a so-called Black-Ink-Profile, for instance
        Black-Ink-ISOCoated-v2-eci (can be explained later)
    c) Make empty CMYK image, here for  ISOCoated-v2-eci, and paste the Grayscale into the
        K-channel. All further handling happens as CMYK file for the process ISOCoated-v2-eci.
        Void plates CMY don't matter.
        Post #12 here:
        Re: Colour shift (from CMYK = 0 0 0 20 to Grayscale K = 22 !)
    All this can be done by an action (I hope so...).
    Much better would be a new start by InDesign with typographical text (K-only vector instead of raster)
    with images in RGB or CMYK, taking into account the intended process.
    Note: Photoshop can deliver vector text, if exported as PDF.
    Best regards --Gernot Hoffmann

  • Launchd: how to make a script run every weekday?

    I'm trying to make a script run every weekday as a LaunchAgent. Is there a way to do this like you could in cron?
    Here is the relevant portion of my LaunchAgent plist:
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>9</integer>
    <key>Minute</key>
    <integer>0</integer>
    <key>Weekday</key>
    <integer>3</integer>
    </dict>
    I have tried changing the Weekday integer to 1-5 or 1,2,3,4,5 but neither worked. It only works with a single integer. Do I have to create 5 separate plists for each weekday?
    Any ideas?

    Thanks VK, for others who are looking to do something similar, here is the relevant part of the code to make the command run every day (since that field is missing) at 7:00pm and 7:01pm:
    <key>StartCalendarInterval</key>
    <array>
    <dict>
    <key>Hour</key>
    <integer>19</integer>
    <key>Minute</key>
    <integer>00</integer>
    </dict>
    <dict>
    <key>Hour</key>
    <integer>19</integer>
    <key>Minute</key>
    <integer>01</integer>
    </dict>
    </array>

  • How to make a script for find text object?

    Hi everyone
    I want to make a script for find and select text object and then find next, find next, and so on, but without any open dialog
    Is that possible make a script for this?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "(\[\x{2022}\])|(\x{25CF})";
    app.findGrep();
    thanks
    Regard

    You already have that. A script does not 'find, select, find next' - it finds all texts as soon as you execute the 'app.findGrep' command.

  • How to make a script for expand column width

    Hi experts,
    Is that possible to make a script for expand the column width aim to let the columns show up all the overset text?
    Regard
    John

    Hi John,
    As Uwe advised it would be wise to put a stop on any while loop in case the condition is never fulfilled which would mean the script will break.
    Without knowing what specifically you are working on you could make the below amendments to do this.
    myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();
    for (var t = 0; t < myTables.length; t++) {
        BE_resizeColumnsToFitContents(myTables[t], 200);
    function BE_resizeColumnsToFitContents(tableToEdit, tableMaxWidth) {
        for (var i = 0; i < tableToEdit.columns.length; i++) {
            while (tableToEdit.columns[i].overflows === true) {
                if (tableToEdit.width < tableMaxWidth) {
                    tableToEdit.columns[i].width += 1;
                    tableToEdit.columns[i].recompose();
                else {
                    alert("Column " + i + " contents too large for column.");
                    break;
    I won't put any extra functions in this because it might not be what you're after. To use this you just define the table width as a second argument to the function (but you could change this parameter to something else, like page, column or cell width). And, if you want to have a fail action you just put it in the 'else' part.
    Brett

  • How to make this script work

    Help me to make this script work, please!
    function(){
    app.findGrepPreferences.firstLineIndent  = "8 mm";
    app.findGrepPreferences.leftIndent  = "8 mm";
    app.changeGrepPreferences.firstLineIndent  = "8 mm";
    app.changeGrepPreferences.leftIndent  = "16 mm";
    app.selection[0].changeGrep();
    app.findGrepPreferences.leftIndent  = "16 mm";
    app.changeGrepPreferences.leftIndent  = "24 mm";
    app.selection[0].changeGrep();

    Hi,
    Its already replied, see below code:
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.firstLineIndent  = "8 mm";
    app.findGrepPreferences.leftIndent  = "8 mm";
    app.changeGrepPreferences.firstLineIndent  = "8 mm";
    app.changeGrepPreferences.leftIndent  = "16 mm";
    app.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    First run the above code, again you want to change leftIndent from '16 mm' to '24 mm' run below code:
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.leftIndent  = "16 mm";
    app.changeGrepPreferences.leftIndent  = "24 mm";
    app.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    by
    hasvi

  • HT5577 How to make Apple ID?

    I want to make Apple ID please help me

    See >  Create an Apple ID
    From >  http://www.apple.com/support/appleid/basics/

Maybe you are looking for

  • Macbook pro will not reinstall yosemite

    I have had major problem with my Macbook Pro since downloading Yosemite from the beta version.  it has been randomly shutting down then not turning on.  When it had managed to work it is showing error on Hdd.  Tried to fix it but because of the shutt

  • HT5887 can i transfer files between iphone 5 and my macpro

    Hi guys,               I just want to know  weather the files between macbook and i phone 5 cane trensefered, because i dont know thmethod using airdrop and i have tried using the airdrop on both device but still i cant do it. so please i need ur hel

  • Controling an XML based scrolling thumbnails

    hi! this is my code so far: import caurina.transitions.*; var xmlRequest:URLRequest = new URLRequest("scrolling.xml"); var xmlLoader:URLLoader = new URLLoader(xmlRequest); var imgData:XML; var imageLoader:Loader; var rawImage:String; var rawH:String;

  • "Save for Web" feature suddenly grayed out

    I have a Mac Notebook. I have Adobe Photoshop Elements 4.0 installed (I know it's outdated but it meets my simple needs). I use Photoshop Elements mostly to save photos for my blog. I use the "save for web" feature everytime. However, when I tried us

  • HT4859 How do I retrieve my pictures from iCloud?

    I've recently lost my iTouch, and I want to retrieve all of my pictures. All of my pictures had been updated onto iCloud regularly. How do I download them back?