Jump to content

how to execute shell script vai php


websoftexpert

Recommended Posts

Do I have an example? The link I gave you has plenty of examples, and explains what arguments the function accepts as well as what it returns.

 

Your post above uses the system function, which can also execute external programs.

 

Read the manual, it is the definitive guide.

  • 2 months later...

Hi

 

Do you have any example?

 

Please see below.

 

<?php system("your.sh"); ?>

 

Am I right?

 

Thanks

 

 

Here's a basic example, using the shell_exec() function mentioned.

For the purpose of keeping it simple I've used a basic command to check the version of rails installed on a server.

 

<?php
$shell = "rails -v";
$cmd = shell_exec($shell);

echo $shell.'
<br>'.$cmd;
?>

This will output:

 

rails -v

Rails 3.2.1 (whatever version you have...)

 

I'm not sure what the restrictions are to running shells on this function, if any. Refer to the php.net example as mentioned by thorpe.

 

I have successfully created a shell interface that acts similar to your basic shell client. I can create files and edit files...(no pico/gedit capabilities yet)

I can run dir, cat, and most other basic linux commands, haven't run into any commands that I cannot use yet.

 

This is a very basic example. php.net is the place to go for more detail.

http://php.net/shell_exec

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.