Jump to content

How to execute linux commands through a php program?


lalitmishra

Recommended Posts

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.

 

It depends on what Linux you are on however FC you can kick out of php to run Linux command with

 

system("cd /home/whereEver;nohup ./myscipt --commands > /dev/null & echo $!;";

 

the "> /dev/null & echo $!" changes from versions of Linux however it is needed to stop hanging of a command if you are not looking for as reply.

 

You could also use shell_exec("whatever ");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.