|
|
AppleScript to Turn on Filesharing on Remote Machine
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
I am thisclose to making this work:
Code:
using terms from application "Finder"
tell application "Finder" of machine "eppc://myusername:[email protected]"
do shell script "/usr/sbin/AppleFileServer"
end tell
end using terms from
But it doesn't quite make it. No error message, but it doesn't appear to work. I've tried changing the target app to "System Events," tried appending "sudo" to the start of the script, but no dice. I even added "password x with administrator privileges" with no luck. Somebody help me. Thanks.
Could it be, ironically, that Filesharing has to be on for this to work? I know Apple Remote Events is set to "on" on the target machine....
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
My knowledge of remote AppleScripting is pretty limited, but as an alternative, since you are basically just running a shell script, don't you think a shell script might be a better fit for this?
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Originally Posted by Chuckit
My knowledge of remote AppleScripting is pretty limited, but as an alternative, since you are basically just running a shell script, don't you think a shell script might be a better fit for this?
Perhaps. But my knowledge of shell scripting is pretty limited. :-) Also, I intend to follow it up with more AppleScript code.
(
Last edited by selowitch; Jul 25, 2006 at 08:06 AM.
)
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
Originally Posted by selowitch
Perhaps. But my knowledge of shell scripting is pretty limited. :-) Also, I intend to follow it up with more AppleScript code.
Well, you COULD just write the shell script, include it inside the applescript bundle (or whatever), and be done...
Just to check, there's (IIRC) a setting someplace to enable remote Apple Events (I think it's in the Sharing Prefpane). doesn't that need to be on?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Originally Posted by arcticmac
Well, you COULD just write the shell script, include it inside the applescript bundle (or whatever), and be done...
Fine. Would you care to tell me how?
Originally Posted by arcticmac
Just to check, there's (IIRC) a setting someplace to enable remote Apple Events (I think it's in the Sharing Prefpane). doesn't that need to be on?
Remote Apple Events is definitely enabled on the remote machine and I'm pretty sure that, yes, that is necessary for this to work.
(
Last edited by selowitch; Jul 25, 2006 at 04:09 PM.
)
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
well, the shell script can actually *probably* be one line - I think an appropriately crafted SSH command would do it, so you could just write the statement. I think something like this...
or you could put it in a separate file,
and run that
Code:
do shell script "~/myshellscript"
That said, I haven't played around with this, and it still leaves how you're going to authenticate... you might be able to get applescript to send a newline and then your password in that first option, but...
play around.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
OK, I think I've made some progress, although it is not exactly working yet. Stay with me, folks.
I think this AppleScript, once corrected, may do the trick, without a tell block:
Code:
do shell script "/usr/bin/ssh johnsmith:[email protected] /usr/sbin/AppleFileServer"
No, it doesn't "work" exactly, but we're getting somewhere. Any further ideas?
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
Originally Posted by selowitch
Any further ideas?
my further idea would be that you try running the command in a terminal window until you can get it to a single line that does what you want. THEN put it into the applescript. The terminal will give you better debugging info that AppleScript. Also, remember, manpages are your friend. man ssh in a terminal to start, see what gives by reading that. It's more efficient for you to read it than for me to read it and tell you about it.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Try changing this to:
do shell script "/usr/bin/ssh [email protected]: /usr/sbin/AppleFileServer"
You can't pass off your password to SSH this way (and I hope that wasn't your personal password you just published). What you can do that is even better is setup SSH to connect via public/private key pairs. This approach is secure and well documented.
Here is a great tutorial on all things SSH. There is a section here on how to setup authentication via keys:
http://www.suso.org/docs/shell/ssh.sdf
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Originally Posted by arcticmac
my further idea would be that you try running the command in a terminal window until you can get it to a single line that does what you want. THEN put it into the applescript. The terminal will give you better debugging info that AppleScript. Also, remember, manpages are your friend. man ssh in a terminal to start, see what gives by reading that. It's more efficient for you to read it than for me to read it and tell you about it.
I'm trying this approach now (i.e., figuring out the proper Terminal command first).
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Note: No, besson3c, I did not just publish my password. The ones I did publish were made up. So, sleep soundly! :-)
OK, here's my progress so far:
1. Turning Filesharing On Locally via AppleScript
Code:
do shell script "/usr/sbin/AppleFileServer/" password "mypassword" with administrator privileges
2. Turning Filesharing Off Locally via AppleScript
Code:
do shell script "/usr/bin/killall AppleFileServer/" password "mypassword" with administrator privileges
These two scripts work great with just one line apiece, no tell block or anything. There is a slight delay, and if you are viewing the Services tab of the Sharing pane of System Preferences, you may need to switch away from it and back again to see the checkmark indicating Filesharing has been toggled on or off. But it works.
3. Turning Filesharing On Locally via Terminal
Here's a transcript of a Terminal session that successfully achieves this:
Code:
Last login: Sat Jul 29 19:38:54 on ttyp1
Welcome to Darwin!
Sam-Elowitchs-Computer:~ samelowitch$ sudo /usr/sbin/AppleFileServer/
Password:
Sam-Elowitchs-Computer:~ samelowitch$
4. Turning Filesharing Off Locally via Terminal
Here's a transcript of a Terminal session that successfully achieves this:
Code:
Last login: Sat Jul 29 19:38:54 on ttyp1
Welcome to Darwin!
Sam-Elowitchs-Computer:~ samelowitch$ sudo /usr/bin/killall AppleFileServer/
Password:
Sam-Elowitchs-Computer:~ samelowitch$
(
Last edited by selowitch; Jul 30, 2006 at 04:20 PM.
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|