Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms, arguments, etc

Status
Not open for further replies.

segment

ISP
Jun 15, 2004
225
US
Hey all, I'm looking to make a quick (good looks not necessary) form which will take my argument and parse it out of a logfile, then print it back to the page I entered the command on...

Think of grep 20060925 /var/log/messages where in a little form I can enter the date. However, boolean grep would be nice too... E.g. grep 2006* /var/log/messages. Just unsure how to get my argument parsed into a page correctly... Any help?

<?php
echo '<pre>';

$found = system('grep $ARG /var/log/messages', $retval);

echo '
</pre>
<hr />Found: ' . $found . '
<hr />Return value: ' . $retval;
?>



perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
This line:

$found = system('grep $ARG /var/log/messages', $retval);

Probably won't work because it uses single quotes and inside single quotes variables are not interpolated (link).

Either use doublequotes or concatenate the string together.


You may also run into problems with the variable $ARG depending on from where its value comes.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Most likely, you need $_POST['ARG'] instead of $ARG. You'd replace 'ARG' with your field name.

Code:
<?php
echo '<pre>';

$found = system("grep $POST['ARG'] /var/log/messages", $retval);

echo '
</pre>
<hr />Found: ' . $found . '
<hr />Return value: ' . $retval;
?>

<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" method="post">

Text: <input type="text" name="ARG">

</form>

You can learn more about forms at
 
Yes, please do look at the htmlgoodies page... I left off the submit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top