I have a perl script that uses Net::OpenSSH and Net::Telnet. I am able to run the script from the command line of my server (solaris) and it seems to run correctly, including the ssh and telnet parts.
However, if I try to exec that script from php it doesnt work. The files the script is supposed to create do not get created, and in the error_log I see some errors related to libssh2.so and ssh2.so. However, my PHP code has no SSH related lines. Only the Perl does.
I see this line in the log quite a few times:
I also see this:[Fri Apr 01 15:11:57 2016] [warn] (128)Network is unreachable: connect + to listener on [::]:443
ssh: illegal option -- M Usage: ssh [options] host [command] Options: -l user Log in using this user name. -n Redirect input from /dev/null. -F config Config file (default: ~/.ssh/config). -A Enable authentication agent forwarding. -a Disable authentication agent forwarding (default). -X Enable X11 connection forwarding. -x Disable X11 connection forwarding (default). -i file Identity for public key authentication (default: ~/.ssh/ +identity) -t Tty; allocate a tty even if command is given. -T Do not allocate a tty. -v Verbose; display verbose debugging messages. Multiple -v increases verbosity. -V Display version number only. -q Quiet; don't display any warning messages. -f Fork into background after authentication. -e char Set escape character; ``none'' = disable (default: ~). -c cipher Select encryption algorithm -m macs Specify MAC algorithms for protocol version 2. -p port Connect to this port. Server must be on the same port. -L listen-port:host:port Forward local port to remote address -R listen-port:host:port Forward remote port to local address These cause ssh to listen for connections on a port, and forward them to the other side by connecting to host:por +t. -D port Enable dynamic application-level port forwarding. -C Enable compression. -N Do not execute a shell or command. -g Allow remote hosts to connect to forwarded ports. -1 Force protocol version 1. -2 Force protocol version 2. -4 Use IPv4 only. -6 Use IPv6 only. -o 'option' Process the option as if it was read from a configuratio +n file. -s Invoke command (mandatory) as SSH2 subsystem. -b addr Local IP address. login failed: filehandle isn't open at /opt/apache/htdocs/enrc/cgi-bin +/metro_cm_tool.pl line 130
The PHP code:
<?php exec("/usr/bin/perl522/bin/perl /opt/apache/htdocs/enrc/cgi-bin/metro_ +cm_tool.pl"); ?>
I cant figure out what PHP is doing differently than when I run the script from the command line directly.
In reply to Execute a perl script from PHP? by jtzako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |