comands inside the script

hi,

i want to put a set of commands inside a script and executing commands sequentially. there are 2 commands, the first command copies the program from my machine to another machine, execute it and get the result on my machine. the second command removes the program which was copied to the remote machine. I have already made the ssh authentication. I need to integrate both of them in one single script so that if i run that script it gives the result. Can somebody give some suggestions?

first command

cat /path of my machine/script.pl | ssh user@remotemachine "cat > /path of the remote server where the file is copied/backup_script.pl ; perl /path of the remote server where the file is copied/backup_script.pl

second command: removing the file after executing

ssh user@remotemachine rm /path of the remote server where the file is copied/backup_script.pl

thanks.

Instead of using cat and piping, couldn't You just do something like:

#!/bin/sh
scp script.pl user@remote:
result=$(ssh user@remote script.pl)
ssh user@remote rm script.pl
echo $result

Thanks a lot Lakris...

#!/bin/sh
scp script.pl user@remote:remote path
result=$(ssh user@remote script.pl)
echo $result
ssh user@remote rm script.pl

i jus swapped the last 2 lines of ur script, cuz it deletes the file before it gets executed.

thanks.

NP,

Yes but the content of result is in Your local machine, isn't it? And that doesn't get deleted until You end the script.
:slight_smile:

/L

ohhh k... i got it ....

thanks.