Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w =head1 NAME ftp-watch.pl - Simple reporting for updates on remote FTP server. =head1 DESCRIPTION When run first time, this script generates a file with recursive listi +ng of some directory on remote FTP server. Any other script execution wi +ll cause it to report differences in directory listing using GNU diff for +mat. =cut use Text::Diff; use Net::FTP::Recursive; use strict; # # Settings # my $host = 'ftp.linux.dom'; # Server my $user = 'anonymous'; # Username my $pass = 'me@here.com'; # Password my $dir = '/pub/people/leonid/'; # Top directory to monitor my $listing_file = '/tmp/ftp.real'; # Keep listing in this file my $listing_temp = '/tmp/ftp.temp'; # Temporary file # Get FTP listing open (OUT, ">$listing_temp") or die "Couldn't open $listing_temp ($@)" +; my $ftp = new Net::FTP::Recursive($host) or die "Couldn't connect ($@) +";; $ftp->login($user,$pass) or die "Couldn't login ($@)"; $ftp->cwd($dir) or die "Couldn't change directory ($@)"; $ftp->rls(Filehandle=>*OUT); $ftp->quit(); close (OUT); # Create empty data file if does not exist if (! -e $listing_file) { warn "No local listing...creating empty"; open (OUT, ">$listing_file") or die "Couldn't open $listing_file($ +@)"; close (OUT); } # Compare open (IN1, "<$listing_file") or die "Couldn't open $listing_file ($@)" +; open (IN2, "<$listing_temp") or die "Couldn't open $listing_temp ($@)" +; my $diff = diff \*IN1, \*IN2; close (IN2); close (IN1); # Clean-up rename ($listing_temp, $listing_file) or warn "Couldn't update info ($ +@)"; # Output results print $diff,"\n"; =head1 AUTHOR Leonid Mamtchenkov <leonid@leonid.maks.net> =cut

In reply to ftp-watch.pl by TVSET

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found