![]() |
Enabling FileSharing from the command line
I would like to enable and disable filesharing via a command line script or applescript for that matter. The final goal is to run a cron job that enables my filesharing at known times throughout the day. I can then connect from a remote location and get at my files. Does anyone know of a way to do this. I can do the cron but can't seem to find a way to toggle filesharing any other way other than throught the gui.
Any help would be appreciated. Thanks |
It is possible, and there's a hint on the main site about it. But it references a script URL that's no longer there; I've asked the original author to send me a new URL (or the script!) and if I get anything, I'll let you know.
-rob. |
sudo SystemStarter start AppleShare
sudo SystemStarter stop AppleShare sudo SystemStarter restart AppleShare |
make sure the file /etc/hostconfig file has
AFPSERVER=-YES- in it not AFPSERVER=-NO- otherwise it won't start |
before I start a reminder that I am new at os x.
You have not said what you want to share. If the remote folder is a *nix share you can mount it from the command line fairly simply using a couple of versions of the same command: mount [-t nfs] machinename:sharename where the -t switch is optional. In os x, as I understand, it mount_nfs is an alternative, but I may be wrong. I don't currently have a dns server on my simple home network, (as my change from fixed ip addresses to dhcp only happened a few weeks ago) so currently I use: mount machine_ip_address:sharename hope that helps |
mount mount_cd9660 mount_devfs mount_ftp mount_msdos mount_smbfs mount_udf mount_webdav
mount_afp mount_cddafs mount_fdesc mount_hfs mount_nfs mount_synthfs mount_volfs these are all the cli apps to do with mounting under osx, each of them has a man page that can be viewed from the command line with the command: man command-name where command-name is, well, the command name i got this list by typing mount^d (^d is control-d) Hope this helps |
enabling Filesharing
Thanks Accura for that last post. I am however having trouble relating the information in the post to the task I am trying to do - enable filesharing from the command line or from an applescript. I am what you posted is quite relevant, but I know just little enough about this stuff to not see how to connect the dots between what you wrote and what I am trying to do.
When you get a moment could you clarify this for my simple mind. Thanks |
ok, first off u need to edit /etc/hostconfig and change the line
AFPSERVER=-NO- to AFPSERVER=-YES- then you need to run sudo SystemStarter start AppleShare to shut it down sudo SystemStarter stop AppleShare This is all for Apple File sharing, if you want to start windows file sharing you need to change the line SMBSERVER=-NO- and use sudo SystemStarter stop Samba The mount stuff i was talking about will allow you to mount servers from the cli as a clint and not start the services like the stuff above. if u want to do this from a apple script u can use do shell script 'shell-command' where 'shell command' is a shell command of some kind Hope this helps |
Filesharing
Thanks.
I will try that stuff. When I ran the SystemStart stuff as you spelled out I keep getting "Unknown Service Appleshare" . My /etc/hostconfig file does and already did read AFPSERVER=-YES- And a file called "Appleshare" is located in /System/Library/StartupItems It seems that all is as it should be but for some reason I get the Unknown Service message. BTW the other services in that same directory (/System/Library/StartupItems) work fine but not Appleshare. I will continue to battle this thing. thanks again for your help. |
can u post the out put of the following commands
ls -la /System/Library/StartupItems ls -la /System/Library/StartupItems/AppleShare Thank you |
ls -la /System/Library/StartupItems
drwxr-xr-x 33 root wheel 1122 Mar 18 19:27 . drwxr-xr-x 50 root wheel 1700 Jan 29 21:50 .. drwxr-xr-x 5 root wheel 170 Jul 27 2002 Accounting drwxr-xr-x 5 root wheel 170 Jul 27 2002 Apache drwxr-xr-x 5 root wheel 170 Jul 27 2002 AppServices drwxr-xr-x 5 root wheel 170 Jul 27 2002 AppleShare drwxr-xr-x 5 root wheel 170 Jul 27 2002 AppleTalk drwxr-xr-x 5 root wheel 170 Jul 27 2002 AuthServer drwxr-xr-x 5 root wheel 170 Dec 15 03:19 BIND drwxr-xr-x 5 root wheel 170 Jul 27 2002 ConfigServer drwxr-xr-x 5 root wheel 170 Jul 27 2002 CoreGraphics drwxr-xr-x 5 root wheel 170 Jul 27 2002 CrashReporter drwxr-xr-x 5 root wheel 170 Jul 27 2002 Cron drwxr-xr-x 5 root wheel 170 Jul 27 2002 DirectoryServices drwxr-xr-x 5 root wheel 170 Jul 27 2002 Disks drwxr-xr-x 5 root wheel 170 Jul 27 2002 IPServices drwxr-xr-x 5 root wheel 170 Jul 27 2002 LDAP drwxr-xr-x 5 root wheel 170 Jul 27 2002 LoginWindow drwxr-xr-x 5 root wheel 170 Jul 27 2002 NFS drwxr-xr-x 5 root wheel 170 Jul 27 2002 NIS drwxr-xr-x 5 root wheel 170 Jul 27 2002 NetInfo drwxr-xr-x 5 root wheel 170 Jul 27 2002 Network drwxr-xr-x 5 root wheel 170 Jul 27 2002 NetworkExtensions drwxr-xr-x 5 root wheel 170 Jul 27 2002 NetworkTime drwxr-xr-x 5 root wheel 170 Jul 27 2002 Portmap drwxr-xr-x 5 root wheel 170 Jul 27 2002 PrintingServices drwxr-xr-x 5 root wheel 170 Jul 27 2002 SSH drwxr-xr-x 5 root wheel 170 Jul 27 2002 Samba drwxr-xr-x 5 root wheel 170 Jul 27 2002 SecurityServer drwxr-xr-x 5 root wheel 170 Jul 27 2002 Sendmail drwxr-xr-x 5 root wheel 170 Jul 27 2002 SystemLog drwxr-xr-x 5 root wheel 170 Jul 27 2002 SystemTuning drwxr-xr-x 5 root wheel 170 Jul 27 2002 mDNSResponder ls -la /System/Library/StartupItems/AppleShare drwxr-xr-x 5 root wheel 170 Jul 27 2002 . drwxr-xr-x 33 root wheel 1122 Mar 18 19:27 .. -rwxr-xr-x 1 root wheel 350 Jul 27 2002 AppleShare drwxr-xr-x 17 root wheel 578 Jul 27 2002 Resources -rw-r--r-- 1 root wheel 221 Jul 27 2002 StartupParameters.plist |
sudo SystemStarter start AppleShare
Hey, the problem your having is to do with case you NEED to have the line with AppleShare (notice the upper case A and S) Sorry if i didn't make this clear jameso |
Quote:
Code:
$ sudo SystemStarter start AppleShare |
Ok, im not sure why this is because its different to every man page and online help file but if you type
sudo SystemStarter start Apple\ File\ Service or sudo SystemStarter start 'Apple File Service' but for the best you should use sudo /sbin/SystemStarter start Apple\ File\ Service this should also work but it doesn't. /sbin/SystemStarter restart /System/Library/StartupItems/AppleShare If you want to know the service name you need to hand SystemStarter you can cat the file /System/Library/StartupItems/ServiceFolder/StartupParameters.plist where ServiceFolder is the folder the service is living in, ie, SMB for samba. And look for the line "Provides", if there are any spaces u will need to use (') or (\) like I have above Sorry that i didn't pick this all up before, it was all taken from my head. James O'Farrell |
filesharing from command line
It seems that there is something to calling the following:
sudo Systemstarter start Apple\ File\ Service that seems to make a difference. However in the file /System/Library/StartupItems/AppleShare/AppleShare I see the following: #!/bin/sh ## # Apple File Protocol ## . /etc/rc.common StartService () { if [ "${AFPSERVER:=-NO-}" = "-YES-" ]; then CheckForNetwork if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi ConsoleMessage "Starting Apple File Service" AppleFileServer & fi } StopService () { return 0 } RestartService () { return 0 } RunService "$1" Through debugging, I determined that the first test: " if [ "${AFPSERVER:=-NO-}" = "-YES-" ]; then " is always failing. Regardless of what is in my /etc/hostconfig file. Somehow that line looks wrong to me. Why does it say {AFPSERVER:=-NO-} and not {AFPSERVER}. In other words it seems like the line should read: " if [ "${AFPSERVER}" = "-YES-" ]; then " If I change the line, all of this works fine. The problem is that the GUI seems to get out of synch. If i start file sharing in this manner and then go into the network control panel, the file sharing check box is checked but the text to the right of it reads "Personal Filesharing Off" (even though I can verify that filesharing is in fact on) If I then click the button or the checkbox, the status message changes to "Filesharing Shutting Down". And it remains like this forever. Even if I close the control panel and reopen it. The only way to clear it up is by clicking the "lock" icon on the lower left and then enter an admin password and the click the lock again. All of a sudden everything is in synch. It is as if this forces it to reparse the hostconfig file or something. Do I have to manually change the hostconfig file to read AFPSERVER:=-YES- after I turn filesharing on with SystemStarter? We're getting close on this thing. I appreciate all the input. |
Hmm.. FWIW, my AppleShare script looks the same on my machine. Strange, this looks like it should work..
Code:
[null:~] yellow% sudo SystemStarter start 'Apple File Service' |
"${AFPSERVER:=-NO-}"
means if the variable has no value, give it -NO- as a default from man sh: ${parameter:=word} Assign Default Values. If parameter is unset or null, the expansion of word is assigned to parame- ter. In all cases, the final value of parameter is substituted... |
filesharing
hmmm,
I wonder why mine won't work unless I modify that line. The saga continues.... |
From my logs when starting AFP from the GUI:
Jun 10 16:00:46 null configd[106]: executing /usr/sbin/AppleFileServer Hmm.. |
the script looks for that line, apples sharing gui button will turn this on so you must set it for the sharing to work, along with everything else. To let the gui "keep up" with your changes there is a plist file you can edit, its on the main site as a hint
jameso |
filesharing
Thanks. I went looking for the hint you referenced - didn't find it. If you happen to know which hint it is, that would be great. Thanks
|
I'm sorry, i can't actually find the info about it. I also had a look and could not find the plist file that no doubt will need editing. you would think it would be /Library/Preferences/com.apple.sharing.plist but its not. I did find mention to com.apple.sharing.plist in another plist file (i think the SystemPreferences plist file) but could not locate it on the disk.
***bang head on desk*** On my os 10.2.6 the GUI will keep up with using SystemStarter to quickly change the /etc/hostconfig file u can use this command sudo perl -i~ -pe 's/AFPSERVER=-YES-/AFPSERVER=-NO-/' /etc/hostconfig to change it back use sudo perl -i~ -pe 's/AFPSERVER=-NO-/AFPSERVER=-YES-/' /etc/hostconfig Have a good one jameso |
Hi there,
i would like to share some folders directly from the smb.conf! I am able to do that with Linux, and in Mac OS the file is /etc/smb.conf But where mac os puts the sharing folder settings when you edit the system preferences? Anyway if i edit smb.conf i have to activate the sharing folder settings in mac system preferences, in order to see what i shared in smb.conf! Why? Also i have to activate the guest account (only sharing). In linux you can do all of that simply editing the smb.conf and crate the sharing folders. Maybe is the smbd service? Is it possible to activate this service with terminal? Thanks Filippo |
Help please!
|
Self answer!
Only copy & edit elsewere smb.conf (/etc/smb.conf) Then: sudo /usr/sbin/smbd -D -s /Users/username/Desktop/smb.conf |
Enabling FileSharing from the command line
C3100 with standard Sharp ROM
Can someone give me the required commands to start a specific wireless network connection from the command line please? I want to set up a script to do it. |
| All times are GMT -5. The time now is 09:30 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.