I an having a problem. Just to start, when I run this same script on Windows box with comperable config it works fine. I move my PHP script to Linux and it fails. PHP exec's to my perl script. I pass the IP, login, and password to the perl script and it should return the output in an array. This is not working. I fail on connection and the return error is:
problem connecting to "x.x.x.x", port 23: Permission denied at get.pl line 22
Script is as follows:
#use Net::Telnet::Cisco;
use Net::Telnet::Cisco::IOS;
use Switch;
use Net::DNS;
use Net::IPAddress;
require biosearcher;
sub printfile($) {
my $str = shift;
print "$str \n";
return;
}
if ((ip2num($ARGV[0]) > '167772160' && ip2num($ARGV[0]) < '184549375') || (ip2num($ARGV[0]) > '2886729728' && ip2num($ARGV[0]) < '2887778303') || (ip2num($ARGV[0]) > '3232235520' && ip2num($ARGV[0]) < '3232301055')) {
$private = 1;
}else{
$private = 0;
}
# WE NEED THIS TO CHECK THE COMMAND LINE
$cl = $ARGV[0];
if (defined $cl) {
# IF EVERYTHING IS OK THEN PROCEED ELSE DROP TO END
if ($private) {
$connection = Net::Telnet::Cisco::IOS->new(Host => $ARGV[0]); # THIS IS LINE 22
}else{
$connection = Net::Telnet::Cisco::IOS->new(Host => "daagw00");
$do = "o $ARGV[0]";
my $ok = $connection->print($do);
}
When I run this from the console it works fine. It only fails when I run it from the exec() in PHP as follows:
$run = "perl get.pl $ipaddress $user $pass $site";
exec($run, $output, $input);
Any help would be appreciated.
jeffry.maynard@gmail.com
Logged In: YES
user_id=680645
Originator: NO
Can you run the PHP from console?
php myscript.php
Logged In: YES
user_id=503535
Originator: NO
Yes, I am able to run it from the console with no problems.
Logged In: YES
user_id=503535
Originator: NO
Yes, I am able to run it from the console with no problems.
Logged In: YES
user_id=680645
Originator: NO
I'm afraid I have no clue. I would guess it's probably a PHP security thing. Possibly something to do with the user that your web server runs as not being able to make sockets.
Sorry. :(