LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 03-01-2006, 09:35 PM   #1
ckoniecny
Member
 
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:
<?php
     
echo "<HTML>";
     echo 
"<TITLE>";
     echo 
"<BODY>";
     echo `
uname -a`;         <=== How do you execute this?
     echo 
"</TITLE>";
     echo 
"</BODY>";
     echo 
"</HTML>";
?>
 
Old 03-01-2006, 09:44 PM   #2
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Original Poster
Rep: Reputation: 30
Nevermind, I figured it out.
 
Old 03-01-2006, 10:20 PM   #3
sipsipi
Member
 
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
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

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

http://us3.php.net/manual/en/function.system.php

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:
<?php
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 '
</pre>
<hr />Last line of the output: ' 
$last_line '
<hr />Return value: ' 
$retval;
?>

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.
 
  


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 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 07:58 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration