Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Unix&Linux>>Issuing multiple commands through SSH

Issuing multiple commands through SSH

potato95
04-05-2005, 12:25 PM
Simple newbie question:

I want to use SSH to login to a remote machine, make a backup of a file, gzip it and then logout using a simple bash script. I know I need to manually login but from then on I would like to execute the other commands automatically.

Here is the simplified code....

1 ssh admin@xxx.xxx.xx.xxx
2 cp file1 file1.bak
3 gzip file1.bak
4 exit

If I put this in a bash script I just get to the remote machine prompt. How can I get the remote machine to execute lines 2,3 and 4


Regards

kd4ttc
04-05-2005, 03:38 PM
ssh admin@xxx.xxx.xx.xxx 'cp file1 file1.bak ; gzip file1.bak'

Set it up for passwordless login.

Alternative: put a shell script on the target computer and then invoke it remotely with ssh. For multiple commands that might work better.

You can also pipe the output:
ssh admin@xxx.xxx.xx.xxx 'cp file1 file1.bak ; gzip file1.bak' | grep grep_args


Steve


 

TOP

Windows Server Outsell
Unix Signals And C++ E

For more info

Unix Signals And C++ E
Windows Server Outsell
ssh setup for password
Bash script does not w
esc code 
ARD send unix command 
question about binarie
Scanning mail 
Issuing multiple comma
How do I install Linux

News Archive

/etc/hosts? 
Manually Start a Start
mounting missed hard d
Using Netinfo in Singl
darwin/bsd login probl
system_profiler and fi
Send mail from script 
mounting a drive 
OS X disk first aid ha
system.log shows steal

Related stories:

Bash script does not work!
esc code
ARD send unix command question
question about binaries
installing Libusb
ssh setup for passwordless login
quoting string with single quotes inside?

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics