Jump to content

Running shell commands


jhsachs

Recommended Posts

I'm experimenting with the shell_exec function to gain shell capability on a Linux host that doesn't provide it otherwise. I've found that I can see what is in different directories by entering a command line like:

 

cd ..; ls

 

but if I enter two consecutive command lines:

 

cd ..
ls

 

The cd command has no effect. Apparently shell_exec is using a new shell every time I call it.

 

Is there a way to start a shell in a PHP script and keep it active while I pass it multiple commands, so that this won't happen?

Link to comment
Share on other sites

The list of files will be the same (in this particular example), except it won't move you into the directory... still, since it's a simple php script that's always running from the same directory, always including the path to execute the commands could help.

 

Anyway, a simple google search for 'php shell terminal' returned this: http://sourceforge.net/projects/phpterm/.

 

hope this helps

Link to comment
Share on other sites

The SourceForge listing looks promising. I'll look into it.

 

How would the Ajax solution work? I thought Ajax just provided a channel for the client to communicate with a server script between page loads. The script to do anything that it couldn't do without Ajax in the picture.

Link to comment
Share on other sites

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.