Re: Running ssh from AppleScript...
Re: Running ssh from AppleScript...
- Subject: Re: Running ssh from AppleScript...
- From: "John W. Baxter" <email@hidden>
- Date: Mon, 19 Jan 2004 15:36:32 -0800
- Envelope-to: email@hidden
On 1/19/2004 9:26, "David Crowe" <email@hidden> wrote:
>
I'm not having much success running 'ssh' from AppleScript.
>
>
>
The command line:
>
>
do shell script "(echo \"~/ssh-mail\" | login -f $USER ) &"
>
>
>
runs ssh (via the script 'ssh-mail' which only executes the Unix
>
'ssh' command with the right port mapping) but it logs out right away.
>
>
I used a similar command to run a VPN client in the background:
>
>
(do shell script "(echo \"echo y | /usr/local/bin/vpnclient
>
connect " & theProfile & " user " & theUserName & " pwd " &
>
thePassword & "\" | login -f $USER ) >/tmp/startvpn.tmp 2>&1 &")
>
>
>
>
I know piping the command line to login is a bit convoluted, but it's
>
the only way I could get it to work. As with vpnclient, running ssh
>
directly results in it complaining that it's standard input is not a
>
terminal.
It was situations like this which led to the development of the wonderfully
powerful and often frustrating language Expect, which sits atop TCL (tool
control language).
We have Expect version 5.38.0 in Panther 10.3.2 (we didn't have it at all in
10.0). man expect will lead to shock--the old O'Reilly book Exploring
Expect was a good source. In the Expect language, everything is a string,
and the braces are where they are because that's where they are. [It's much
stranger in that respect than is AppleScript and its parenthesis pairs.]
But...Expect's job is to drive processes which think they are talking to a
live human who is using a teletype. And it does the job very very well.
I would attack problems similar to yours by writing an Expect script and
triggering it with do shell script (or just run it from Terminal or from
cron).
--John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.