Hello world again!, I know you can enable web sharing at startup using applescript, but can you do the same with file sharing for a account that doesn’t have system prefs accessing abilities?
Thanks
Ben
Also, does this form support Cocoa code too?
Thanks
Ben
Hi,
you can do this only this way.
edit /etc/hostconfig by changing
AFPSERVER=-NO-
into
AFPSERVER=-YES-
and then you can start and stop FileSharing from the command line
do shell script "/sbin/SystemStarter start AppleShare" user name "adminName" password "¢¢¢" with administrator privileges
At least the name and password of an admin account are required
PS: you can ask Cocoa questions in the Xcode forum. It’s actually for AppleScript Studio, but here are a few people with ObjC knowlegde
StefanK, you are the best. Thanks sooo much for all the help. Also, I just registered at xcodeforum.com
Thanks, however when I looked at this code :
Open this Scriplet in your Editor:
do shell script “/sbin/SystemStarter start AppleShare” user name “adminName” password “¢¢¢” with administrator privileges
I noted the key word: “Admin”. The accounts I am using this for are not admins. they are Managed.
Will this still work if I put it on a Managed account, also, what if the account has no password, what do I do?
Thanks
Ben
user name and password must be the access data of an admin account
Stefan
Can your shell script be adapted to turn the FTP option on and off to coincide with file sharing on and off. The default is no FTP when file sharing is turned on, so something extra is needed. I am running Leopard.
I was also wondering if there is a similar shell script work around to toggle internet sharing on and off?
Cheers
Andrew
In Leopard and higher services can (and should) be turned on/off with launchd
Basic Syntax
enable:
do shell script "/bin/launchctl load -w " & pathToServicePlist with administrator privileges
disable:
do shell script "/bin/launchctl unload -w " & pathToServicePlist with administrator privileges
administrator privileges are required! launchctl without sudo affects the agents / deamons in the user domain
Some service plist paths are:
FTP: /System/Library/LaunchDaemons/ftp.plist
FileSharing: /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist
Internet Sharing: /System/Library/LaunchDaemons/com.apple.InternetSharing.plist
Thanks for this Stefan. Will have a play around
Andrew