in reply to Self Extracting Archives with Perl (almost)

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;

Replies are listed 'Best First'.
Re: Re: Self Extracting Archives with Perl (almost)
by Anonymous Monk on Jan 23, 2001 at 22:49 UTC

    (same anonymous, firewalled silly author here...)

    ...all of which is not to say that your use isn't exceedingly kewl! I'd love to see your final version posted up here...