Re: [OT] run command via ssh - problem

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

 



On Wed, 2009-11-04 at 14:14 +0100, Joachim Backes 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.

That will try to execute the name of the remote host as though it was a
command (backticks expand on the remote host and the output of the
hostname command is used as the command line).

$ ssh abox '`hostname`'
bash: abox.example.com: command not found

Bryn.


-- 
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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux