Operating System - HP-UX
1752694 Members
5660 Online
108789 Solutions
New Discussion

execute if statement via ssh

 
SOLVED
Go to solution
rleon
Regular Advisor

execute if statement via ssh

I would like to run an if statement on a remote machine via ssh.

 

if [ -f /home/user/myfile ]

then

mv  /home/user/myfile /tmp/myfile

do

more

stuff

else

do that

fi

 

I can do it if i convert it into a one liner

But I was wondering if there was a better way.

 

 

 

1 REPLY 1
Dennis Handly
Acclaimed Contributor
Solution

Re: execute if statement via ssh

>I would like to run an if statement on a remote machine via ssh.

 

You could just copy the script there and run that.

 

>I can do it if I convert it into a one liner

 

Yes that works.

Or you could redirect stdin with a here doc and include the commands.