Re: [OT] run command via ssh - problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/04/2009 05:10 AM, Dan Track wrote:
Hi,

I'm running a command like this:

for i in server1 server2;do ssh root@$i "`hostname`";done.

However the hostname command always outputs the hostname of the server
that the above command is run from. I'd like to know how to run this
hostname command so that it actually runs on server 1, server2 etc..

Thanks
Dan


Content inside double quotes is evaluated by shell, so backtick expansion happens on localhost.
Use single quotes, instead, like so:

for i in server1 server2;do ssh root@$i '`hostname`';done


HTH

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux