Results 1 to 11 of 11
  1. #1


    Member Since
    Dec 08, 2010
    Posts
    8
    How Can I Make A Terminal Command Permanent?
    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

  2. #2

    louishen's Avatar
    Member Since
    Oct 22, 2007
    Location
    London
    Posts
    8,968
    Specs:
    Mac Mini Core i7 2012 | White 2009 MacBook 2 Ghz | 733 Mhz G4 Quicksilver
    Member of the Month September 2008 & August 2012 | Found advice useful? use the rep system

  3. #3


    Member Since
    Dec 08, 2010
    Posts
    8
    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

  4. #4

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  5. #5


    Member Since
    Dec 08, 2010
    Posts
    8
    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.

  6. #6


    Member Since
    Dec 08, 2010
    Posts
    8
    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.

  7. #7

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    One of the key sentences from that page which lacks explanation is the following:
    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

  8. #8


    Member Since
    Dec 08, 2010
    Posts
    8
    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.

  9. #9

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  10. #10


    Member Since
    Dec 08, 2010
    Posts
    8
    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.

  11. #11

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Terminal command to make aliases (shortcuts) of files/folders?
    By ericconn in forum OS X - Operating System
    Replies: 4
    Last Post: 05-24-2012, 02:16 PM
  2. How to make Terminal prompt change permanent?
    By jsherk in forum OS X - Operating System
    Replies: 1
    Last Post: 01-18-2012, 02:40 PM
  3. Make Terminal command
    By richbits in forum OS X - Development and Darwin
    Replies: 8
    Last Post: 01-12-2012, 03:35 AM
  4. iphoto. How to make changes permanent?
    By emperor_black in forum Images, Graphic Design, and Digital Photography
    Replies: 5
    Last Post: 01-15-2011, 06:54 PM
  5. Can I make this setting permanent?
    By Trolle in forum Music, Audio, and Podcasting
    Replies: 0
    Last Post: 09-15-2009, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •