From: "rob pike" <rob@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: [9fans] fax
Date: Sat, 2 Jun 2001 17:45:19 -0400 [thread overview]
Message-ID: <20010602214521.070C4199C0@mail.cse.psu.edu> (raw)
Presto had already fixed our fax script; here is the complete file
/rc/bin/fax
#!/bin/rc
view=no
stdin=no
switch($1){
case -v
view=yes
shift
}
switch($#*){
case 0 1
echo usage: $0 telephone-number recipient [files]
exit 0
case 2
stdin=yes
}
telno=$1
shift
switch($telno){
case [0-9]*
;
case *
echo usage: $0 telephone-number recipient [files]
exit 0
}
switch($telno){
case ???????
telno='*9,'^$telno
case ??????????
telno='*9,1'^$telno
case 1??????????
telno='*9,'^$telno
case 011*
telno='*9,'^$telno
case +*
telno=`{echo $telno | sed 's/\+/*9,011/'}
}
recip=$1
shift
script=/tmp/fax.$pid
header=/tmp/faxh.$pid
user=`{cat /dev/user}
tmp=/tmp/fax.g3.$pid
tmpin=/tmp/fax.in.$pid
tmpps=/tmp/fax.ps.$pid
tel=`{grep '\) '$user /lib/tel}
myname=`{echo $tel | sed 's/ \(.*//'}
ext=`{echo $tel | sed 's/.*\) [^ ]* [^ ]* ([^ ]*).*/\1/'}
fn sigint{
rm -f $tmp.* $script $header $header.* $tmpin $tmpps
exit interrupt
}
# gather input into a file
switch($stdin){
case yes
cat > $tmpin
infiles=$tmpin
case *
infiles=($*)
}
# convert to g3
g3files=()
a=1
for(i in $infiles){
switch(`{file $i}){
case *:*g3* *:*fax*
g3files=($g3files $i)
case *:*postscript
gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $i quit.ps
g3files=($g3files $tmp.$#a.*)
case *
lp -dstdout $i > $tmpps
gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $tmpps quit.ps
g3files=($g3files $tmp.$#a.*)
}
a=($a $a)
}
pages=`{echo $g3files|wc -w}
echo -n 's/FAXddd/' > $script
echo -n `{date}>> $script
echo />> $script
echo -n s/FAXFFF/>> $script
echo -n $myname >> $script
echo />> $script
echo -n s/FAXEEE/>> $script
echo -n $user >> $script
echo />> $script
echo -n s/FAXVVV/>> $script
echo -n $ext >> $script
echo />> $script
echo -n s/FAXTTT/>> $script
echo -n $recip >> $script
echo />> $script
echo -n s/FAXfff/>> $script
echo -n $telno >> $script
echo />> $script
echo -n s/FAXPPP/>> $script
echo -n $pages >> $script
echo />> $script
sed -f $script /sys/lib/fax/h.ps > $header
gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%03d' -dNOPAUSE -dQUIET $header quit.ps
files=()
for(i in $header.* $g3files){
files=($files -f $i)
}
switch($view){
case no
upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null
rx dinar /sys/lib/fax/faxgoose
case yes
page $header.* $g3files
}
#rm -f $tmp.* $script $header $header.* $tmpin $tmpps
next reply other threads:[~2001-06-02 21:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-02 21:45 rob pike [this message]
2001-06-03 20:34 ` Boyd Roberts
2001-06-03 20:43 rob pike
2001-06-03 21:25 ` Boyd Roberts
2005-04-03 6:07 [9fans] FAX lucio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010602214521.070C4199C0@mail.cse.psu.edu \
--to=rob@plan9.bell-labs.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).