View previous topic :: View next topic |
Author |
Message |
dirtbag Guru
Joined: 18 Feb 2003 Posts: 508 Location: NC
|
Posted: Wed Apr 25, 2012 10:35 pm Post subject: problems getting shell scriptie to work! |
|
|
ok, here is what I want to do ..
Quote: | [root@host1 ]# ssh host2 "sed -e 's/^/'"`hostname`"' /' /tmp/part3" |
and what I get back is
Code: | host1 root somehost Tue Apr 10 16:25:50 -0400 2012
host1 alice beast Thu Jun 3 09:38:42 -0400 2010
host1 fred hulk Tue Apr 24 11:04:26 -0400 2012 |
i am expecting the `hostname` to get run on the box that I am doing the ssh to.. but it appears that somehow its getting executed on the local box that im running the ssh command from.
WTF?!
-db |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Wed Apr 25, 2012 10:45 pm Post subject: |
|
|
Quote: | [root@host1 ]# ssh host2 "sed -e 's/^/'"`hostname`"' /' /tmp/part3" |
... very funky quoting you've got there. Either that should be fixed, for instance $(hostname) (backticks are bad...) or just write the command in a script on the remote host and execute this?! _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
dirtbag Guru
Joined: 18 Feb 2003 Posts: 508 Location: NC
|
Posted: Wed Apr 25, 2012 10:55 pm Post subject: |
|
|
yeah i need the funky quoting to get the hostname command to run within a remote loop over ssh . ..
I could make the program run remotely, but I am going to run this command over a bunch of hosts in a loop, so that wouldnt be a very good option.
-db |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Thu Apr 26, 2012 2:24 am Post subject: |
|
|
To elaborate on the hint that avx gave you, why are you running hostname locally and inserting its contents into the otherwise remote string? |
|
Back to top |
|
|
dirtbag Guru
Joined: 18 Feb 2003 Posts: 508 Location: NC
|
Posted: Thu Apr 26, 2012 1:13 pm Post subject: |
|
|
ok
ssh host2 'sed -e "s/^/$(hostname) /" /tmp/part3'
seems to have worked..
-db |
|
Back to top |
|
|
|