/usr/share/doc/mgetty/examples/faxview.th is in mgetty-docs 1.1.36-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/perl -w
# $Id: faxview.th,v 1.1 1998/08/31 20:25:37 gert Exp $
# Program for handling gziped and tarred g3 files
#
# use together with "new_fax.th"
#
# Torsten Hilbrich <Torsten.Hilbrich@gmx.net>
# The FAX viewer
my $viewer="/opt/kde/bin/kfax";
# First let's define a function that determines the filetype
sub type($)
{
my $file = shift;
open TYPE, "file \"$file\"|"
or die "Could not exec file for $file";
my @ret = <TYPE>;
close TYPE;
return join "", @ret;
}
# A temp directory
my $tmp = "/tmp/faxview-$$";
mkdir $tmp, 0755
or die "Unable to create temp directory $tmp";
# The array files contains all files to be viewed
my @files;
# Step through the command line argument
my $file;
foreach $file (@ARGV) {
# Ignore non existing and unreadable files
-f $file && -r $file or next;
my $steps = 0;
$steps++;
# Check for gzip compressed files
if(type($file) =~ /compressed/) {
my $newname = "$tmp/gzip-$steps";
system("gzip -dc \"$file\" > \"$newname\"") == 0
or die "Unable to unzip $file into $tmp";
$file = $newname;
redo;
}
if(type($file) =~ /tar/) {
my $tempdir = "$tmp/tar-$steps";
mkdir $tempdir, 0755
or die "Unable to create temp directory $tempdir";
chdir $tempdir;
# Extract the file right here
system("tar xf \"$file\"") == 0
or die "Problem while unpacking tar archive $file";
# Add these files to @files
open READ, "tar tf \"$file\"|"
or die "Unable to read tar archive $file";
while(<READ>) {
chop($_);
push @files, $_;
}
close READ;
next;
}
push @files, $file;
}
system($viewer, @files) == 0
or die "Problem while calling the fax viewer $viewer";
END {
defined $tmp and
system("rm -fr \"$tmp\"");
}
|