LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-18-2010, 05:04 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 676
Blog Entries: 2

Rep: Reputation: 36
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.
 
Old 03-18-2010, 05:43 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023
Have you looked here http://www.php.net/manual/en/. There's examples of how to use all the cmds in php.
 
Old 03-18-2010, 09:32 AM   #3
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado
Distribution: Slackware
Posts: 421

Rep: Reputation: 58
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?
 
Old 03-18-2010, 11:18 PM   #4
pinga123
Member
 
Registered: Sep 2009
Posts: 676
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by Chuck56 View Post
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 ?
 
Old 03-18-2010, 11:46 PM   #5
pinga123
Member
 
Registered: Sep 2009
Posts: 676
Blog Entries: 2

Original Poster
Rep: Reputation: 36
I think i need to give bash script execution permission to apache? correct me if i m wrong.
 
Old 03-19-2010, 01:28 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023
You need to

su - apache

and create a key for that user and txfr it.
 
Old 03-22-2010, 10:34 PM   #7
pinga123
Member
 
Registered: Sep 2009
Posts: 676
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Thank you very much my problem is solved by creating key and transferring it using apache login.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php integration with access database on linux server dianarani Linux - General 1 05-22-2008 08:38 AM
PHP and Pay pal integration malan_in Programming 1 10-19-2007 04:28 PM
LXer: Continuous integration with PHP LXer Syndicated Linux News 0 03-12-2007 06:46 PM
php curl integration problem tstName Linux - Software 0 06-27-2006 02:05 AM
PHP + MySQL Integration issue digitalgravy Linux - Software 1 01-15-2004 10:07 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration