Scripting with 'networksetup' command utility [noob question]

I’m trying to write a simple script so that I can connect to the network of my choice without having to open Terminal. I’m a complete novice when it comes to writing scripts so forgive me for asking for help for such an issue.

The command line that I would write in terminal would be the following:

Now I just need to find out how to make a script so that I can link it to a key command and not have to open up Terminal. Thank you for the consideration!

-A

The absolutely easiest thing would be to create an Automator Service, with a shell script action in it where you’d paste your script. When you have saved your Service then you could assign a short cut key to in System Preferences^Keyboard^Services.

Right, but I’d like to have the shortcut key run the command line without having terminal open up. Is that possible through automator?

edit: what I’m basically asking is how I can run a shell script “behind the scenes.”

Hello.

I just told you how to run a shell script behind the scenes. With a shortcut key too.

Just have a little bit confidence, and try my suggestion. :slight_smile:

HI.

The English name of the Automator action for McUsrII’s suggestion is “Run Shell Script” and it’s in Automator’s “Utilities” library.

Or in AppleScript, you could try:

do shell script "networksetup -setairportnetwork en1 PacMan ***********" with administrator privileges

I haven’t tried it myself, but I assume the administrator privileges will be necessary.

Ok, sorry MacUsrII, I didn’t know Automator runs shell scripts. Now I do. Thank you. And thank you for pointing that out Nigel.

I am not sure, haven’t tried it either, but what I do have, is a series of preferred networks, that I have an account for, so I basically just turn on Airport via an applet, invoked by spotlight, that obviates the need for an administrator privileges, as all of that is taken care of up front.

do shell script "networksetup -setairportpower en1 on"

I just see when it is up by the color of the fan on the menubar, before I go any further, but I could have run a tight loop, and tested for it with ifconfig -status or something. Haven’t got that far yet. Deep into FileMaker Pro at the moment. :slight_smile: