On Wed, Nov 4, 2009 at 1:14 PM, Joachim Backes <joachim.backes@xxxxxxxxxxxxxx> wrote: > On 11/04/2009 02:10 PM, 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 >> > > Use the following > for i in server1 server2;do ssh root@$i '`hostname`';done. > > > Explanation: `hostname`, or $(hostname), is already evaluated on the source > host by your shell (even inside of "...") , not on the target host. > -- > > Joachim Backes <joachim.backes@xxxxxxxxxxxxxx> > > http://www.rhrk.uni-kl.de/~backes > Hi, Thanks for that, any thoughts on how it fits in with my script: for i in server1 server2;do ssh root@$i "DNSNAME=\"basename\`hostname\`\";echo $DNSNAME";done Thanks Dan -- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines