PDA

View Full Version : [Resolved] Help setting command/scrip to change DNS servers




cdubb80
Jul 16, 2012, 11:56 AM
Hi, trying to setup an script/command to turn on and off a DNS server instead of manually entering it each time.

This page talks about it http://tunlr.net/forums/topic/mac-os-x-scripts-for-tunring-tunlr-onoff/#post-1210

NOTE: This works as-is if you use OS X 10.7.x Lion or 10.8.x Mountain Lion using Wi-Fi. If you use Ethernet, just change “Wi-Fi” to “Ethernet”. If you use Mac OS X 10.6 or previous versions, change “Wi-Fi” to “AirPort”.

for turning on:

sudo networksetup -setdnsservers Wi-Fi 149.154.158.186, 199.167.30.144

Then save this to a command of your preference (Suggested: tunlron.command)

for turning off:

sudo networksetup -setdnsservers Wi-Fi 4.2.2.2, 4.2.2.3

Then save this to a command of your preference (Suggested: tunlroff.command)


After I execute the file by using "chmod +x tunlron.commnad" when I click on it gives this

calvin-macbookpro:~ calvin$ /Volumes/MacBook\ Pro\ HD/Users/calvin/tunlron.command ; exit;
-bash: /Volumes/MacBook Pro HD/Users/calvin/tunlron.command: cannot execute binary file
logout

[Process completed]


Any suggestions?



chown33
Jul 16, 2012, 12:05 PM
1. Open a Terminal window.

2. Copy and paste these commands into the window:
ls -ld /Volumes/MacBook Pro HD/Users/calvin/tunlron.command
file /Volumes/MacBook Pro HD/Users/calvin/tunlron.command

3. Copy and paste the complete output into a reply post.

cdubb80
Jul 16, 2012, 12:21 PM
calvin-macbookpro:~ calvin$ ls -ld /Volumes/MacBook Pro HD/Users/calvin/tunlron.command
ls: /Volumes/MacBook: No such file or directory
ls: HD/Users/calvin/tunlron.command: No such file or directory
ls: Pro: No such file or directory
calvin-macbookpro:~ calvin$ file /Volumes/MacBook Pro HD/Users/calvin/tunlron.command

cdubb80
Jul 16, 2012, 12:34 PM
Ok thinK i have resolved things.

For some reason textedit originally didn't let me save the command as .txt file (options were RTF, .doc, .odt)

Opened up some .txt file and edited it with the commands and now works.

thanks for help though

chown33
Jul 16, 2012, 02:57 PM
calvin-macbookpro:~ calvin$ ls -ld /Volumes/MacBook Pro HD/Users/calvin/tunlron.command
ls: /Volumes/MacBook: No such file or directory
ls: HD/Users/calvin/tunlron.command: No such file or directory
ls: Pro: No such file or directory
calvin-macbookpro:~ calvin$ file /Volumes/MacBook Pro HD/Users/calvin/tunlron.command

Gaack!! I forgot the quoting. Corrected:
ls -ld "/Volumes/MacBook Pro HD/Users/calvin/tunlron.command"
file "/Volumes/MacBook Pro HD/Users/calvin/tunlron.command"



TextEdit will only let you save as .txt if you're editing the file as plain text. Under the Format menu, look for a menu item "Make Plain Text".

There's also a TextEdit preference for New Document, a Format choice between Rich text and Plain text.