LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-11-2004, 03:13 PM   #1
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Rep: Reputation: 0
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
 
Old 03-11-2004, 04:13 PM   #2
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 03-11-2004, 04:16 PM   #3
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 03-11-2004, 04:53 PM   #4
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Seems to be working OK.

THanks for the help-
Erik
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi shell script: ssh not working kitmui Programming 2 04-21-2010 02:46 PM
Running a shell script remotely via 'ssh <hostname> <command>' davee Linux - General 4 10-09-2005 01:38 AM
shell script + change shell && continue darkRoom Programming 6 02-25-2005 02:50 AM
Shell Script with ssh & scp ErikJohnson Linux - Networking 1 03-11-2004 04:14 PM
Ssh or logging from shell script Alek Linux - General 5 09-24-2003 10:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration