Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
here is the the part of the IMSLook.pl:
the problem is when i run, the apache server error log giving me the error that say i dun supply the host name for them. It mean the $hostname in (sub IMSConnect) didn't get any value can anyone check it for me. Thank you--------------------------------------- package IMSLook; use Socket; use CGI qw/:standard/; require "LDAPLook.pl"; require "LDAPAdd.pl"; require "LoadConfig.pl"; # ----------------------------------------------------------# global v +ariables # ----------------------------------------------------------my %server +con = &LoadConfig::LoadConfig("server.conf"); my $hostname = $servercon{'hostname'}; my $port = $servercon{'port'}; my $password = $servercon{'password'}; my $logdir = $servercon{'logdir'}; sub IMSConnect { my $response; my $iaddr = inet_aton($hostname) || die "no host: $server"; my $paddr = sockaddr_in($port, $iaddr); my $proto = getprotobyname('tcp'); # Open socket connection to the server socket($sock, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; connect($sock, $paddr) || die "unable to connect"; select($sock); $| = 1; select(STDOUT); &SOCKETread($sock); &SOCKETwrite($sock, "LOGIN $password WRITE\n"); $response = &SOCKETread($sock); if ($response =~ /.*OK.*/) { &TaskLog("IMSLook sub::IMSConnect: Successfully connected +to IMS\n"); return 0; } &TaskLog("IMSLook sub::IMSConnect: Access denied to IMS, possibly +invalid password\n"); return 1; } Here is the part for the LoadConfig.pl function : -------------------------------------------------- package LoadConfig; use IO::Handle; sub LoadConfig() { $config_file = $_[0]; #open a file handle open(MYHANDLE, "<$config_file") or die "could not open file"; while (<MYHANDLE>) { chomp; s/#.*//; # no newline s/^\s+//; s/\s+$//; next unless length; my ($var, $value) = split(/\s*=\s*/, $_, 2); $User_Preferences{$var} = $value; } return %User_Preferences; } # ~LoadConfig() 1; here is the the part of the text file name Server.conf: -------------------------------------------------------- hostname="sgsms.asia.com" port="4200" password="p" logdir="C:\\tempperl" host='sgsmld.d1asia.com:351' host392='sgsmld.asia.com:352'
Petruchio - Wed Jul 11 02:24:01 EDT 2001 - Added code and p tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can anyone help to detect any error in this script
by Abigail (Deacon) on Jul 11, 2001 at 11:00 UTC | |
|
Re: can anyone help to detect any error in this script
by alfie (Pilgrim) on Jul 11, 2001 at 10:07 UTC |