[ale] Remote Shell Question

Randy Ramsdell rramsdell at livedatagroup.com
Wed Jan 3 13:22:47 EST 2007


Michael B. Trausch wrote:
> On Tue, 2007-01-02 at 23:34 -0500, Vikram Nanda wrote:
>> Hi,
>>
>> I have a shell script on Unix box A. I want to execute it on another 
>> Unix box B from the box A. The restriction is that the script file
>> cannot physically land (or copied) on B. Is there any way this could
>> be accomplished through rsh/rexec ?
>
> This sounds like a silly restriction that I had when I was working
> with boxes at AT&T... I wanted to write scripts to automate silly
> trivial tasks that I had to do on a daily basis, but they wouldn't
> permit those scripts from so much as residing in my networked $HOME
> because they would be "modifications to the platform...".
>
> I got around it by writing the script and saving it on my own
> workstation, and when I needed to use it, using a generic script that
> used telnet to pipe the script into the shell on the other end, and
> then display the results on my tty locally, or redirect to a file
> using regular shell redirection and the like.
>
> I don't have the script that I used anymore, but I remember that I had
> to use () to run things in a subshell and then pipe them into telnet,
> with a series of commands to do the login, and then move the script
> over to run before disconnecting.  It would be something along the
> lines of:
>
> (
>   sleep 1
>   echo $USER
>   sleep 1
>   echo $PWD
>   sleep 1
>   IFS='
> '
>   for line in $SHELL_SCRIPT; do echo "$line"; sleep 1; done
>   echo "exit"
> ) | telnet $HOST
>
> That should get you started... hope this helps.
You could use a "here document."

It takes this form.

####################
telnet host  <<telnet_args

commands
.
.

telnet_args
####################


http://www.tldp.org/LDP/abs/html/here-docs.html
http://www.tldp.org/LDP/abs/html/here-docs.html#HF

Randy Ramsdell





More information about the Ale mailing list