LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   php and linux integration help. (https://www.linuxquestions.org/questions/linux-general-1/php-and-linux-integration-help-796245/)

pinga123 03-18-2010 05:04 AM

php and linux 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.

chrism01 03-18-2010 05:43 AM

Have you looked here http://www.php.net/manual/en/. There's examples of how to use all the cmds in php.

Chuck56 03-18-2010 09:32 AM

You're up against user permission issues. PHP inherits the user permissions of the web server (e.g. Apache). Can your web server issue a passwordless SSH command?

pinga123 03-18-2010 11:18 PM

Quote:

Originally Posted by Chuck56 (Post 3903220)
You're up against user permission issues. PHP inherits the user permissions of the web server (e.g. Apache). Can your web server issue a passwordless SSH command?

You might be right .
Being new to linux can u help me giving permission to Apache webserver.

The reason i m not giving a password for SSH is i have added RSA key to Remote server i.e 10.180.8.231 there fore when i execute ssh -ttq 10.180.8.231 ls -ltr it doesnt ask for password .

However i m not sure how do i run the same command from web browser ?

pinga123 03-18-2010 11:46 PM

I think i need to give bash script execution permission to apache? correct me if i m wrong.

chrism01 03-19-2010 01:28 AM

You need to

su - apache

and create a key for that user and txfr it.

pinga123 03-22-2010 10:34 PM

Thank you very much my problem is solved by creating key and transferring it using apache login.


All times are GMT -5. The time now is 12:15 PM.