Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/fax/receiverc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
spool=/mail/faxqueue
recipients=/mail/faxqueue/faxrecipients

# run mail as if we're on fs
rm /srv/fs
9fs fs
bind -c /n/fs/mail/faxqueue /mail/faxqueue

#
# Arguments should be
#	time Y|N pages [ftsi]
#
switch($#*){

case 4
	#
	# Check for the NYT. It's 9 pages from 'Via Fax             '.
	#
	nyt=false
	if(~ $2 Y && {~ $4 'Via Fax             '}){
		switch(`{date|sed 's/ .*//'}){
		case Mon Tue Wed Thu Fri
			hour=`{date|sed 's/.* ([0-9][0-9]):.*/\1/'}
			if(test $3 -gt 7 -a '(' $hour -lt 7 -o $hour -ge 21 ')')
				nyt=true
		case *
			if(test $3 -gt 7)
				nyt=true
		}
	}
	switch($nyt){

	case true
		to=`{seq 0 1 $3}
		for(i in `{seq 2 1 $3}){
			switch($i){
	
			case ?
				ext=00$i
			case ??
				ext=0$i
			case ???
				ext=$i
			}
			cp $spool/$1.$ext /n/fs/lib/nyt/nyt.$to($i)
		}
		cp $spool/$1.1 /n/fs/lib/nyt/nyt.$3
		rm -f $spool/$1.*
	case *
		{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
	}
case 3
	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
case *
	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail postmaster
}
exit 0

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].