Not to be a heretic, but you could step outside of Perl and just use the "shar" program to create a shell archive. This utility already does near-exactly what you're trying to do, and is (somewhat) common.

Here's the HP/UX "shar:"

usage: shar [-AabCcDdefhmorstuvZ] <file|dir> ... -A: supress warning messages for optional acl entries -a: assume files are shippable, don't uuencode -b: use basenames instead of full pathnames -c: use wc(1) to check integrity of transfer -C: include a "cut here" line -d: don't recurse on contents of directories -D <dir>: must be in <dir> to unpack -e: don't overwrite existing files -f <file>: file containing list of directories and files or - to read filenames from standard input -h follow symbolic links instead of archiving them -m: retain modification/access times on files -o: retain user/group owner information -r: must be "root" to unpack -s: use sum(1) to check integrity of transfer -t: verbose messages to /dev/tty instead of stderr -u: assume remote site has uudecode(1) for unpacking -v: verbose mode -Z: shrink files using compress(1)

The GNU version is substantially similar.

If your "targets" don't have access to a POSIX-like shell, though, they'd need one. (i.e. are they stuck on Windows?) The Bourne Again Shell (bash) from Cygwin comes to mind...

For example:

(hpux) $ shar myfile.pl > myfile.shar (nt) $ ftp (hpux) Connected to (hpux) 220 (hpux) FTP server (Version 1.1.214.4 Mon Feb 15 08:48:46 GMT 1999) + ready. Name ((hpux):(user)): 331 Password required for (user). Password: 230 User (user) logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> ascii 200 Type set to A. ftp> get sample.shar 200 PORT command successful. 150 Opening ASCII mode data connection for sample.shar (138630 bytes). 226 Transfer complete. 140877 bytes received in 0.14 seconds (1006264 bytes/s) ftp> quit 221 Goodbye. administrator@(nt) ~ $ head -3 sample.shar # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". administrator@(nt) ~ $ sh sample.shar Compiling unpacker for non-ascii files x - myfile.pl

I've assumed a binary file here (ergo the line about non-ascii), but transfered it in ASCII mode, just to make sure that the translation before a 64-bit UNIX host and a 32-bit Win32 host would work OK even over an "unclean" link, like contained in an eMail message. Something like this should work for you, then:

#!/usr/bin/perl -w my $recipients = 'admin@site1 admin@site2'; open MAIL, "|mailx -s 'updated files' $recipients"; print MAIL<<HEADER_END; Here are today's updated files. Save the rest of this message to a file (for example, "updated.shar") +and then run it in a shell (for example, "sh updated.shar") to extract. HEADER_END print MAIL `shar @ARGV`; print MAIL `cat ~/.signature`; close MAIL;

In reply to Re: Self Extracting Archives with Perl (almost) by Anonymous Monk
in thread Self Extracting Archives with Perl (almost) by deprecated

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.