Help with Scripting in Terminal


I am VERY new to this whole script thing and I don’t think I am starting out too basic, but heres what I want to do:

I want to have a script run at startup and tell terminal to do this:

sudo ifconfig en1 mtu 1454

I will then have to enter my password for it to go through, I think I have that down, it should look something like this:

do shell script “myscript” with administrator privileges password mypassword

Any help?

Thanks in advance,

Terminal and ‘do shell script’ have absolutely nothing to do with each other even though they both deal with shell commands. Do you actually want a Terminal window open or do you just need to run the script without further interaction?

Since you don’t need the terminal for this, you can:

do shell script “ifconfig en1 mtu 1454” with administrator privileges

By excluding the password parameter, the script will actually prompt you for your admin password before running the script. If you’re happy embedding your password in the script then feel free to add the password parameter.

The script works perfectly, thanks! what folder do I place it in to have it run on startup in OS X?

Thanks again!

You have a multitude of options here.

The easiest is to save the script as an application and add it to your Login Items. That way it’ll get run as soon as you log in.

Alternatively, adding it to /Library/StartupItems/ would execute the script at startup, although you’ll need a corresponding .plist file to tell the system how to load it.

That works great! Thanks for helping out a newbie! Hopefully I’ll be able to pick this stuff up pretty quick.

Thanks again!