LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help with shell scripts (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-with-shell-scripts-387147/)

thorney 11-27-2005 10:37 PM

Need help with shell scripts
 
Hi,

How do I write a shell script that logs me into a remote machine, executes commands on the remote machine and then exits and returns me to my local machine prompt? (I have setup ssh to allow key authentication.) Any help would be awesome!!

thanks

Tinkster 11-27-2005 10:59 PM

Something like this?

Code:

#!/bin/bash
scp file user@remote-machine:/path/to/file
ssh user@remote-machine "commands; ..."


Cheers,
Tink

thorney 11-27-2005 11:09 PM

Ya I guess. So I take it that any commands that are in quotes get executed on the remote machine!?

Tinkster 11-27-2005 11:17 PM

That's right. If it's only a single command you can skip the
quotes, too.


Cheers,
Tink

thorney 11-27-2005 11:18 PM

Thanks Tinkster


All times are GMT -5. The time now is 06:07 AM.