Calling script

Michael Enkelis michaele at vice.ICO.TEK.COM
Thu May 25 04:56:28 AEST 1989


This is a simple calling script i use with tip.
It will try to redial a system if it is busy.

-----

#!/bin/csh -f
set noglob
onintr Hangup

set SPOOL="/usr/spool/uucp"
set MODEM="modem"
set CALL="/usr/public/tip"
set TRYS=2
set DELAY=30
set SYSTEM=""
set TRY=1
while ($#argv)
	switch ($1)
		case "-r":
			shift
			set TRYS=$1
			if ($TRYS < 1) then
				echo "Retry count too low, set from 1 to 100."
				exit 1
			endif
			if ($TRYS > 100) then
				echo "Retry count too high, set from 1 to 100."
				exit 1
			endif
			echo "Retry count set to $TRYS."
			breaksw
		case "-s":
			shift
			set DELAY=$1
			if ($DELAY < 1) then
				echo "Sleep value too low, set from 1 to 120."
				exit 1
			endif
			if ($DELAY > 120) then
				echo "Sleep value too large, set from 1 to 120."
				exit 1
			endif
			echo "Sleep time set to $DELAY seconds."
			breaksw
		case "-h":
		case "-?":
			echo -n "`basename $0` "
			echo "[-r retry_count] [-s sleep_time] system/number"
			echo "-r VVVV  Set retry count."
			echo "         Value of VVVV is 1 to 100."
			echo "-s VVVV  Set sleep time."
			echo "         Value of VVVV is 1 to 120 seconds."
			echo "system   System name from tip database."
			echo "number   Phone number to dial."
			exit 1
			breaksw
		default:
			set SYSTEM=$1
			breaksw
	endsw
shift
end

if ($SYSTEM == "") then 
	echo -n "Usage: `basename $0` "
	echo "[-h] [-r retry_count] [-s sleep_time] system/number"
	exit 1
endif

Top:
	if (-f $SPOOL/LCK..$MODEM ) then
		set info=`ls -l $SPOOL/LCK..$MODEM`
		echo "Modem is in use by $info[3], $info[5] $info[6] $info[7]."
		exit 2
	endif

	$CALL $SYSTEM

	switch ($status)
	case 0:
		echo "That will be .25 for 3 minutes."
		exit 0
		breaksw
	case 1:
		if ($TRY != $TRYS) then
			echo "Unable to complete this call."
			echo "Delaying for $DELAY seconds."
			sleep $DELAY
			@ TRY++
			echo "Retry $TRY of $TRYS."
			goto Top
		else
			echo "Sorry, unable to complete your call."
			exit 3
		endif
		breaksw
	case 3:
		exit 4
		breaksw
	case 8:
		exit 5
		breaksw
	default:
		echo "Exit status: $status."
	endsw

Hangup:
echo ""
exit 0
-- 
 _ _ _                          __
' ) ) )      /          /)     /  `       /      /)	Michael Enkelis
 / / / o _. /_  __. _  //     /--   __   /_  _  // o _ 	tektronix!vice!michaele
/ ' (_(_(__/ /_(_(_(<_(/_    (___, /) )_/ <_(<_(/_(_/_)_    (503) 627-4099



More information about the Alt.sources mailing list