LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Shell Script with ssh & scp (https://www.linuxquestions.org/questions/linux-software-2/shell-script-with-ssh-and-scp-156402/)

ErikJohnson 03-11-2004 04:13 PM

Shell Script with ssh & scp
 
I want to use a shell script to ssh onto a remote machine and tar some files and copy them to my local machine. I already have it set up to log me in without a password prompt.

The problem is that once I am logged into the remote machine, the script stops running (or fails to continue running there). When I manually close the ssh connection, the script continues on (with errors now of course). I assume the script is waiting for the ssh program to end before continuing on with the script.

Is there a way to run a local script and have it do the commands for me once I'm logged into a remote system with ssh?

Thanks-
Erik

druuna 03-11-2004 05:13 PM

You don't show the command you are using to do this. Are you sure it's correct?

Something like this should work:
ssh -l <user> <remotehost> "cd /some/dir ; tar cf some.tar dir/*"
This would, on the remote host, cd to a directory, tar the everything in dir directory.

Hope this helps.

ErikJohnson 03-11-2004 05:16 PM

Well, the command I was originally doing was this:

ssh me@remote.com
tar -cf files.tar ./dir/* etc.

Then I tried this:

ssh me@remote.com tar -cf files.tar ./dir/*

which just pooped out and hung. I suppose I need the quotes.


Thanks-
Erik

ErikJohnson 03-11-2004 05:53 PM

Seems to be working OK.

THanks for the help-
Erik


All times are GMT -5. The time now is 10:24 AM.