Solved Resolving a variable

I'm trying to run a program on a remote system over ssh using something like:-

ssh $REMOTE 'sh -x $PROG'

where $REMOTE is the IP address of the remote host, and $PROG is the program I want to run.

Unfortunately I can't get $PROG to resolve. The command works if PROG is hard coded.

The program is copied to the remote host successfully using:-

scp -p 22 $PROG root@$REMOTE:/root/$PROG

I'm trying to copy a program created by script, and run it on the remote. The copy works but I can't run it unless I hard code the program name. How do I resolve the variable $PROG when I want to run it?
 
If ${PROG} points to an executable and it has a proper shebang line, you don't have to start it with sh(1).
 
Code:
dice@fbsd-test:~/test % ll
total 1
-rwxr-xr-x  1 dice dice 76 May 29 11:48 heredoc.sh*
dice@fbsd-test:~/test % cat heredoc.sh
#!/bin/sh


cat <<HERE  > somefile.sh
#!/bin/sh

echo "Hello World!"
HERE


dice@fbsd-test:~/test % ./heredoc.sh
dice@fbsd-test:~/test % cat somefile.sh
#!/bin/sh

echo "Hello World!"
 
Yes, the same with any executable, current working directory is never part of PATH.
 
Back
Top