psfax 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/rc
  2. view=no
  3. stdin=no
  4. switch($1){
  5. case -v
  6. view=yes
  7. shift
  8. }
  9. switch($#*){
  10. case 0 1
  11. echo usage: $0 telephone-number recipient [files]
  12. exit 0
  13. case 2
  14. stdin=yes
  15. }
  16. telno=$1
  17. shift
  18. recip=$1
  19. shift
  20. script=/tmp/fax.$pid
  21. header=/tmp/faxh.$pid
  22. user=`{cat /dev/user}
  23. tmp=/tmp/page.$pid
  24. tmpin=/tmp/page.in.$pid
  25. tel=`{grep '\) '$user /lib/tel}
  26. myname=`{echo $tel | sed 's/ \(.*//'}
  27. ext=`{echo $tel | sed 's/.*\) [^ ]* [^ ]* ([^ ]*).*/\1/'}
  28. fn sigint{
  29. #rm -f $tmp.* $tmpin.* $script $header $header.*
  30. exit interrupt
  31. }
  32. # gs insists on reading its standard input, so we read quit.ps to cut it off.
  33. switch($stdin){
  34. case yes
  35. cat > $tmpin
  36. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.%.3d' -dNOPAUSE -dQUIET $tmpin quit.ps
  37. case *
  38. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.%.3d' -dNOPAUSE -dQUIET $* quit.ps
  39. }
  40. pages=`{echo $tmp.*|wc -w}
  41. # use delimiters that are unlikely to be supplied in arguments
  42. echo -n s∮FAXddd∮ >$script
  43. echo -n `{date} >>$script
  44. echo ∮ >>$script
  45. echo -n s∮FAXFFF∮ >>$script
  46. echo -n $myname >>$script
  47. echo ∮ >>$script
  48. echo -n s∮FAXEEE∮ >>$script
  49. echo -n $user >>$script
  50. echo ∮ >>$script
  51. echo -n s∮FAXVVV∮ >>$script
  52. echo -n $ext >>$script
  53. echo ∮ >>$script
  54. echo -n s∮FAXTTT∮ >>$script
  55. echo -n $recip >>$script
  56. echo ∮ >>$script
  57. echo -n s∮FAXfff∮ >>$script
  58. echo -n $telno >>$script
  59. echo ∮ >>$script
  60. echo -n s∮FAXPPP∮ >>$script
  61. echo -n $pages >>$script
  62. echo ∮ >>$script
  63. sed -f $script /sys/lib/fax/h.ps > $header
  64. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%.3d' -dNOPAUSE -dQUIET $header quit.ps
  65. files=()
  66. for(i in $header.* $tmp.*){
  67. files=($files -f $i)
  68. }
  69. switch($view){
  70. case no
  71. upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null
  72. rx fax /sys/lib/fax/faxgoose
  73. case yes
  74. page $header.* $tmp.*
  75. }
  76. #rm -f $tmp.* $header $script $header.* $tmpin