LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-28-2012, 09:48 AM   #1
Marvin_G
LQ Newbie
 
Registered: Dec 2012
Posts: 14

Rep: Reputation: Disabled
PHP + terminal


can i use php to execute command in terminal?
 
Old 12-28-2012, 10:30 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Yes. Try
Code:
man php
it has lots of examples. A simple one is:

Code:
php -r 'echo "hi\n";'
You may also have been referring to the system() PHP function:

PHP Code:
<?php
//Code from the link I posted above:
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;
?>

Regards,

Last edited by Snark1994; 12-28-2012 at 10:32 AM. Reason: Added information about system()
 
Old 12-28-2012, 11:36 AM   #3
Marvin_G
LQ Newbie
 
Registered: Dec 2012
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Snark1994 View Post
Yes. Try
Code:
man php
it has lots of examples. A simple one is:

Code:
php -r 'echo "hi\n";'
You may also have been referring to the system() PHP function:

PHP Code:
<?php
//Code from the link I posted above:
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;
?>

Regards,
will try this. thanks alot. anything i will update here.
 
Old 12-28-2012, 12:37 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
php -f /path/to/file.php
 
  


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
Linux terminal to php ruchirarsm Linux - Newbie 2 08-27-2012 10:31 PM
embed terminal in html-php webpage maradnus Programming 2 12-07-2011 11:28 AM
Run php scripts in terminal gpm1982 Programming 3 04-30-2008 03:20 AM
can i run .php trom terminal samnjugu Linux - Software 6 04-20-2006 07:54 AM
Running a terminal/prompt from PHP james_cwy Linux - Newbie 1 12-15-2003 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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