How to execute linux commands through a php program?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lalitmishra
Forum Newbie
Posts: 5
Joined: Sat Jun 07, 2008 12:39 am

How to execute linux commands through a php program?

Post by lalitmishra »

How to execute linux commands through a php program? :-

1- I am taking a 'C' program as input in PHP program. I want execute it directly through PHP means linux commands 'gcc' should be executed directly through our php program and out put should be displayed on our php page.

2- Execution of linux Commands like VMSTAT in our php program. How to execute it through php program.


Please reply soon.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to execute linux commands through a php program?

Post by John Cartwright »

//step in Evil mod

Why on Earth did you think it's ok to post this thread in 6 seperate forums. Unfortunately, your first and final warning :evil:

Moved to PHP-Code.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to execute linux commands through a php program?

Post by VladSun »

Code: Select all

$output = `/path/cmd args`;
// or
$output = system('/path/cmd args');
// or
exec('/path/cmd args', $output);
// or
passthru('/path/cmd args');
Also, take a look at escapeshellcmd
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply