On Thu, 2 Feb 2006, Tomasz Chmielewski wrote:

- the output of the script is "guessed-name005" (and exit status 0) in case it 
guessed the name correctly,

OK.

- it exits with the status 1 if there was an error (couldn't connect to LDAP 
etc.).
What should be done now?

====

--> Sample: Get name from IP-address
# Get the current system's name from IP address
use Sys::Hostname;
if(my $hostname = hostname) {
        if($hostname =~ /^([a-zA-Z0-9\-_]+)/) {
                $u->{'UserData'}->{'ComputerName'} = $1;
                print STDERR "Got name via DHCP: $1\n";
        }
}

====

# Get the current system's name via script
if(my $hostname = `script`) {
        # Use only that part of the name that consists of
        # alnum characters, dash or underscores
        if($? == 0 && $hostname =~ /^(?:guessed-)?([a-zA-Z0-9\-_]+)/) {
                $u->{'UserData'}->{'ComputerName'} = $1;
                print STDERR "Got name via script: $1\n";
        }
}
# Remove the "(?:guessed-)?" if you want to have it in the name

Bye,

--
Steffen Kaiser


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
unattended-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unattended-devel

Reply via email to