Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.