#!/usr/bin/perl -w #====================================================================== # Author: Adam Bultman # Date: 27 October 2000 # Usage: This program runs a windows command (ipconfig), and pipes the output # to a file. Once that is finished, it uploads the file to an ftp # server. It then sleeps for 30 minutes, or a set time limit. Then it # starts all over until interrupted. Swell! #========================================================================== # Use the FTP module for Perl use Net::FTP; # Set some variables $time = 800; # Sleep for this many seconds $server = "server"; # Upload to this server $fileName = "file"; # Pipe to this file $userName = "userName"; # Set the user name... $password = "password"; # Terrible, but this is the password $cmd = "ipconfig |"; # Let's name the command #Let's assign an ftp connection... # Print out what the program does print "\nThis program will run \"ipconfig\" every $time seconds, pipe\n"; print "It to $fileName, and then upload the file to $server .\n"; for(;;) { # Open up the file and the command handle open (FILE, ">$fileName") || die "\nI couldn't open the file for overwriting. "; open (COMMAND, $cmd) || die "\nI couldn't run the program! "; # Try to print the results of the command to the file write_to_file; # Just for tying off loose ends close COMMAND || die " I couldn't close COMMAND "; close FILE || die " I couldn't close FILE"; $ftp = Net::FTP->new($server) || die "I couldn't open a connection to $server "; # Log onto the server and put the file, then quit. $ftp->login($userName,$password); print "Logged in... "; $ftp->cwd('public_html'); print "Changed dir to public_html... "; $ftp->put($fileName); print "I put the file... "; $ftp->quit(); print "Logging out...\n"; print "I put the file $fileName to $server successfully.\n"; # Sleep the alloted time. $| = 1; sleep($time); } sub html_header { $document_title = $_[0]; print FILE ""; print FILE ""; print FILE "$document_title"; print FILE ""; print FILE ""; print FILE "

$document_title

"; print FILE "
";



}











sub write_to_file
  {
 html_header("MY IP ADDRESS");



	print FILE ;

	print FILE "
"; print FILE "
"; print FILE ""; print FILE ""; }