Discussion:
Sending faxes during specified time interval
(too old to reply)
Wouter van Marle
2010-05-24 14:15:27 UTC
Permalink
Hi list,

I have a problem with faxspool: the -t <hh:mm-hh:mm> option to be exact.

In man faxspool it is described as time interval in between which faxes
can be sent, however my faxspool only accepts the -t <hh:mm> format,
which basically means try until midnight. That's not a good idea for
me: I want sending to start in the evening, then run overnight until
the morning, and stop again (if not finished).

Is this now implemented or not? The man pages are contradictory here. I
have seen both the range and the from-only option mentioned.
Any plans to have it implemented? Any patches available maybe?

I'm using mgetty+sendfax version 1.1.36-1.5 by Debian, which seems to
be the latest version available.

Also I noticed the mgetty.greenie.net home page is outdated with broken
links to the faq and listing 1.1.35 as latest beta release.

Wouter.


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-05-29 11:00:17 UTC
Permalink
Hi,
Post by Wouter van Marle
I have a problem with faxspool: the -t <hh:mm-hh:mm> option to be exact.
In man faxspool it is described as time interval in between which faxes
can be sent, however my faxspool only accepts the -t <hh:mm> format,
which basically means try until midnight. That's not a good idea for
me: I want sending to start in the evening, then run overnight until
the morning, and stop again (if not finished).
Oh, good spotting. The online help for faxspool has been adapted, and
faxrunqd (not faxrunq) implements it - but the man page for "faxqueue"
is still outdated, and the argument parsing for faxspool hasn't been
done yet either.

(Interesting that nobody has spotted this yet :-) ).
Post by Wouter van Marle
Is this now implemented or not? The man pages are contradictory here. I
have seen both the range and the from-only option mentioned.
Any plans to have it implemented? Any patches available maybe?
The missing code is just a few lines + documentation, so I'll try to
get this done next week.
Post by Wouter van Marle
I'm using mgetty+sendfax version 1.1.36-1.5 by Debian, which seems to
be the latest version available.
Also I noticed the mgetty.greenie.net home page is outdated with broken
links to the faq and listing 1.1.35 as latest beta release.
*sigh*. Thanks for pointing this out. Site moved, update scripts didn't
do their job at 1.1.36 release.

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Wouter van Marle
2010-06-01 03:11:10 UTC
Permalink
Hi,

So if I understand correctly if I amend the JOB file then it would work?
So change the 'time 1900' to 'time 1900-0800' would do the job?

Otoh, from the manual I understand that 'time 1900' means effectively
'from 19:00 until midnight'. But that doesn't seem to work either, see
e.g. this job file (edited for privacy):

------------------
phone secret
mail secret
input /tmp/tmpzeWvWe
pages f1.g3 f2.g3 f3.g3 f4.g3
time 1900
user fax
Status Tue Jun 1 00:32:30 2010 FATAL FAILURE, exit(10): dial failed:
ERROR or NO CARRIER
------------------

It is now 11:09 in the morning, and this job and a lot of other jobs are
happily dialling out. These faxes were queued yesterday (31 May) and
were obviously not finished by midnight, so are still being tried.

Wouter.
Post by Gert Doering
Hi,
Post by Wouter van Marle
I have a problem with faxspool: the -t <hh:mm-hh:mm> option to be exact.
In man faxspool it is described as time interval in between which faxes
can be sent, however my faxspool only accepts the -t <hh:mm> format,
which basically means try until midnight. That's not a good idea for
me: I want sending to start in the evening, then run overnight until
the morning, and stop again (if not finished).
Oh, good spotting. The online help for faxspool has been adapted, and
faxrunqd (not faxrunq) implements it - but the man page for "faxqueue"
is still outdated, and the argument parsing for faxspool hasn't been
done yet either.
(Interesting that nobody has spotted this yet :-) ).
Post by Wouter van Marle
Is this now implemented or not? The man pages are contradictory here. I
have seen both the range and the from-only option mentioned.
Any plans to have it implemented? Any patches available maybe?
The missing code is just a few lines + documentation, so I'll try to
get this done next week.
Post by Wouter van Marle
I'm using mgetty+sendfax version 1.1.36-1.5 by Debian, which seems to
be the latest version available.
Also I noticed the mgetty.greenie.net home page is outdated with broken
links to the faq and listing 1.1.35 as latest beta release.
*sigh*. Thanks for pointing this out. Site moved, update scripts didn't
do their job at 1.1.36 release.
gert
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-01 07:30:07 UTC
Permalink
Hi,
Post by Wouter van Marle
So if I understand correctly if I amend the JOB file then it would work?
So change the 'time 1900' to 'time 1900-0800' would do the job?
Yes. With faxrunqd. Faxrunq doesn't understand time ranges.
Post by Wouter van Marle
Otoh, from the manual I understand that 'time 1900' means effectively
'from 19:00 until midnight'. But that doesn't seem to work either, see
------------------
phone secret
mail secret
input /tmp/tmpzeWvWe
pages f1.g3 f2.g3 f3.g3 f4.g3
time 1900
user fax
ERROR or NO CARRIER
------------------
It is now 11:09 in the morning, and this job and a lot of other jobs are
happily dialling out. These faxes were queued yesterday (31 May) and
were obviously not finished by midnight, so are still being tried.
Hmmm, this is interesting. I need to look into this again.

Was this with faxrunq or with faxrunqd? Is there anything in faxrunqd.log
about this specific job?

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-01 07:38:06 UTC
Permalink
Hi,
Post by Wouter van Marle
Otoh, from the manual I understand that 'time 1900' means effectively
'from 19:00 until midnight'. But that doesn't seem to work either, see
I *think* faxrundq handles this as "if it's not yet 1900, calculate the
delay until 1900, and put the job to sleep until then - and then, send
it whenever possible".

So it's more like "delay until 1900", not "... and if not sent before
midnight, stop trying, and wait until 1900 next day".

But the documentation is obviously not specific enough :)

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Wouter van Marle
2010-06-01 07:46:50 UTC
Permalink
Post by Gert Doering
Hi,
Post by Wouter van Marle
Otoh, from the manual I understand that 'time 1900' means effectively
'from 19:00 until midnight'. But that doesn't seem to work either, see
I *think* faxrundq handles this as "if it's not yet 1900, calculate the
delay until 1900, and put the job to sleep until then - and then, send
it whenever possible".
Well you're the author :)
And my programming skills are not good enough to figure it out...
especially as I never learnt C.

Normally just delaying should be good enough but the fax list of the
missus is obviously too long :)

Wouter.
Post by Gert Doering
So it's more like "delay until 1900", not "... and if not sent before
midnight, stop trying, and wait until 1900 next day".
But the documentation is obviously not specific enough :)
gert
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Wouter van Marle
2010-06-01 07:45:31 UTC
Permalink
Post by Gert Doering
Post by Wouter van Marle
------------------
phone secret
mail secret
input /tmp/tmpzeWvWe
pages f1.g3 f2.g3 f3.g3 f4.g3
time 1900
user fax
ERROR or NO CARRIER
------------------
It is now 11:09 in the morning, and this job and a lot of other jobs are
happily dialling out. These faxes were queued yesterday (31 May) and
were obviously not finished by midnight, so are still being tried.
Hmmm, this is interesting. I need to look into this again.
Was this with faxrunq or with faxrunqd? Is there anything in faxrunqd.log
about this specific job?
It is faxrunqd.
Nothing specific in the logs that I can tell: just the normal log of a
job being done (dialing, phone answers, etc). Nothing about time
restrictions.
To free up my line I just stopped the daemon (and created an at job to
restart it tonight).

Debian Lenny
mgetty 1.1.36-1.5
mgetty-fax 1.1.36-1.5

Wouter.
Post by Gert Doering
gert
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-04 11:26:15 UTC
Permalink
Hi,
Post by Wouter van Marle
Post by Gert Doering
Post by Wouter van Marle
Otoh, from the manual I understand that 'time 1900' means effectively
'from 19:00 until midnight'. But that doesn't seem to work either, see
I *think* faxrundq handles this as "if it's not yet 1900, calculate the
delay until 1900, and put the job to sleep until then - and then, send
it whenever possible".
Well you're the author :)
Checked the source again. This is indeed what faxrunqd does today:

- read the job from disk (at faxrunqd start or when job is spooled)
- check whether it can be sent now
- if not: put into "delayed for <x> minutes" state (until start time is
reached)
- after that: never check time constraints again

so if you put "time 2300-0500" in there, and the fax can not be sent before
05:00, it will indeed get sent after that time.

(It's still useful to be able to say "time 1000-1600" and if you spool
this fax at 17:00, have faxrunqd understand that it needs to wait until
the next morning - but for your case, it's not working right yet)

Unfortunately, the fix for *that* is not so easy.
Post by Wouter van Marle
And my programming skills are not good enough to figure it out...
especially as I never learnt C.
Well, faxrunqd is perl, faxspool is shell, so you won't need C knowledge
to enhance or bugfix those :-)

I'll send a patch for "faxspool" to the list later today (to be able to
enter "-t 10:00-16:00" in the first place). I'm not sure when I'll find
time to change the logic inside faxrunqd :-/

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-04 12:54:16 UTC
Permalink
Hi,
Post by Gert Doering
Post by Wouter van Marle
Is this now implemented or not? The man pages are contradictory here. I
have seen both the range and the from-only option mentioned.
Any plans to have it implemented? Any patches available maybe?
The missing code is just a few lines + documentation, so I'll try to
get this done next week.
OK, here we go. This is just the faxspool + faxq patch (made against
faxspool.in / faxq.in, but should apply just fine against the resulting
scripts).

Documentation update will be done, but I won't send the patch here, do
a 1.1.37 release instead "soon".

gert

Index: faxspool.in
===================================================================
RCS file: /u2/cvs/mgetty/fax/faxspool.in,v
retrieving revision 4.35
retrieving revision 4.36
diff -u -r4.35 -r4.36
--- faxspool.in 21 Aug 2007 10:33:42 -0000 4.35
+++ faxspool.in 4 Jun 2010 12:45:36 -0000 4.36
@@ -3,7 +3,7 @@
# faxspool - sample script how to spool fax input data to a spool
# directory, creating jobs to be run by faxrunq
#
-# sccsid: $Id: faxspool.in,v 4.35 2007/08/21 10:33:42 gert Exp $ (c) Gert Doering
+# sccsid: $Id: faxspool.in,v 4.36 2010/06/04 12:45:36 gert Exp $ (c) Gert Doering
#
# syntax: faxspool [flags] <phone-number> <job(s)>
#
@@ -26,6 +26,10 @@
# 3.10.93: use "hp2hig3" for hp-pcl4-files (cl)
# 19.10.93: phone directories (caz)
# $Log: faxspool.in,v $
+# Revision 4.36 2010/06/04 12:45:36 gert
+# Implement "start-end" syntax for "-t <time>" flag
+# small bugfix for "echo" message after successful queueing "with -t"
+#
# Revision 4.35 2007/08/21 10:33:42 gert
# add "-" to list of permitted characters in FDATE
#
@@ -529,17 +533,26 @@
shift ; shift
;;
# set first time to send fax
- -t) if expr "$2" : "[0-2][0-9]:[0-9][0-9]$" >/dev/null
+ -t) if expr "$2" : "[0-2][0-9]:[0-5][0-9]$" >/dev/null
then
h=`expr "$2" : "\(..\)"`
m=`expr "$2" : "..:\(..\)"`
- if [ "$h" -gt 23 -o "$m" -gt 60 ]
+ if [ "$h" -gt 23 ]
then
$echo "Invalid time specified: $h:$m" >&2; exit 2
fi
TIME="$h$m"
+ elif expr "$2" : "[0-2][0-9]:[0-5][0-9]-[0-2][0-9]:[0-5][0-9]$" >/dev/null
+ then
+ h1=`expr "$2" : "\(..\)"`
+ h2=`expr "$2" : "..:..\-\(..\)"`
+ if [ "$h1" -gt 23 -o "$h2" -gt 23 ]
+ then
+ $echo "Invalid time range specified: $2" >&2; exit 2
+ fi
+ TIME="`echo "$2" | tr -d ':'`"
else
- $echo "Time must be in <hh:mm> format." >&2; exit 2
+ $echo "Time specification (-t) must be in <hh:mm> or <hh:mm-hh:mm> format." >&2; exit 2
fi
shift ; shift
;;
@@ -995,6 +1008,6 @@
if [ -z "$TIME" ] ; then
$echo "\nFax queued successfully. Will be sent at next \`\`faxrunq'' run.\n"
else
- $echo "\nFax queued successfully. Will be sent at first \`\`faxrunq'' run\nafter the specified send time '$TIME' has been reached\n."
+ $echo "\nFax queued successfully. Will be sent at first \`\`faxrunq'' run\nafter the specified send time '$TIME' has been reached.\n"
fi
fi


Index: faxq.in
===================================================================
RCS file: /u2/cvs/mgetty/fax/faxq.in,v
retrieving revision 4.11
retrieving revision 4.12
diff -u -r4.11 -r4.12
--- faxq.in 16 Apr 2005 11:29:09 -0000 4.11
+++ faxq.in 4 Jun 2010 12:42:54 -0000 4.12
@@ -4,7 +4,7 @@
#
# like "lpq" or "mailq", show jobs waiting in the output queue
#
-# SCCS: $Id: faxq.in,v 4.11 2005/04/16 11:29:09 gert Exp $ Copyright (C) 1994 Gert Doering
+# SCCS: $Id: faxq.in,v 4.12 2010/06/04 12:42:54 gert Exp $ Copyright (C) 1994 Gert Doering
#
FAX_SPOOL=@FAX_SPOOL@
FAX_SPOOL_OUT=@FAX_SPOOL_OUT@
@@ -127,8 +127,11 @@
$1=="acct_handle" \
{ printf "ACCT=\"%s\";", substr( $0, 13 ) }
$1=="input" { printf "INPUT=\"%s\";", substr( $0, 7 ) }
- $1=="time" { printf "TIME=\"%s:%s\";",
- substr( $0, 6, 2 ), substr( $0, 8,2 ) }
+ $1=="time" { if ( length($2) == 4 )
+ { printf "TIME=\"%s:%s\";",
+ substr( $2, 1, 2 ), substr( $2, 3, 2 ) }
+ else
+ { printf "TIME=\"%s\";", $2 } }
$1=="subject"{ printf "RE=\"%s\";", substr( $0, 9 ) }
$1=="priority"{ printf "PRI=\"%s\";", $2 }
$1=="pages" { if ( NF==2 ) printf "PAGES=\"%s\";", $2
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Andreas Barth
2010-06-04 12:59:13 UTC
Permalink
Post by Gert Doering
Documentation update will be done, but I won't send the patch here, do
a 1.1.37 release instead "soon".
apropos. I have the following patch from the debian security team. I'm
unsure if someone forwarded it to you already.


Andi

#! /bin/sh /usr/share/dpatch/dpatch-run
## 78-insecure-tmp-usage by Nico Golde <***@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: fix insecure use of temporary file names

@DPATCH@
diff -urNad mgetty-1.1.36~/fax/faxspool.in mgetty-1.1.36/fax/faxspool.in
--- mgetty-1.1.36~/fax/faxspool.in 2008-09-13 16:32:53.000000000 +0200
+++ mgetty-1.1.36/fax/faxspool.in 2008-09-13 16:33:11.000000000 +0200
@@ -653,9 +653,9 @@
#
# mkdir a directory in $TMP (or /tmp), convert input to G3 in there
#
-spooldir=${TMP:-/tmp}/$new_seq.$$.`date +%S`
+spooldir=`mktemp -t -d`

-if ( umask 077 ; mkdir $spooldir ) ; then
+if [ $? -eq 0 ]; then
$echo "spooling to $spooldir (->$new_seq)..."
else
$echo "ERROR: can't create work dir '$spooldir', giving up" >&2 ; exit 6
@@ -674,10 +674,13 @@
#
if [ x$file = x- ]
then
- $echo "spooling $file (stdin)..."
- trap "rm /tmp/faxsp.$$" 0
- cat - >/tmp/faxsp.$$
- file=/tmp/faxsp.$$
+ file=`mktemp /tmp/faxspool.XXXXXXXXX`
+ if test -z $file
+ then
+ $echo "ERROR: can't create work file, giving up" >&2 ; exit 6
+ fi
+ trap "rm $file" 0
+ cat - >$file
else
$echo "spooling $file..."
fi

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-04 13:43:22 UTC
Permalink
Hi,
Post by Andreas Barth
Post by Gert Doering
Documentation update will be done, but I won't send the patch here, do
a 1.1.37 release instead "soon".
apropos. I have the following patch from the debian security team. I'm
unsure if someone forwarded it to you already.
I think I've seen it before.

Can't easily include it, though :-( - as it is non-portable to systems
without "mktemp"... and everything in the mgetty package (except faxrunqd)
still tries to be compatible to the most basic unix systems out there.

Need to check whether all recent unix platforms have "mktemp" (with "-d"),
and if yes, I could indeed reconsider (and in doubt, pack mktemp.c into
compat/). *check*. OK, Solaris and NetBSD have it... and it might even
be call-compatible, even if the manpage suggests otherwise...

SYNOPSIS
mktemp [-dtqu] [-p directory] [template]

SYNOPSIS
mktemp [-d] [-q] [-t prefix] [-u] [template ...]

Hrm.

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-06-04 13:48:45 UTC
Permalink
Hi,
Post by Gert Doering
- read the job from disk (at faxrunqd start or when job is spooled)
- check whether it can be sent now
- if not: put into "delayed for <x> minutes" state (until start time is
reached)
- after that: never check time constraints again
so if you put "time 2300-0500" in there, and the fax can not be sent before
05:00, it will indeed get sent after that time.
So. Here's a patch for faxrunqd that should make it do exactly as it
is told to "send the fax *only* in the time range specified".

I have tested it a bit, and it seems to work...

(The line offsets will be off for "stock 1.1.36" faxrunqd, but it should
be fairly obvious from the context where the changes should go to)

gert

Index: faxrunqd.in
===================================================================
RCS file: /u2/cvs/mgetty/fax/faxrunqd.in,v
retrieving revision 1.80
diff -u -1 -0 -r1.80 faxrunqd.in
--- faxrunqd.in 17 May 2010 15:13:57 -0000 1.80
+++ faxrunqd.in 4 Jun 2010 13:48:09 -0000
@@ -1076,25 +1076,23 @@
print LOG " policy: extra key set: $ekey->$queue{$job}{$ekey}\n" if $opt_v;
}

last;
}
}

# all done, mark job as 'ready to be sent'
$queue{$job}->{'status'} = 'active';

- # if timing constraints permit, put into modem queue
- if ( &check_timing_constraints($job) )
- {
- &put_job_to_modem_queue($job);
- }
+ # put into modem queue (time constraints will be checked when this
+ # job is at the head of the modem queue and due for sending)
+ &put_job_to_modem_queue($job);
return;
}

if ( -f "$job/JOB.done" )
{
$queue{$job}->{'status'} = 'done'; return;
}

if ( -f "$job/JOB.error" )
{
@@ -1195,20 +1193,29 @@
# set $tty_in_use{$tty}, etc.
#
##########################################################################
sub send_job_from_queue
{
my $tty = shift;
my $job = shift @{$modem_queue{$tty}};

print LOG "$job: Sending $job/JOB on $tty...\n" if $opt_v;

+ # check whether we can send this job right now, or need to delay it
+ unless( &check_timing_constraints($job) )
+ {
+ # need to delay - remove from queues, free phone number, etc.
+ $mq_length{$tty} -= $queue{$job}->{weight};
+ &reactivate_others($job);
+ return;
+ }
+
# check whether job has been removed (faxrm) in the meantime...
unless( -d "$job" && -f "$job/JOB" )
{
print LOG "WARNING: job $job has disappeared from disk queue!\n";
$queue{$job}->{'status'}='error';
$mq_length{$tty} -= $queue{$job}->{weight};
&reactivate_others($job);
return;
}
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...