note 50208 added to function.shell-exec
| From: | (at_heath0tmaildotcom) | Date: | Mon, 21 Feb 2005 23:30:57 +0000 |
| Subject: | note 50208 added to function.shell-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85339@lists.php.net to get a copy of this message | ||
hi.. i am just learning php since a few days.. i had mount a website in my own pc and want let
users to post messages..
anyway, i wrote a very tiny page that let you run some commands remotely, that is useful mostly as
example of ereg_replace and shell_exec :D
<!-----run.php-----
<pre>
<?php
$salida=ereg_replace("<","<",shell_exec($_POST["comando"]));
echo "comando:
",$_POST["comando"],"<br>",$salida,"<br>";
?>
<form action="run.php" method="post">
comando: <input type="text" name="comando">
</form>
</pre>
-----eof----->
the ereg_replace is only for replace the "<" character at the output for his code,
which html reads as a tag..
- first tou must write something in the form..
- when page is opened again it takes it, replaces "<" characters and puts in $salida
variable (it may be useful later)..
- then prints out and you can write something again :)
.. i haven't change the ">" and other characters.. (see ereg_replace posts)
one inconvinient is that you can't change drive/dir.. i was thinking running some like this
before
echo $lastpath;
shell_exec($lastdrv);shell_exec("cd "+$lastpath);
then run our command.. but i dont know if exiting shell_exec restores the home dir again.. next we
must update our path again (if somebody wrotes "cd" command for example), and get $lastdrv
with some filter:
$lastpath=shell_exec("cd");
(anyway, $lastdrive will be the first 2 characters of $lastpath :P )
that's all 4now
greetings ;)
----
Manual Page -- http://www.php.net/manual/en/function.shell-exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50208
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50208&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50208&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50208&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50208&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50208&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50208&report=yes
Search -- http://master.php.net/manage/user-notes.php