Operating System - HP-UX
1825795 Members
2242 Online
109687 Solutions
New Discussion

Re: "if" sentence embedded into a remsh command line

 
SOLVED
Go to solution
Jose Mosquera
Honored Contributor

"if" sentence embedded into a remsh command line

Hi pals,

I need execute the following simplest "if" sentence into a remsh command line (HPUX-11)

if [ -d $REMOTE_DIR ]
then
echo 0
else
echo 9
fi

remsh $REMOTE_HOST -l root -n

Rgds and thks in advance
4 REPLIES 4
G. Vrijhoeven
Honored Contributor
Solution

Re: "if" sentence embedded into a remsh command line

Hi,

I always us && in a remsh string.

remsh $REMOTE -l user -n " test -d REMDIR && echo 0"

It laks the else but it might be enough.

Gideon
Mark Grant
Honored Contributor

Re: "if" sentence embedded into a remsh command line

One possibility is to abandon "if" altogther

remsh host "test -d $REMOTE_DIR && echo 8"

Then, if you don't get an 8 you can assume that $REMOTE_DIR didn't exist.

Never preceed any demonstration with anything more predictive than "watch this"
T G Manikandan
Honored Contributor

Re: "if" sentence embedded into a remsh command line

put that into a script on the remote machine and then do a
remsh -n <script-name>
Jose Mosquera
Honored Contributor

Re: "if" sentence embedded into a remsh command line

Thank you Mr. Vrijhoeven, for me is enough know an echo condition.
My final command line is:
remsh $REMOTE_HOST -l root -n "test ! -d $REMOTE_DIR && mkdir -m 755 $REMOTE_DIR"

Rgds.