Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Vegbrain

macrumors newbie
Original poster
Jun 17, 2012
7
0
I'm a complete newbee on terminal scripts, so "help", please:
PROBLEM - I have a Satellite HDR that is running an older W98 version of Samba, and my new Mac (OSX 10.7) can't connect as pre-XP versions of Samba are not recognized.
SOLUTION: from the Apple website, if I add:
"sudo sysctl -w net.smb.fs.kern_deprecatePreXPServers=0"
the problem is solved. But I have to execute this command in the terminal each time I start up the Mac.
QUESTION - how do I make this change permanent?
I bought a program called Lingon 3 which was supposed to make it easy, but it won't accept anything starting with "sudo" as it says this is not allowed in the "root"(??). I have no idea what this means.
Can anybody out there help me, please?
 
You can run that shell command in an Applescript as described here, and have it prompt you for your password.

Once you get the Applescript working properly you can save it as an app then run the app as a login item.
 
You can run that shell command in an Applescript as described here, and have it prompt you for your password.

Once you get the Applescript working properly you can save it as an app then run the app as a login item.
Thanks Weaselboy, but as I haven't a clue about any of this, I can't understand anything about the link you sent. Any chance of providing some really basic instructions, please?
Thanks in advance.
 
Thanks Weaselboy, but as I haven't a clue about any of this, I can't understand anything about the link you sent. Any chance of providing some really basic instructions, please?
Thanks in advance.

Sure thing. Open the Applescript editor app from the /Applications/Utilities folder. Then copy/paste in the below command.

Code:
do shell script "sysctl -w net.smb.fs.kern_deprecatePreXPServers=0" with administrator privileges

Then click the compile button in Applescript editor. Now click the run button to test your script. It should give you a popup window with your user name already filled in and the password window blank. Type in your password and hit return. That should execute the script.

If it worked okay, you now want to save the Applescript as an application. In Applescript editor click on the file menu then "save as" and name your new app. Toward the bottom of the save as window change the format from script to application. Pick where you want to save your app (I would put it in /Applications) then save it.

Quit the Applescript editor.

Now go to System Preferences / Users & Groups and click your user name then add your new app as a login item.

Logout then log back in. You should get the same password prompt you did earlier when testing. Type in the password and hit enter and your script should execute. You could embed the password in the script, but this is not very safe and exposes your password in a plain text file. The better and safer way is what we did here that prompts for the password each time.

This should do it. :)
 
Sure thing. Open the Applescript editor app from the /Applications/Utilities folder. Then copy/paste in the below command.

Code:
do shell script "sysctl -w net.smb.fs.kern_deprecatePreXPServers=0" with administrator privileges

Then click the compile button in Applescript editor. Now click the run button to test your script. It should give you a popup window with your user name already filled in and the password window blank. Type in your password and hit return. That should execute the script.

If it worked okay, you now want to save the Applescript as an application. In Applescript editor click on the file menu then "save as" and name your new app. Toward the bottom of the save as window change the format from script to application. Pick where you want to save your app (I would put it in /Applications) then save it.

Quit the Applescript editor.

Now go to System Preferences / Users & Groups and click your user name then add your new app as a login item.

Logout then log back in. You should get the same password prompt you did earlier when testing. Type in the password and hit enter and your script should execute. You could embed the password in the script, but this is not very safe and exposes your password in a plain text file. The better and safer way is what we did here that prompts for the password each time.

This should do it. :)

Many many thanks - This works (sort of). It doesn't work from a cold boot, even though I get the prompt on start-up to put in my password for the newly-created app. However, it works fine if I click on the app after boot-up - this is good enough for me. I owe you a pint!:)
 
Why don't you try adding that sysctl setting to "/etc/sysctl.conf"? It has a man page, so maybe it will work.

Code:
sudo sh -c "echo net.smb.fs.kern_deprecatePreXPServers=0 >> /etc/sysctl.conf"
 
Why don't you try adding that sysctl setting to "/etc/sysctl.conf"? It has a man page, so maybe it will work.

Code:
sudo sh -c "echo net.smb.fs.kern_deprecatePreXPServers=0 >> /etc/sysctl.conf"

Thanks pitaya, someone else on the Satellite forum also has just mentioned "/etc/sysctl.conf", but without idiot's-guide instructions I have no idea how to edit things. And what is a man page?
 
A man page is a form of text based system documentation. You could think of man as short for manual. 'man' is the command you type in to read a page from the manual. If you open up a Terminal window you can enter the following to read about sysctl.conf.

Code:
man sysctl.conf

From the Description section:
Code:
The /etc/sysctl.conf file is read in when the system goes into multi-user mode to
     set default settings for the kernel.

The sudo command from my previous post will append your setting to the text file /etc/sysctl.conf . Enter that command into a terminal window. You can check the contents using a plain text editor, or:

Code:
cat /etc/sysctl.conf



Also, you can use 'apropos' to search for keywords in man page descriptions:

Code:
$ apropos sysctl
sysctl(3), sysctlbyname(3), sysctlnametomib(3) - get or set system information
sysctl(8)                - get or set kernel state
sysctl.conf(5)           - kernel state defaults

You can then read those man pages using 'man'.
 
A man page is a form of text based system documentation. You could think of man as short for manual. 'man' is the command you type in to read a page from the manual. If you open up a Terminal window you can enter the following to read about sysctl.conf.

Code:
man sysctl.conf

From the Description section:
Code:
The /etc/sysctl.conf file is read in when the system goes into multi-user mode to
     set default settings for the kernel.

The sudo command from my previous post will append your setting to the text file /etc/sysctl.conf . Enter that command into a terminal window. You can check the contents using a plain text editor, or:

