Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-01-2006, 09:35 PM   #1
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
Executing UNIX command from PHP script

How can I execute a UNIX command from a PHP script?

Is there someway of doing the following:

PHP Code:
echo "<HTML>";
     echo `
uname -a`;         <=== How do you execute this?
Old 03-01-2006, 09:44 PM   #2
Registered: Oct 2005
Posts: 162

Original Poster
Rep: Reputation: 30
Nevermind, I figured it out.
Old 03-01-2006, 10:20 PM   #3
Registered: Dec 2005
Location: Chicago
Distribution: Fedora and Redhat
Posts: 86

Rep: Reputation: 15
Well, whatdja do?
Old 03-01-2006, 11:42 PM   #4
Registered: Oct 2005
Posts: 162

Original Poster
Rep: Reputation: 30
This is what I am using.

But I do have another question, how can I set the PATH for commands?

For example,

If I run "php -f test.php"

PHP Code:
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line system('ls'$retval);

// Printing additional info
echo '
<hr />Last line of the output: ' 
$last_line '
<hr />Return value: ' 

the result is:
sh: /usr/local/php/bin/ls: No such file or directory

Last edited by ckoniecny; 03-01-2006 at 11:45 PM.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 01:21 PM
PHP executing System command abdul_zu Linux - General 4 12-28-2005 03:14 PM
Problem executing a linux script from php that runs ffmpeg darkisolde Linux - Software 4 10-04-2005 08:43 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 01:33 AM
Executing PHP script- error message vfulco Linux - Newbie 3 07-13-2004 11:55 PM

All times are GMT -5. The time now is 08:57 AM.

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