Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
problems getting shell scriptie to work!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
dirtbag
Guru
Guru


Joined: 18 Feb 2003
Posts: 508
Location: NC

PostPosted: Wed Apr 25, 2012 10:35 pm    Post subject: problems getting shell scriptie to work! Reply with quote

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
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Wed Apr 25, 2012 10:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
dirtbag
Guru
Guru


Joined: 18 Feb 2003
Posts: 508
Location: NC

PostPosted: Wed Apr 25, 2012 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Thu Apr 26, 2012 2:24 am    Post subject: Reply with quote

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
View user's profile Send private message
dirtbag
Guru
Guru


Joined: 18 Feb 2003
Posts: 508
Location: NC

PostPosted: Thu Apr 26, 2012 1:13 pm    Post subject: Reply with quote

ok


ssh host2 'sed -e "s/^/$(hostname) /" /tmp/part3'

seems to have worked..

-db
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum