bofh_of_oz has asked for the wisdom of the Perl Monks concerning the following question:

Yesterday, I've got a very interesting request at work... I've been automating some of our file transfers (using FTP or UNC, with zip/unzip and PGP options) lately, and now they want me to develop a 'template' that, given file names and transfer types (along with other relevant options), would transfer the file(s) in question to desired destination.

I wasn't able to find something like this that would be already developed and readily available. Since that doesn't mean the program doesn't exist, I am asking if any of the esteemed Perl monks could point me in the right direction so that I can avoid reinventing the wheel.

Any pointers appreciated...

UPDATE: After getting an insightful input, I (again...) realized that I still can't properly state what I need the first time I post my question. Here is some more information:

- The "template" (or a universal script - call what you like) will be converted to an .EXE file by perl2exe and installed onto Win32 computer(s). (So it's not a configuration file, it IS the actual program that will transfer the files)

- Yes, wget has some of needed functionality, but not all of it; a script of some sort would still be needed, so might as well do the whole thing in Perl...

- All relevant information (filenames, host names etc) will be passed to the script at run time (via params in STDIN or a text file).

- The relevant information may include options about whether we need to zip/unzip the file, encrypt/decrypt, use SSL on transfer etc.

- The functionality required currently exists as a bunch of scripts (one script/exe for one task); the management is curious about integrating all that into one script.

- As I develop the script for the company I work for, I will be maintaining it (at least, while i'm employed here...)

--------------------------------
An idea is not responsible for the people who believe in it...

Replies are listed 'Best First'.
Re: File transfer template script
by zentara (Cardinal) on May 27, 2005 at 16:32 UTC
    Also check out curl. It is hard to wade through the docs, but it has many examples to do what you want, and there is a perl interface to libcurl.

    I'm not really a human, but I play one on earth. flash japh
Re: File transfer template script
by 5mi11er (Deacon) on May 27, 2005 at 15:12 UTC
    wget?

    From your description, I think this is will do most of the work for you, you might still need a small perl wrapper around that, but definitely check out wget.

    -Scott

Re: File transfer template script
by ghenry (Vicar) on May 27, 2005 at 15:05 UTC

    Hi,

    Who will look after the template?

    Is this something that "they" will be editing and then sending you a copy etc.?

    Or is it merely a configuration file that you need to source for the various options?

    You could use various data formats for this technique, like HoHs or an XML file etc.

    With a few more details on the "template" requirement, we should be able to give you more tips.

    HTH.

    Walking the road to enlightenment... I found a penguin and a camel on the way.....
    Fancy a yourname@perl.me.uk? Just ask!!!
Re: File transfer template script
by crusty_collins (Friar) on May 27, 2005 at 15:10 UTC
    I do something similar with control files. For instance. *process*version : 1.0 *process*tcpPort : 7500 *process*httpPort : 7580 It sounds to me like you would want something like *filename*transferProto : ftp *filename*destMachine : hostname etc. The following code is what was suggested to me for populating the hash
    local $Data::Dump::Purity = 1; local(*FILE); open (FILE,"$ControlFile") or die print "Could not open control file + : $ControlFile\n"; my %hash; # Parse the whole file then later on get vars based # on avaible process. while( <FILE> ) { chomp($_); next, if (index($_,'#') >= 0); next, if (index($_,'!') >= 0); if ( (index($_,$process) >= 0) ) { print "$_ \n", if ($verbose); my ( $front, $back ) = split /\s*:\s*/; $front =~ s/^\*//g; my @keys = split /\*/, $front; eval( '$hash' . ( join '', map { "{'$_'}" } @keys ) . "=" . Dumpe +r $back ); } } close FILE; return \%hash;