s3kk3y
Mar 20 2004, 03:58 PM
I am trying to execute a cmd on a remote server from my server but cannot find a way to get it to work. What I have so far is:
$output = exec("ssh -l root -2 -i /root/.ssh/id_dsa 11.11.11.11 "ls /home/folder"");
echo $output;
?>
If I run ssh -l root -2 -i /root/.ssh/id_dsa 11.11.11.11 "ls /home/folder" from shell it works fine but I need a way to run it from a php page.
Would anyone know what I am doing wrong?
Thanks in advance.
smack
Mar 20 2004, 07:24 PM
Well first of all, exec only returns the last line of output.
Instead try shell_exec , and then add 2>&1 if you want to see error output as well....soo...
$output = shell_exec('ssh -l root -2 -i /root/.ssh/id_dsa 11.11.11.11 "ls /home/folder" 2>&1');
echo $output;
newuser
Mar 20 2004, 07:44 PM
try
exec("commands here",$resultArray);
print_r($resultArray);
s3kk3y
Mar 22 2004, 12:22 AM
Thanks for the suggestions but now I think the problem is that the script is not even connecting to the remote server.
I tried both the suggestions as well as passthru() but I am pretty sure that it is not connecting the remote server to run the cmds.
Am I overlooking something here that would not allow the script to connect?
Off topic, is anyone else not receiving forum post notice emails?
Thanks as always!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.