Jump to content

My first question (php + unix)


mracine

Recommended Posts

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

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.

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.

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.