#
#   Kermit script that sends a numeric message to a pager
#
#  By: Jacob Lundqvist jaclu@ibk.se
#      1997-01-10
#

DEFINE \%a \&@[2] # modem line

#======================================================
#
# Macro deffinitions
#

#
#  Terminate script
#
define TERMINATE hangup,quit


#
# Pressentation
#
define ABOUT_PGM \
    echo, \
    echo Kermit numeric-paging ver 1.0 by Jacob Lundqvist - jaclu@ibk.se, \
    echo

#
#  Help
#
define SHOW_HELP \
    ABOUT_PGM, \
    echo First param should be a phonenumber, second a numeric message, \
    echo, \
    echo Example: kermit numeric.scr 4670890510 200192168510, \
    echo, TERMINATE

#
#  Terminate script
#
define TERMINATE hangup,quit

#
#  Help
#
define SHOW_HELP \
    ABOUT_PGM, \
    echo syntax: kermit numeric.scr line number message, \
    echo, \
    echo Example: kermit numeric.scr /dev/cua0 46890510 200192168510, \
    echo, set exit status 0, TERMINATE

#
# Wrong number of Arguments
#
define WRONG_NO_ARGS echo ERROR: wrong number of arguments (try ?), \
	set exit status 3, TERMINATE

#
#  No such device
#
define NO_DEV echo ERROR: no such device: \%1, set exit status 1, TERMINATE

#
# Check if device exists
#
define CHECK_DEV if < \Ffiles(\%1) 1 NO_DEV \%1

#========================================================
#
# Main
#

#
# Want help?
#
if equal \&@[2] ? SHOW_HELP

ABOUT_PGM

#
# Check params
#
if < \v(args) 5 WRONG_NO_ARGS
if > \v(args) 5 WRONG_NO_ARGS

CHECK_DEV \%a

#
# Set line params
#
set modem hayes
set line \%a
set flow xon/xoff
set speed 1200
set dial timeout 45

#
# Debugging
#
#log session session.log new

#
#  Send Message
#
hangup	# Make sure line is available

#
# Since not given any "CONNECT" we cant do much to check for success.
# if you loose messages, try adding some more ,,,,, (pause chars)
#
dial \&@[3],,,,,,,\&@[4]

#
#  Exit kermit
#
set exit status 0
TERMINATE
