LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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: 684
Blog Entries: 2

Rep: Reputation: 37
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
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: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
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: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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: 684

Original Poster
Blog Entries: 2

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration