please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting please help
# 1  
Old 07-25-2006
please help

Hello everyone!

I'm using remote shell (rsh) to call a script on a remote computer. I'm checking error codes of the rsh command and the code that returns the remote computer:

stat=`rsh dpx20 '/tmp/arhiv/ProIV.sh; echo $?'`
echo "rsh return code: $?"
echo "dpx20 return code: $stat"

It's going fine but I wish to run the script with one argument. The code would be :

stat=`rsh dpx20 '/tmp/arhiv/ProIV.sh $DAN; echo $?'`
echo "rsh return code: $?"
echo "dpx20 return code: $stat"

but the script doesn't run with any parameter!

I tried this and script runs with argument $DAN:
job="/tmp/arhiv/ProIV.sh $DAN; echo$?"

stat=`rsh dpx20 $job`
echo "rsh return code: $?"
echo "dpx20 return code: $stat"

... but then I don't get proper return code from the dpx20 machine.

Any one has a suggestion to solve this problem?

Thanks for future posts!

Greetings
# 2  
Old 07-25-2006
Is the variable $DAN defined where it is being passed to the script as a parameter? If it isn't and it will be defined on the remote system when the script executed, then just escape the $ to prevent the $DAN from being substituted with its value.

Something like this:
Code:
stat=`rsh dpx20 '/tmp/arhiv/ProIV.sh \$DAN; echo $?'`
echo "rsh return code: $?"
echo "dpx20 return code: $stat"

--NOT TESTED
# 3  
Old 07-25-2006
The substitution of $DAN is not made by the current shell because the command is specified betwen simple quotes. It's the remote shell that make the substitution of the DAN variable that may be not define.

Change simple quotes by double quote and protec the substitution of ?
Code:
stat=`rsh dpx20 "tmp/arhiv/ProIV.sh $DAN; echo \$?"`
echo "rsh return code: $?"
echo "dpx20 return code: $stat"

Jean-Pierre.
# 4  
Old 07-25-2006
Hey blowtorch!

Yes, the variable is defined and initialized before with:

DAN=`date '+%a'`

Forgot to tell that. Sorry, my bad. So the value of $DAN has to be passed as the first argument when calling the script on the remote side.
# 5  
Old 07-25-2006
Hello Jean-Pierre!

Thanks for the post! I tried your suggestion, but the variable stat doesn't store the proper exit code from the script. If the script ProIV.sh on the remote side exits with code 1, the variable stat shuld have this return code but it has allways 0.
# 6  
Old 07-25-2006
Helo. The problem are the single quotes.
If there is no $DAN defined in dpx20 you will be executing the script without parameters.
Try this:
Code:
stat=`rsh dpx20 "(/tmp/arhiv/ProIV.sh $DAN; echo \$?)"`

Regards.
# 7  
Old 07-25-2006
I just used brackeds: "(" and ")" and now the script is executed with argument read from the variable DAN and I get the return code of the script either.

the code is:

stat=žrsh dpx20 '(/tmp/arhiv/ProIV.sh $DAN; echo $?)'ž

Thanks for solutions Smilie !!!
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question