LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2007, 07:54 AM   #1
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Rep: Reputation: 31
Very basic PHP


Hi,

I'm interested in making a very basic PHP script for a Linux server. It should only do this:
1. execute some command-line program (which normally prints some text to the screen)
2. Write this text to the web page instead.

This is for monitoring a cluster, and I'd like to be able to view the cluster status using a web browser instead of logging in by SSH or something.

Many thanks,
 
Old 06-14-2007, 08:05 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

Something like:

PHP Code:
<?php
header
("Content-Type: text/plain");
system("ls");
?>
Of course, change the "ls" into a more useful command.

Last edited by Guttorm; 06-14-2007 at 08:06 AM.
 
Old 06-14-2007, 09:32 AM   #4
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Ahh thank you, this is exactly what I was looking for. This works with commands like 'ls' and 'ps', but it does not print any output from the program I'd like to use. In this case the return value from system() is 1. Is this a permissions issue? I've tried chmod 777 on the program but this does not seem to make a difference.
 
Old 06-14-2007, 09:43 AM   #5
senyahnoj
Member
 
Registered: Jul 2004
Location: Gloucestershire, UK
Distribution: Ubuntu, Debian & Gentoo
Posts: 74

Rep: Reputation: 16
What program are you trying to use?
 
Old 06-14-2007, 09:46 AM   #6
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by senyahnoj
What program are you trying to use?
It's called condor_status from the Condor project (http://www.cs.wisc.edu/condor/). I'm not sure if this is relevant though? I can run the program as a normal unpriveledged user and it works, and I can also redirect the text output to a file (using the > operator) but this does not seem to work either when I try with PHP.
 
Old 06-14-2007, 09:52 AM   #7
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
I have a workaround....If I write a script which does nothing except run condor_status, and use PHP to execute the script, it works. I can't explain why. But I'll be happy with that.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding users with PHP (pass php variables to Expect script) Jayla Programming 1 10-20-2006 10:44 AM
Problem with basic PHP MIME mail tooparam Linux - Newbie 1 02-09-2006 10:11 AM
Basic PHP HELP! Alexander.s Programming 2 04-22-2005 12:31 PM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:23 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