A
Adrian Rafferty
Hi,
i'm trying a dummy perl script on solaris ....
# cat test
#!/bin/perl -w
use Sys::Hostname;
my $hostname = hostname();
print "Hostname = $hostname\n";
#
the problem that i have is that some of the hosts have an
/etc/nodename
= to the fqdn , others have the none fqdn nodename
(e-mail address removed): # cat /etc/nodename
gdwtest.au.thenational.com
(e-mail address removed): # ./test
Hostname = gdwtest.au.thenational.com
(e-mail address removed): #
i.e ..
n144110@webjump2: $ ./test
Hostname = webjump2
n144110@webjump2: $
How can i change the output of the script to be "gdwtest"
i.e. the first field of the fqdn ??
I have tried ...
(e-mail address removed): # hostname | perl -lne 'print
((gethostbyname $_)[0])'
gdwtest
(e-mail address removed): #
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
the correct o/p is also displayed in the host without the fqdn ...
n144110@webjump2: $ hostname | perl -lne 'print ((gethostbyname
$_)[0])'
webjump2
n144110@webjump2: $
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
Any help greatly appreciated,
Regards Adrian
i'm trying a dummy perl script on solaris ....
# cat test
#!/bin/perl -w
use Sys::Hostname;
my $hostname = hostname();
print "Hostname = $hostname\n";
#
the problem that i have is that some of the hosts have an
/etc/nodename
= to the fqdn , others have the none fqdn nodename
(e-mail address removed): # cat /etc/nodename
gdwtest.au.thenational.com
(e-mail address removed): # ./test
Hostname = gdwtest.au.thenational.com
(e-mail address removed): #
i.e ..
n144110@webjump2: $ ./test
Hostname = webjump2
n144110@webjump2: $
How can i change the output of the script to be "gdwtest"
i.e. the first field of the fqdn ??
I have tried ...
(e-mail address removed): # hostname | perl -lne 'print
((gethostbyname $_)[0])'
gdwtest
(e-mail address removed): #
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
the correct o/p is also displayed in the host without the fqdn ...
n144110@webjump2: $ hostname | perl -lne 'print ((gethostbyname
$_)[0])'
webjump2
n144110@webjump2: $
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
Any help greatly appreciated,
Regards Adrian