Linux and Php integration help .

I m devoloping a website which communicate with Linux server .
Whenever a page is loaded it runs one script on Linux server.

My problem is a simple commands like date , ls runs very smoothly. But whenever i execute big script.It wont display the output.

My knowledge of PHP is very less i m using simple echo command to run the script and display the output.

My php file:
Working Program:
<html>
<head><title>This is my page</title></head>
<body>
This is the content of my page.
<?php
print "Do you like it?";
?>
<?php
echo `date`;
?>
</body></html>
Output:
This is the content of my page. Do you like it?Thu Mar 18 15:02:36 IST 2010
When i modify my php file as

<html>
<head><title>This is my page</title></head>

<body>
This is the content of my page.
<?php
print "Do you like it?";
?>
<?php
echo `ssh -ttq 10.180.8.231 ls -ltr`;
?>
</body>
</html>

Output:This is the content of my page. Do you like it?
However the command ssh -ttq 10.180.8.231 ls -ltr get executed properly on linux machine.

Please help.
 
echo or print will output whatever you type in between quotes. GIGO ;)

What you need to do is, you need to use any of the process execution methods to run your ssh command and redirect the output into a string. Then you can echo/print the string to see the output.

Refer - PHP: Program execution Functions - Manual

Before this, I would suggest you to go through the basics of php from any of the books/online tutorials. One of the best source is php manual (though not very well structured for beginners).
 
Back
Top