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
https://forums.phpfreaks.com/topic/248890-running-shell-commands/
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

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.

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.