N
Noel Sant
Hi! Can anyone help, please?
I'm using AciveState's "perl v5.8.0 built for MSWin32-x86-multi-thread"
(from a "perl -v" command), on Windows 2000. I want to use WZZIP (WinZip's
command line utility) to back up some data files. I'm using its -i option to
pick up files that have the archive attribute set, and the -rp option to
recurse into subfolders. I want to keep WZZIP's messages, but after the
first backup, they are mainly the names of folders, which aren't interesting
(to me). So I thought I'd open WZZIP as a pipe and read in its output,
filter out any lines ending with a (forward or back) slash, and print them
out again. I'd also like to print out its return code.
The following program snippet does whar I want, except for the return code.
When I just used the perl system function, it was fine, of course, but
something in the camel book (p. 342) made me think I might get it when
closing the pipe. Perhaps that's only in Unix systems. All I get is "1",
whereas WZZIP gives "0" if OK.
(The program would look prettier if I could use a non-proportional font, but
my Outlook Express News reader only seems to allow that if I use HTML, but I
wasn't sure if that was OK in this news group.)
=====================
# my $rc = system($command);
open ZIP_OUTPUT, "$command |"
or die "Error openng WZZIP output pipe etc."\n";
while (<ZIP_OUTPUT>) {
chomp;
s/\s+$//; # trim blanks right
next if /\\$/;
next if /\/$/;
print MESSAGES $_ . "\n";
}
my $rc = close ZIP_OUTPUT;
=====================
TIA,
Noel
I'm using AciveState's "perl v5.8.0 built for MSWin32-x86-multi-thread"
(from a "perl -v" command), on Windows 2000. I want to use WZZIP (WinZip's
command line utility) to back up some data files. I'm using its -i option to
pick up files that have the archive attribute set, and the -rp option to
recurse into subfolders. I want to keep WZZIP's messages, but after the
first backup, they are mainly the names of folders, which aren't interesting
(to me). So I thought I'd open WZZIP as a pipe and read in its output,
filter out any lines ending with a (forward or back) slash, and print them
out again. I'd also like to print out its return code.
The following program snippet does whar I want, except for the return code.
When I just used the perl system function, it was fine, of course, but
something in the camel book (p. 342) made me think I might get it when
closing the pipe. Perhaps that's only in Unix systems. All I get is "1",
whereas WZZIP gives "0" if OK.
(The program would look prettier if I could use a non-proportional font, but
my Outlook Express News reader only seems to allow that if I use HTML, but I
wasn't sure if that was OK in this news group.)
=====================
# my $rc = system($command);
open ZIP_OUTPUT, "$command |"
or die "Error openng WZZIP output pipe etc."\n";
while (<ZIP_OUTPUT>) {
chomp;
s/\s+$//; # trim blanks right
next if /\\$/;
next if /\/$/;
print MESSAGES $_ . "\n";
}
my $rc = close ZIP_OUTPUT;
=====================
TIA,
Noel