PDA

View Full Version : AppleScript Terminal Commands




michaelzz
Jul 4, 2008, 11:48 PM
Hi,
I have 2 commands in terminal i use often and I would like to automate them with an applescript (or shell script, or a script of some sort). I tried apple script and put this in

do shell script "sudo ipfw pipe 1 config bw 50KByte/s"
do shell script "sudo ipfw add 1 pipe 1 src-port 80"
then i try to run it in the editor and it says "error: Password: ". so i was wondering if there was someway to add a password into the script (i don't care too much about security), or find a way around this. I would rather not type my password every time i try to run the script, but it would be fine if I had to.
Thanks in advance!



HiRez
Jul 5, 2008, 03:38 AM
Use the with administrator privileges, user name, and password keywords, and don't use sudo:

http://developer.apple.com/technotes/tn2002/tn2065.html

michaelzz
Jul 5, 2008, 11:57 PM
i got an error after i did that
ipfw: socket: operation not permitted

HiRez
Jul 6, 2008, 03:14 AM
Well I'm sorry, I don't know anything about that error, but using those keywords is the normal way to do such things from AppleScript. Maybe certain commands have issues with it. Can you try running the script from the root account and see if it still gives you the error?

HeyPretty
Jun 27, 2011, 08:18 PM
No need for an AppleScript here. Just add an alias in your .profile:

http://ss64.com/bash/alias.html

alias config='sudo ipfw pipe 1 config bw 50KByte/s'
alias add='sudo ipfw add 1 pipe 1 src-port 80'