Re: [OT] run command via ssh - problem

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

 



On Wed, Nov 4, 2009 at 2:29 PM, Bryn M. Reeves <bmr@xxxxxxxxxx> wrote:
> On Wed, 2009-11-04 at 13:32 +0000, Dan Track wrote:
>> Hi Bryn,
>>
>> Many thanks. I tried hostname -s but I keep getting the following:
>>
>> hostname: Host name lookup failure
>
> Possibly your resolver on the servers is not configured to search its
> own local domain. Add a line like this to /etc/resolv.conf:
>
> search mylocaldomain.com
>
> Or, if you configure the resolver via dhcp add a directive on the server
> to pass this over to clients.
>
>> This may be because the hostname's are short already e.g just
>> "server1" instead of "server1.example.com"
>>
>> I've updated teh script to your recommendations but I still get the
>> local hosts hostname in teh output instead of the remote servers
>> hostname. Any other thoughts?
>>
>> I now run the following:
>>
>> for i in server1 server2;do ssh root@$i "DNSNAME=$(basename
>> $(hostname)$);echo $DNSNAME";done
>
> You need to use single quotes instead of double quotes - see the rules
> in the bash man page about quote expansion. A single quoted string is
> not subject to any expansion by the shell on the client machine but a
> double quoted string will be expanded on the client before the ssh
> command is executed.
>
> $ ssh abox 'DNSNAME=$(basename $(hostname));echo $DNSNAME'
> abox.example.com
>
> I still don't think that basename will do what you want here...
>
> Regards,
> Bryn.

Great that single quote worked. It's nwo returning the correct result.
Many thanks. The basename command works well.

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
[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