Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- chaining ssh commands
September 26, 2005, 6:55 am
rate this thread
I need to cd to /usr/me directory on the remote machine and extract
me.tar in that directory. I'm wondering how we can chain ssh commands
ssh me@remotebox cd /usr/me;ssh me@remotebox tar -xvf me.tar
Unfortunately, ssh will relogin into /home/me directory to extract the
tar instead of using /usr/me directory. Does someone have an idea of
how to do that properly?
Thanks in advance.
- Jacques-Olivier Haenni
September 26, 2005, 7:13 am
Re: chaining ssh commands
Note that if the "cd" fails it will still run the second command.
In this example it's probably not a big deal, but under other conditions
it might be.
To prevent that, use "&&" instead, eg:
$ ssh me@remotebox 'cd /usr/me && tar -xvf me.tar'
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
- Nico Kadel-Garcia
September 26, 2005, 12:30 pm
- » How to run a command after logging using a SFTP client..
- — Next thread in » Secure Shell Forum
- » protocol question - issue with exit-status inside unfinished data stream?
- — Newest thread in » Secure Shell Forum