HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl script to resend failed fax. Anybody have it?

You probably want Phil Abercrombie's resendfax perl script

On 3 Aug 1999, kyle.silfer wrote:

> >From searching the mail archives, it appears the a guy named Paul
> Abercrombie wrote a handy Perl script to resend faxes from the doneq
> directory. He posted it to this list (although it does not appear in
> the archives!!!) and some people have used it. Paul himself no longer
> has the script. Does anybody? It sounds extremely useful and thus far
> the only pragmatic solution to reusing failed faxes without starting
> over from scratch.
> If anybody has a copy, I would be eternally grateful if he/she could
> email a copy to me (and to the list!). Thanks.

Tim Rice			Multitalents	(707) 887-1469 (voice)

# (c) Copyright Phil Abercrombie April 1997

# phil@mcs.vuw.ac.nz

use Net::FTP;

use Getopt::Std;

getopts("A:au:h:p:v") || die <<DEATH;

usage: $0 [-u user[:passwd]] [-a] [-A admin-passwd] [-h host] [-p port] [-v] job...


  -h host           fax server (default $FAXSERVER or localhost)

  -p port           port on fax server (default 4559)

  -u user[:passwd]  user to log on to fax server (default current user)

  -a                try to get admin privileges

  -A passwd         use this passwd to get admin privileges

  -v                enable debugging



my $USERNAME = $opt_u || (getlogin);

my $PASSWD = $1 if $USERNAME =~ s/:(.*)//;

my $ADMIN = $opt_A;

my $FAXSERVER = $opt_h || $ENV{FAXSERVER} || "localhost";

my $HYLAFAX = $opt_p || 4559;

my $hfax = new Net::FTP $FAXSERVER, Port=>$HYLAFAX or die "Can't connect to fax server $FAXSERVER:$HYLAFAX\n";


sub check(@)


  my $code = $hfax->code;

  return $code if grep($_==$code,@_);

  return if $hfax->ok;

  die sprintf "%3d %s", $code, $hfax->message;


sub noecho($ )


  my $prompt = shift;

  system('stty -echo');

  print STDERR "$prompt: ";

  chomp(my $input = <STDIN>);

  system('stty echo');

  print STDERR "\n";



END { system('stty sane') }

$hfax->quot("USER", $USERNAME);

if (check(331))


  $PASSWD ||= noecho "Password";

  $hfax->quot("PASS", $PASSWD);



$ADMIN ||= noecho "Admin Password" if $opt_a;

$hfax->quot("ADMIN",$ADMIN) if $ADMIN; check;

$hfax->binary; check;

my $job;

for $job (@ARGV)                     # each job


  my @docs;

  my $cx = $hfax->retr("doneq/q$job"); check;



    push(@docs,$2) if (/^!?(postscript|tiff):.*(docq.*)$/);


  $cx->close; check;

  $hfax->quot("JOB",$job); check;

  $hfax->quot("JNEW"); check;



    $hfax->quot("JPARM","DOCUMENT","$_"); check;


  # poke job's sendtime and killtime

  $hfax->quot("JPARM", "SENDTIME", "NOW"); check;

  $hfax->quot("JPARM", "LASTTIME", "000259"); check;

  $hfax->quot("JSUBM"); check;

  my ($jobno)= $hfax->message =~ /Job (\d+)/;

  print STDERR "Job $jobno submitted as clone of job $job\n";


Project hosted by iFAX Solutions