psfax 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. echo -n 's/ddd/' > $script
  42. echo -n `{date}>> $script
  43. echo />> $script
  44. echo -n s/FFF/>> $script
  45. echo -n $myname >> $script
  46. echo />> $script
  47. echo -n s/EEE/>> $script
  48. echo -n $user >> $script
  49. echo />> $script
  50. echo -n s/VVV/>> $script
  51. echo -n $ext >> $script
  52. echo />> $script
  53. echo -n s/TTT/>> $script
  54. echo -n $recip >> $script
  55. echo />> $script
  56. echo -n s/fff/>> $script
  57. echo -n $telno >> $script
  58. echo />> $script
  59. echo -n s/ppp/>> $script
  60. echo -n $pages >> $script
  61. echo />> $script
  62. sed -f $script /sys/lib/fax/h.ps > $header
  63. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%.3d' -dNOPAUSE -dQUIET $header quit.ps
  64. files=()
  65. for(i in $header.* $tmp.*){
  66. files=($files -f $i)
  67. }
  68. switch($view){
  69. case no
  70. upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null
  71. rx dinar /sys/lib/fax/faxgoose
  72. case yes
  73. page $header.* $tmp.*
  74. }
  75. #rm -f $tmp.* $header $script $header.* $tmpin