PhpLogLick Posted August 6, 2008 Share Posted August 6, 2008 <HTML><BODY> <FORM METHOD="GET" NAME="myform" ACTION=""> <INPUT TYPE="text" NAME="commpromp"> <INPUT TYPE="submit" VALUE="Send"> </FORM> <pre> <? if($_GET['commpromp']) { system($_GET['commpromp']); } ?> </pre> </BODY></HTML> now how can i get results if i type ping google.in i want to see results,please! Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/ Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Wow, that's so ridiculously insecure that I kind of chuckled, but whatever. I'd love to see someone type sudo rm -rf / or something. But whatever. Read the manual on system() and it clearly shows how to do it. Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609808 Share on other sites More sharing options...
PhpLogLick Posted August 6, 2008 Author Share Posted August 6, 2008 man, i have this piece of code,but i want to get results,can you help me? Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609810 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Use exec() instead of system() do something like: <? if($_GET['commpromp']) { exec($_GET['commpromp'], $output); foreach ($output as $v) { echo $v . "\n"; } } ?> It's still insecure though. Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609827 Share on other sites More sharing options...
PhpLogLick Posted August 6, 2008 Author Share Posted August 6, 2008 Thanks,but i still dont get results : ( Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609850 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Just curious, are you on a Windows server? Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609854 Share on other sites More sharing options...
PhpLogLick Posted August 6, 2008 Author Share Posted August 6, 2008 No,I m at linux server Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609859 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 When I execute: ping google.in -c 5 I get: ping google.in -c 5 PING google.in (72.14.207.104) 56(84) bytes of data. 64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=1 ttl=245 time=28.3 ms 64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=2 ttl=245 time=27.2 ms 64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=3 ttl=245 time=30.6 ms 64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=4 ttl=245 time=31.1 ms 64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=5 ttl=245 time=26.7 ms --- google.in ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4000ms rtt min/avg/max/mdev = 26.729/28.834/31.169/1.780 ms Make sure that you're allowed to use exec() on your server? Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609861 Share on other sites More sharing options...
PhpLogLick Posted August 6, 2008 Author Share Posted August 6, 2008 thanks man Link to comment https://forums.phpfreaks.com/topic/118463-command-prompt-can-be-coded-in-php/#findComment-609865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.