Code:
cat /etc/sysctl.conf



Also, you can use 'apropos' to search for keywords in man page descriptions:

Code:
$ apropos sysctl
sysctl(3), sysctlbyname(3), sysctlnametomib(3) - get or set system information
sysctl(8)                - get or set kernel state
sysctl.conf(5)           - kernel state defaults

You can then read those man pages using 'man'.

Sorry, I'm missing something basic here, I still don't understand what to do.
 
  • remove login item
  • open Terminal.app window
  • copy/paste sudo command from above
  • cat /etc/sysctl.conf
  • does it look ok? Yes? Reboot
  • retrieve net.smb.fs.kern_deprecatePreXPServerskernel state (see below). Check that it's now 0

Code:
sysctl net.smb.fs.kern_deprecatePreXPServers
 
  • remove login item
  • open Terminal.app window
  • copy/paste sudo command from above
  • cat /etc/sysctl.conf
  • does it look ok? Yes? Reboot
  • retrieve net.smb.fs.kern_deprecatePreXPServerskernel state (see below). Check that it's now 0

Code:
sysctl net.smb.fs.kern_deprecatePreXPServers

Thanks - tried this, and after I enter the "cat /etc/sysctl.conf" script it returns the answer zero, so looks good, but when I reboot and try "sysctl net.smb.fs.kern_deprecatePreXPServers" it says "class not implemented".
 
Copy and paste exactly what you see in the terminal window, including the output of "cat /etc/sysctl.conf" and the output of the sysctl command line.

edit: Actually, sysctl.conf isn't working here either. Not sure why yet. You can always fall back on the login item.
 
Last edited:
Copy and paste exactly what you see in the terminal window, including the output of "cat /etc/sysctl.conf" and the output of the sysctl command line.

edit: Actually, sysctl.conf isn't working here either. Not sure why yet. You can always fall back on the login item.

@pitaya Any feedback on the Applescript issue he us having with not working on cold boot, but working on login (warm) boot? You think a "delay 2" at the top of the script is needed to let things settle before the command is run? I'm at a bit of a loss. :confused:
 
I don't know. I could try to speculate a little. Check this out:

Code:
$ sysctl net.smb.fs.kern_deprecatePreXPServers
net: class is not implemented
$ sudo /sbin/kextload /System/Library/Extensions/smbfs.kext
$ sysctl net.smb.fs.kern_deprecatePreXPServers
net.smb.fs.kern_deprecatePreXPServers: 1

That might explain sysctl.conf not working too. If the MIB (that's what the net.smb.... line is called) doesn't exist until a kernel module is loaded (smbfs.kext), and the module tends to get loaded on demand later, then sysctl won't work. So you could try adding that kextload line before the sysctl line in your login item script.

Another option would be to figure out how to make a StartupItem, or figure out how to easily load a kernel module earlier.
 
From sysctl.conf :

BUGS
If loadable kernel modules are used to introduce additional kernel functionality and sysctls to
manage that functionality, sysctl.conf may be processed too early in the boot process to set those
sysctls.

You could try a delay like Weaselboy said. Or manually loading smbfs.kext like pitaya said. Good thinking guys. Try this :

Code:
-- Script is NOT tested!
set the_command to do shell script "sysctl net.smb.fs.kern_deprecatePreXPServers 2>&1"
if the_command contains "class is not implemented" then
	do shell script "kextload /System/Library/Extensions/smbfs.kext" with administrator privileges
	do shell script "sysctl -w net.smb.fs.kern_deprecatePreXPServers=0" with administrator privileges
end if

You can edit /etc/sudoers to get rid of the with administrator privileges.
 
Last edited:
Solved!

Dear all, I was in the same situation: tried to make SMB access work by automatically running the shell command mentioned above. I made it work using launchd to load the smbfs kernel extension and then run the sysctl command (both at boot, as root).

Here's what I did:

STEP 1:
Create a script file (/fixSMBaccess.sh) with the following commands:
Code:
/sbin/kextload /System/Library/Extensions/smbfs.kext
sysctl -w net.smb.fs.kern_deprecatePreXPServers=0
Make this script executable by running:
Code:
sudo chmod +x /fixSMBaccess.sh
.
If this script is called at startup (or later), it will set net.smb.fs.kern_deprecatePreXPServers to zero, which allows connecting to SMB shares.

STEP 2:
Create the file /Library/LaunchDaemons/com.water.fixSMBaccess.plist containing the following lines:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple$
<plist version="1.0">
<dict>

<key>Label</key>
<string>com.water.fixSMBaccess</string>

<key>Disabled</key>
<false/>

<key>ProgramArguments</key>
<array>
<string>/fixSMBaccess.sh</string>
</array>

<key>RunAtLoad</key>
<true/>

<key>StandardErrorPath</key>
<string>/fixSMBaccess_errors.log</string>

<key>StandardOutPath</key>
<string>/fixSMBaccess_out.log</string>

</dict>
</plist>
This file will tell laundctl to run the above script at boot, so that you should automatically be able to mount SMB shares.

STEP 3:
Reboot and hope everything works as expected. If not, complain.
 
I bought a program called Lingon 3 which was supposed to make it easy, but it won't accept anything starting with "sudo" as it says this is not allowed in the "root"(??). I have no idea what this means.

Your problem is that you've got the wrong version of Ligon...
Ligon 3 (available from the app store) can't do anything as root - nothing from the app store can. What this means for those new to terminal is it can't do anything that starts with "sudo"

There is another version of Ligon (Ligon X, i think?) that you can download from the writers website that can run sudo (root) commands.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.