Page 1 of 1

How to execute linux commands through a php program?

Posted: Sat Jun 07, 2008 12:40 am
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.

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

Posted: Sat Jun 07, 2008 2:24 am
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.

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

Posted: Sat Jun 07, 2008 7:59 am
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