0

Hi

I am trying to print out the output from linux command in php. from the command line i am able to view the output, but when i run it from a browser there is no out put. anyone who can assist?

$ex1="ssh myname@server tail -10 /mnt/data/stat/status-rx.log";
$output1=`$ex1`;
echo "<pre>$output1</pre>";

any help will be appreciated.

4
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by omol
0

What happens if you try something simpler like:

$output = `ls`;
echo "<pre>$output</pre>";

Still no output ? Is safe-mode enabled, or shell_exec disabled ?

0

when i try that its able to output the result of the command. but when trying to ssh i dont get any output.

0

The problem is not in the function, but in the output of ssh, so using exec() would not fix the problem.

0

after rerouting the output from stderr i get this message

Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).

0

that's a problem from ssh. Apparantly you're not allowed to connect. Remember that if run it from the commandline, then you're using it with your user rights. If you use it through php, then different rights apply. Am not familiar enough to provide a solution for this.

Edited by pritaeas: n/a

0

so what do u suggest i do, i give the user httpd rights?

0

I think it is the other way around, that you should give the httpd rights to ssh. But as I said, am not too familiar with this. I think you can better ask this in the linux forum.

0

The best / safest way is to use the suphp mod.

I won't go into details of why its a bad idea to lower the user permissions for ssh or raise the user permissions of your web server.

http://www.suphp.org/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.