linuxbashhp-uxrsh

How to source remote scripts and assign variables remotely in rsh?


There is this problem that's been bothering me lately.

I'm trying to do the following using rsh or remsh (in HPUX):

#!/bin/sh
rsh myDNS"
  DIRECTORY=/tmp/foo1/foo2
  echo $DIRECTORY
"

When I try to run the above script, however, I get blank output for $DIRECTORY. Consequently, when this issue is applied to the actual scripts I'm working on, bash claims that it could not find the specified script that I was trying to source.


Solution

  • You're better off using ssh than using rsh or remsh. rsh and remsh are very insecure - the transmit data in cleartext and are based on IP address authentication.

    If you use double quotes like that, $DIRECTORY gets expanded on the initiating host, before rsh/remsh is started.

    If you use single quotes (apostrophes) instead, $DIRECTORY should be expanded on the remote host.