Re: Remote directory <-> local directory comparison


Subject: Re: Remote directory <-> local directory comparison
From: Brian ThunderEagle (furbs@mail.swjedi.net)
Date: Wed Dec 18 2002 - 02:31:55 AKST


Another thing you could do with Perl, but more complicated is you parse the
list of files into another file. The format of the file would be FTP commands.
For example, and file list of:

myfile1.doc
myfile2.dat
myfile3.err

would be exported to a file like this:

user <your_user> <your_pass>
dir myfile1.doc
dir myfile2.dat
dir myfile3.err
quit

You would run the FTP program so that it would use that file for input, and
export what happens as well:

ftp -v -i -n ftp.your_site.com <exported_file >log_file

Now have your Perl program parse the log file by using the transfer codes. Here
is what the "log_file" would be like.

Connected to ftp.aidea.org (24.237.7.175).
220 newguy.aidea.org FTP server ready.
331 Password required for limevillage.
230 User limevillage logged in.
227 Entering Passive Mode (24,237,7,175,11,214).
150 Opening ASCII mode data connection for file list
-rw-rw-r-- 1 limevillage limevillage 0 Dec 18 22:46 myfile1.doc
226 Transfer complete.
227 Entering Passive Mode (24,237,7,175,11,215).
150 Opening ASCII mode data connection for file list
-rw-rw-r-- 1 limevillage limevillage 0 Dec 18 22:46 myfile2.dat
226 Transfer complete.
227 Entering Passive Mode (24,237,7,175,11,216).
150 Opening ASCII mode data connection for file list
-rw-rw-r-- 1 limevillage limevillage 0 Dec 18 22:46 myfile3.err
226 Transfer complete.
221 Goodbye.

For every instance of 150, check if a file is listed. If 226 is on the next
line, then the file doesn't exist.

Hope this helps, and wasn't confusing at all.

     Brian ThunderEagle
      - http://www.swjedi.net
      - furbs@swjedi.net
      - bthundereagle@aidea.org

Quoting Brian ThunderEagle <furbs@mail.swjedi.net>:

> This code will return the size of a file, but it has limitations. It
> would
> require some more testing than I have done to be sure of it's capabilities.
>
> There are 2 examples that work, one using and html file and one using a jpg
>
> file. I know that this code doesn't work for returning php file sizes.
>
>
> #!/usr/bin/perl
> use LWP::Simple;
> my @heads = head 'http://www.swjedi.net/index.html';
> print "$heads[1] bytes\n";
>
> use LWP::Simple;
> my @heads = head 'http://www.swjedi.net/_themes/neon/neobkgnd.jpg';
> print "$heads[1] bytes\n";
>
>
>
> Brian ThunderEagle
> - http://www.swjedi.net
> - furbs@swjedi.net
> - bthundereagle@aidea.org
>
>
>
>
>
> Quoting Brian ThunderEagle <furbs@mail.swjedi.net>:
>
> > PERL:
> >
> > #!/usr/bin/perl
> > $file="/var/log/messages";
> > $size=(stat("".$file.""))[7];
> > print "size of ".$file." is ".$size." bytes\n";
> >
> > or directly on the command line
> >
> > perl -e '$file="/var/log/messages"; $size=(stat("".$file.""))[7]; print
> "size
> >
> > of ".$file." is $size bytes\n"'
> >
> > This will get you the size of a file directly on the system. Getting the
> size
> >
> > of the file on a remote though I am not sure. I will have to look into
> > that.
> >
> >
> > Brian ThunderEagle
> > - http://www.swjedi.net
> > - furbs@swjedi.net
> > - bthundereagle@aidea.org
> >
> >
> >
> >
> >
> > Quoting Tim Johnson <tim@johnsons-web.com>:
> >
> > >
> > > * Arthur Corliss <arthur@corlissfamily.org> [021218 10:07]:
> > > > On Tue, 17 Dec 2002, Tim Johnson wrote:
> > > >
> > > > >
> > > > > Howdy:
> > > > > Here's one for you perl programmers.
> > > > >
> > > > > Given a list of files: I'd like to
> > > > > 1)Confirm that a copy of any file in the list exists
> > > > > both on a remote directory and on my local machine.
> > > > > 2)Compare both copies to see if they are of the same size.
> > > > > 3)Possible (but not necessarily) run 'diff' against them
> > > > >
> > > > > I program in rebol and python - (and can understand perl
> > > > > enough to get me in trouble) I don't believe rebol can
> > > > > do this reliably at all, and I'm not sure that python
> > > > > can either, but will post those MLs too.
> > > >
> > > > You don't say what protocol you're using to access the remote
> machine.
> > >
> > > Howdy Arthur:
> > >
> > > FTP or http. Whatever gets the results. However, I've already
> > > found my error in rebol code. So I'm now getting what I need
> > > from rebol.
> > >
> > > In rebol, I used FTP. BTW: I've been told in the Python
> > > mailing list that getting file sizes via FTP w/python is
> > > unreliable. I do believe that both perl and rebol do
> > > it fine... I just needed some tips.
> > > - thanks Arthur -
> > >
> > > rebol example below:
> > > >> probe info?
> > >
> >
> ftp://login_here:password_here@www.johnsons-web.com/cgi-bin/wmj/WmjSearch.r
> > > connecting to: www.johnsons-web.com
> > >
> > > make object! [
> > > size: 38546
> > > date: 17-Dec-2002/22:29
> > > type: 'file
> > > ]
> > >
> > > Or capture the object and reference the 'size method...
> > >
> > > --
> > > Tim Johnson <tim@johnsons-web.com>
> > > http://www.alaska-internet-solutions.com
> > > http://www.johnsons-web.com
> > >
> > > ---------
> > > To unsubscribe, send email to <aklug-request@aklug.org>
> > > with 'unsubscribe' in the message body.
> > >
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
>
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
>

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Wed Dec 18 2002 - 14:32:58 AKST