New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

How Can I Make A Terminal Command Permanent?


Post Reply New Thread Subscribe

 
Thread Tools
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Hi All,

We posted this on the Apple Forum, but haven't had any responses yet, just wondering if anyone here can help us...

After months of frustration trying to get our old FSG 3 Freecom Nas to work in OSX Lion, we finally discovered something that is helping. We can now see our NAS drive under Lion, but the fix is only temporary and we're looking for a way to make it permanent using Terminal (or any other method).

I basically read this article:
Fixing SMB issues with OSX Lion | Software is too expensive to build cheaply….

and the terminal command:
sudo sysctl -w net.smb.fs.kern_deprecatePreXPServers=0

allows me to see and connect to my NAS, but after a reboot, connectivity disappears and I have to do it again. In order to make the fix permanent, the article suggests editing the file /etc/sysctl.conf

this file just doesn't exist on my machine under Lion...

Could someone help with instructions as to what I would need to do in Terminal (or any other way) to create and add this command into the file to make this a permanent fix????

Thank you so much

T
QUOTE Thanks
louishen

 
louishen's Avatar
 
Member Since: Oct 22, 2007
Location: London
Posts: 8,940
louishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant futurelouishen has a brilliant future
Mac Specs: Mac Mini Core i7 2012 | White 2009 MacBook 2 Ghz | 733 Mhz G4 Quicksilver

louishen is offline
You need to make the command into a shell script

Mac OS X Unleashed | Automating Tasks with Shell Scripts | InformIT

Then auto run it at login

Mac OS X Unleashed | Making Shell Scripts Start at Login or System Startup | InformIT

Member of the Month September 2008 & August 2012 | Found advice useful? use the rep system
QUOTE Thanks
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Thank you so much for your help Louishen, I'm a little bit lost by the use of shell scripts though... I'm pretty new to Macs, and this is a little bit beyond me. Are there any GUI programs that I could copy and paste the terminal command into perhaps?

Thank you again for all your help.

T

Quote:
Originally Posted by louishen View Post
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
You can simply paste the command into a plain text document and save it with the ".sh" extension. There's your shell script.

Note: If you're using TextEdit to create the script, you'll need to make sure it's in Plain Text mode (Format > Make Plain Text). If you don't, the file will be saved as rich text which won't be interpreted properly.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Hi vansmith, thanks for this - I'll give it a go!

Really appreciate all the help on this forum, I'm totally new to this (not so long ago switched from a PC) so this is a really big help.

All the best and thanks again

T

Quote:
Originally Posted by vansmith View Post
You can simply paste the command into a plain text document and save it with the ".sh" extension. There's your shell script.

Note: If you're using TextEdit to create the script, you'll need to make sure it's in Plain Text mode (Format > Make Plain Text). If you don't, the file will be saved as rich text which won't be interpreted properly.
QUOTE Thanks
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Hi vansmith,

I'm having a bit of trouble getting this to work. This is what I did:
1) I Copied the command:
sudo sysctl -w net.smb.fs.kern_deprecatePreXPServers=0
into Text Edit, Chose Format > Make Plain Text and saved it on my desktop as NAS.sh
2) I then went to the folder: System > Library > Startupitems and created a subfolder called NAS and moved the Nas.sh file into it.
3) I then restarted my MBP and tried to connect to my NAS drive, but it didn't work! I just got the usual cannot connect error.

Have I done something wrong in some part of these steps?

Thanks

T


Quote:
Originally Posted by vansmith View Post
You can simply paste the command into a plain text document and save it with the ".sh" extension. There's your shell script.

Note: If you're using TextEdit to create the script, you'll need to make sure it's in Plain Text mode (Format > Make Plain Text). If you don't, the file will be saved as rich text which won't be interpreted properly.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
One of the key sentences from that page which lacks explanation is the following:
Quote:
An executable shell script is just another program as far as Unix is concerned, so you can configure scripts to start on login from there
The key here is the "executable" part and unfortunately, the article doesn't explain how to do this.

Execute the following to make it excutable:
Code:
sudo chmod +x /System/Library/StartupItems/NAS/Nas.sh
If you don't make it executable, the script doesn't appear to be something that needs to be executed. By making it executable, you're essentially telling the OS that this script is meant to be executed.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Thanks again vansmith. I totally get the principle of what you're saying, but not sure I have executed it right... I now have one file (in the same location, still named NAS.sh, but I added the extra command in so it reads like this:

sudo chmod +x /System/Library/StartupItems/NAS/Nas.sh
sudo sysctl -w net.smb.fs.kern_deprecatePreXPServers=0

Is this right, or do I need a seperate file called something else inside the startup folder which Lion will read and from that it'll execute the NAS shell command script?

Apologies for all the questions

T

Quote:
Originally Posted by vansmith View Post
One of the key sentences from that page which lacks explanation is the following:The key here is the "executable" part and unfortunately, the article doesn't explain how to do this.

Execute the following to make it excutable:
Code:
sudo chmod +x /System/Library/StartupItems/NAS/Nas.sh
If you don't make it executable, the script doesn't appear to be something that needs to be executed. By making it executable, you're essentially telling the OS that this script is meant to be executed.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
You don't add the chmod line to your script - you execute it to make your one line script executable. So, remove it from your script (such that you only have the one relevant line), open up a Terminal window and execute the chmod command I provided.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Todd Smith 265

 
Member Since: Dec 08, 2010
Posts: 8
Todd Smith 265 is on a distinguished road

Todd Smith 265 is offline
Aarrggh. still can't get this to work. So, sorry for all the questions. One last thing: my MBP has a password on it, would this prevent the script from autorunning on startup?

It's the only thing I could think of as I've followed everything else to the letter.

Apologies again for bothering you so much with this....

Thanks

T


Quote:
Originally Posted by vansmith View Post
You don't add the chmod line to your script - you execute it to make your one line script executable. So, remove it from your script (such that you only have the one relevant line), open up a Terminal window and execute the chmod command I provided.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,757
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
I'm going to guess that the script is executing before sysctl is available or sysctl is erroring out. For instance, it might be trying to set a value that is overwritten during the boot process or is might not have access to resources that it needs when it executes (in other words, it executes too early in the boot process).

Instead of fighting with this, you might want to try the more flexible launchd. Take a look at this article.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks

Post Reply New Thread Subscribe


« my email is stuck in my outbox | Can't "save as" emails »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
SSH in Terminal to a Linux Station --- Want working directory in title jwillis0720 Running Windows (or anything else) on your Mac 0 03-08-2011 06:34 PM
help: lingon terminal command at startup python string lawlist OS X - Operating System 1 12-12-2010 09:01 PM
How do you change default port for Terminal Services Client for Mac? vpalhories Internet, Networking, and Wireless 1 09-01-2010 01:27 PM
Terminal Won't Open icefall5 OS X - Operating System 7 08-25-2010 08:26 AM
C++ in terminal frike OS X - Development and Darwin 2 04-04-2008 10:52 AM

All times are GMT -4. The time now is 12:08 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?