AppleScript Terminal Commands

Discussion in 'Mac Programming' started by michaelzz, Jul 4, 2008.

  1. michaelzz
    Expand Collapse
    macrumors newbie

    Joined:
    Apr 4, 2008
    #1
    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

    Code:
    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!
     
  2. HiRez
    Expand Collapse
    macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
  3. michaelzz
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 4, 2008
    #3
    i got an error after i did that
    Code:
    ipfw: socket: operation not permitted
     
  4. HiRez
    Expand Collapse
    macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #4
    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?
     
  5. HeyPretty
    Expand Collapse
    macrumors newbie

    Joined:
    Jun 27, 2011
    #5
    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'
     

Share This Page