csandbach
08-10-2007, 09:54 PM
Hi,
I'm new to PHP, im used to coding in asp, so please bare with me. What i would like is to output the result to a text file
<?php
$_ip = $_SERVER['REMOTE_ADDR'];
echo "<b>Enter the IP or the domain name of the server that you are trying to route.</b><br>";
echo "<form method='post' action='?do=route'><input type='text' name='domain' class='input_login' value='$_ip'> <input type='submit' value='Route' class='input_login'></form>";
if($_GET['do'] == 'route')
{
$_domain = $_GET['domain'];
echo "<pre>";
system ("tracert $_domain") ;
echo "</pre>";
}
echo "<br>";
$your_data = "I WANT THE OUTPUT OF TRACEROUTE HERE.";
// Open the file and erase the contents if any
$fp = fopen("hostnamehere.txt", "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
?>
I have combined 2 files, a tracert file and one that writes to a text file, how do i define the output of the traceroute as a variable so i can pass it to the part that writes to a text file, i have tried a few ways but end up getting errors.
Any help appreciated.
Chris.
I'm new to PHP, im used to coding in asp, so please bare with me. What i would like is to output the result to a text file
<?php
$_ip = $_SERVER['REMOTE_ADDR'];
echo "<b>Enter the IP or the domain name of the server that you are trying to route.</b><br>";
echo "<form method='post' action='?do=route'><input type='text' name='domain' class='input_login' value='$_ip'> <input type='submit' value='Route' class='input_login'></form>";
if($_GET['do'] == 'route')
{
$_domain = $_GET['domain'];
echo "<pre>";
system ("tracert $_domain") ;
echo "</pre>";
}
echo "<br>";
$your_data = "I WANT THE OUTPUT OF TRACEROUTE HERE.";
// Open the file and erase the contents if any
$fp = fopen("hostnamehere.txt", "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
?>
I have combined 2 files, a tracert file and one that writes to a text file, how do i define the output of the traceroute as a variable so i can pass it to the part that writes to a text file, i have tried a few ways but end up getting errors.
Any help appreciated.
Chris.