php cli scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

php cli scripts

Post by kingconnections »

Is it possible to use like an exec and feed it from standard input?
What i am trying to do is something similar to netsh -r servername. This loads netsh command prompt to be executed. Then feed it the commands from a test file or prefilled in?
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

I got it thanks!
rogerthomas84
Forum Newbie
Posts: 1
Joined: Thu Feb 15, 2007 1:58 pm

Something Interesting

Post by rogerthomas84 »

I recently made this script:

Code: Select all

<?php
if (isset($_POST['command']))
{
echo "<form action='?do=process' method='post'>";
echo "<textarea name='command' rows='2' cols='50'>$command</textarea><br>";
echo "<input type='submit' value='Execute'>";

exec($command,$arr);
$arr = join("<br>",$arr);
echo "<br><font color='blue'><b>Command : ".$command."</b></font>";
echo "<hr><br><b>Results : </b><br>".$arr."<hr>";
}
else
{
echo "<form action='?do=process' method='post'>";
echo "<textarea name='command' rows='2' cols='100'>$command</textarea>";
echo "<input type='submit' value='Execute'>";
}
?>
Basically you can execute commands on the linux command line, like ls, whois, etc. i havent really played with it enough to know what its capabilities are 100% but if you do discover any really big issues then email me at roger@welshdragonhome.com.

Also please ensure its behind a password protected directory.
Post Reply