Help - Search - Members - Calendar
Full Version: php help
The Planet Forums > System Administration > General Support Questions
s3kk3y
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
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
try

exec("commands here",$resultArray);

print_r($resultArray);
s3kk3y
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.
Invision Power Board © 2001-2010 Invision Power Services, Inc.