#!/usr/um/bin/perl push(@INC,"$ENV{'HOME'}/perl"); %ext=("jpg", "image/jpeg", "gif", "image/gif", "ppm", "image/ppm", "pgm", "image/pgm", "pbm", "image/pbm", "au", "audio/basic", "ps", "application/postscript", "txt", "text/plain", "mpg", "video/mpeg"); while (@ARGV) { $_=shift; /^-f/ && ($access="ftp",next); /^-a/ && ($access="afs",next); /^-t/ && ($access="tar",next); push(@files,$_); } sub usage { $0=~s@.*/@@; print "$0: [ -ftp | -afs | -tar ] files\n" } if ($access eq "tar") { $tmp="/tmp/ifile.$$"; unlink($tmp); system("tar cf - " . join(" ",@files) . " | compress > $tmp"); print "#application/octet-stream ; type=tar ; \\\n"; print " conversions=x-compress $tmp \n"; exit(0); } for $file (@files) { $file=&expandfilename($file); $type=$ext{$'} if ($file=~/.*\./); $type="application/octet-stream" unless $type; if ($access eq "afs") { print "#@$type [] access-type=AFS ; \\\n"; print " name=\"$file\"\n"; } elsif ($access eq "ftp") { chop($host=`hostname`); print "#@$type [] access-type=FTP ; \\\n"; print " name=\"$file\" ; \\\n"; print " site=\"$host\"\n"; } else { print "#$type $file\n"; } } sub expandfilename { local($_)=shift; if (/^~/) { if (m@^~/@) { (getpwuid($>))[7] . "/" . $'; } else { m@^~([a-z]+)/@; (getpwnam($1))[7] . "/" . $'; } } else { $_; } }