# autocis - xcmalt script to visit CIS automagically.
# This file uses 4-character tabstops.
# It will log in, visit Easyplex (if mail is waiting), then the
#  PRACTICE and TANGENT Fora, uploading any prepared files, downloading
#  all new messages, and capture into three separate files.
# The following assumptions are made about your CIS interactions:
#  You go to Easyplex upon login if any mail is waiting.
#  You are in "expert" mode in Easyplex.
#  You are in Command mode in all Fora.
#  You have opted for continuous reading in all Fora.
#  You have set your Prompt Char set to '!' in all Fora.
# The script can be modified to set all of these options on a per/session
# basis if you wish to remain in menu-mode at other times
debug "on"				# Capture to "debug.log", if such a file exists
set bps 2400			# Numbers don't need literal quotes
set cis "off"			# Ignore any ENQ bytes if we see them
tty "on"				# Echo received characters to the screen

if ! linked
transmit "AATs0=0^M"	# The extra 'A' is for a Trailblazer; autoanswer off
then dial "9687790"		# Dial if we haven't already
endif	

assign counter eq 1
while ! waitfor "connect" 41			# Modem tells us this
		do
			incr counter
			if counter morethan 5		# Try again, but not forever
			then						# Don't forget the 'then' !!!
				quit					# This zaps xcmalt completely
			else
				redial
			endif
		done

pause 2
transmit "^C"							# Wait for network to catch up
pause 3
transmit "72160,1341\\pass-word^M"		#  then send PPN and password too!

if ! waitfor "rights reserved"			# 30 second default wait for the
then transmit "bye^M"; quit; fi 		#  normal CIS opening messages

if waitfor "easyplex!" 3				# If mail waiting, we get to this
then set cfile "email"					# Our mailbox
	capture "on"
	file echo `date`					# Date stamp before new mail

	transmit "rec all^M"				# Non-stop read all mail
	while ! waitfor "easyplex!" 1		# Background search for the prompt
		do; done						#  that tells us we're done
	transmit "del all^M"				# Dump 'em, we've got 'em
	capture "off"
fi

set cfile "prax"						# Go to the PRACTICE Forum
transmit "g practice^M"
waitfor "moment please..."
capture "on"
if ! waitfor "forum !!" 60
then transmit "bye^M"
	 quit
endif
assign Upload eq `ls rp 2>/dev/null`	# Have we got an 'rp' file
if Upload eq "rp"						#  containing new messages to send,
then	capture "off"					#  or replies to messages?
	type "rp"							# Better be 100% right about your
	transmit "^M"						#  use of the CIS editor commands!
	while ! waitfor "% choice required"	# The extra ^M provokes this string
		do; done
	capture "on"
fi
transmit "rea new^M^M"					# Grab all new stuff, including
while ! waitfor "% choice required"		#  anything we just uploaded.
	do; done
capture "off"

set cfile "tan"							# Same drill, different place.
transmit "g tangent^M"
waitfor "moment please..."
capture "on"
if ! waitfor "forum !!" 60
then transmit "bye^M"
	quit
endif
assign Upload eq `ls rt 2>/dev/null`
if Upload eq "rt"
then	capture "off"
	type "rt"
	transmit "^M"
	while ! waitfor "% choice required"
		do; done
	capture "on"
fi
transmit "rea new^M^M"
while ! waitfor "% choice required"
	do; done
transmit "off^M"
quit
