mracine Posted April 8, 2007 Share Posted April 8, 2007 First I'll say hi (this is my first post ). I need help with my php. I don't have much experince with it but I need a web interface for my server. I have a script on the server called "speed.pl". I run the script by typing "./speed.pl 192.168.1.100 5". The first part is the script name, the second is the host ip address, and the last one being how many test to do. So I created a web page in html that has a checkbox (to run the script) and two text box for the host ip and number attempt. So then I added the php script. As a result nothing shows up on the web page. I figure something must be wrong with it. If you could take a look and see what I might be doing wrong, I'll be very thankful. Have a great Easter. BTW, I was having a debate with a friend. Is the script suppose to go on top or bottom? <?php $version = "2.0"; // This version /* Set the default settings. */ $message = ""; // Message to be displayed when form is posted. $ping_host = "192.168.1.100"; // Target IP. $ping_number = "5"; // Test number /* Grab and parse POST variables. */ if (count($_POST) != 0) { if ($_POST['ping_host']) { $ping_host = $_POST['ping_host']; } else { $message .= "No IP secified, using default.<br>"; } $ping_host = $_POST['ping_host']; if ($_POST['ping_number']) { $ping_number = $_POST['ping_number']; } else { $message .= "No number secified, using default.<br>"; } $ping_number = $_POST['ping_number']; /* Parse command line. */ if (count($_POST) != 0 && $_POST['Submit']) { echo str_repeat(" ", 512); if ($ping_on) {$commandline = "$ping_host $ping_number";} echo "command line \"./speed.pl $commandline"."\"<br>"; flush(); echo "<textarea name=\"textfield\" cols=\"80\" rows=\"20\" wrap=\"VIRTUAL\">\n"; system("nohup speed.pl $commandline &"); echo "</textarea>\n"; flush(); } ?> <html> <head> <title>NetTech Inc</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#000000"> <form action="ping.php" method="post"> <table cellspacing="1" cellpadding="4" bgcolor="#CCDDCC"> <tr> <td> </td> <td width="10"> </td> <td align="left" valign="middle"> <input type="checkbox" name="ping_on" value="1" > Ping Test --></td> <td align="left" valign="middle"> Host: </td> <td align="left" valign="middle"> <input type="text" name="ping_host" value=""> </td> <td align="left" valign="middle"> Number of ping attempts: </td> <td align="left" valign="middle"> <input type="text" name="ping_number" value=""> </td> </tr> </table> <input type="submit" name="Submit" value="Scan"> <a href="ping.php">Reset</a> </td> <td width="20"> </td> </tr> </table> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/46166-my-first-question-php-unix/ Share on other sites More sharing options...
Zaid Posted April 8, 2007 Share Posted April 8, 2007 not really sure what it does, i had a quick look, and your HTML form goes to ping.php, do you have such file? i think it should redirect to the same filename i.e. speed.pl (btw .pl extension is not for php, it's for perl i think), it would still work if your server is configured correctly. Link to comment https://forums.phpfreaks.com/topic/46166-my-first-question-php-unix/#findComment-224406 Share on other sites More sharing options...
mracine Posted April 8, 2007 Author Share Posted April 8, 2007 ping.php is the name of this php. I only have it on the html section as a reset to the web page. In theory, I should refesh the page and put the default options back. My friend was the one who wrote the speed.pl. It works on the server. I just want a web page that ran the script on the server. I want the webpage to send to the server "./speed.pl 192.168.1.100 5" without logging onto it. Link to comment https://forums.phpfreaks.com/topic/46166-my-first-question-php-unix/#findComment-224421 Share on other sites More sharing options...
mracine Posted April 8, 2007 Author Share Posted April 8, 2007 mybe I should rephrase my question. How do you send unix a command like you would when your log into the server. I want web php to send "./speed.pl 192.168.1.100 5" to the server. The server would then run the script. Link to comment https://forums.phpfreaks.com/topic/46166-my-first-question-php-unix/#findComment-224479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.