Quote:
Originally Posted by TBotNik
Having an issue with a BASH script where it needs the hostname running the sudo cmd!
|
Here you're talking about sudo
Quote:
konsole --tabs-from-file ktabs.txt -exv "su -u root -p $mypss"
which is to open the konsole in sudo mode.
|
But here you're using su, not sudo!
Quote:
So where do I set the hostname that sudo is looking for?
|
Normally with "hostname <the name to set>"
Code:
# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
/bin/hostname $(cat /etc/HOSTNAME)
else
and as you can see in MY system the file that it is stored in is
/etc/HOSTNAME (all caps)
I've never heard of the file /etc/hostname (all lower case) and the one you quoted seems to be a subset of /etc/hosts
Furthermore the system library doesn't really support gethostname(2), the call that the hostname command uses:
Quote:
The GNU C library does not employ the gethostname() system call;
instead, it implements gethostname() as a library function that calls uname(2)
and copies up to len bytes from the returned nodename field into name.
|
and
Quote:
the field nodename is meaningless:
it gives the name of the present machine in some undefined network, but typically machines are in more than one network and have several names. Moreover, the kernel has no way of knowing about such things, so it has to be told what to answer here
|
(from the man pages gethostname(2) and uname(2)
So this suggests too that when never SET the hostname command returns nothing,