AutoPPP -   A REXX script that periodically connects to your ISP using 
            PPP.EXE and SLATTACH.EXE and executes a program once the 
            connection is established.

Author:     David Forrai <dforrai@erinet.com>

DISCLAIMER:  Please note that this software is freeware.  You are free
to distribute and/or modify it.  The author does not warrant that this
software will meet your requirements or that the operation of the
software will be error free.  The author will not be liable for any loss
or damages occurred by the use of this software.

File list:

   README         - This file
   AutoPPP.CMD    - The main REXX program that launches PPP.EXE
   Wait4PPP.CMD   - A background REXX program that monitors SLATTACH 
                    output and launches the specified program when the 
                    connection is established.

Description:

AutoPPP will dial you ISP using PPP and SLATTACH.  You must set the PPP 
parameters using the PPP.CFG file in the TCPIP\ETC directory.  If you 
launch AutoPPP without any command line parameters, AutoPPP will start 
PPP.EXE and connect to your ISP.  If PPP.EXE terminates, AutoPPP will 
restart PPP.EXE.  In this mode you must manually kill the script, 
otherwise it will try to keep your PPP connection established 
indefinitely.  The syntax for this mode of operation is:

AutoPPP

There are three optional command line parameters.  These parameters 
allow periodic execution of an application after the PPP connection is 
established.  As long as that application is running, AutoPPP will try 
to keep your PPP connection up by restarting PPP.EXE after it 
terminates.  Once the application terminates, AutoPPP will wait until 
the default or specified period from the start of the connection process
before connecting and launching the application again.  By default, the
start time for the PPP connection is immediately and the interval is 24 
hours.  The syntax for this mode of operation is:

AutoPPP myapp.exe myapps_parameters

If you specify the path of myapp.exe, the default directory will be 
changed to this path before launching myapp.exe.  myapp could also be a 
OS/2 command file, eg. myapp.cmd

If you wish to start the PPP connection at a specific time and restart 
at 24 hour intervals, use the following syntax:

AutoPPP /Hxx:yy myapp myapp_parameters

The /H switch MUST be before myapp and the start time must be specified 
in 24 hour format (eg. 0:00 = midnight, 12:00 = noon, 23:00 = 11pm) 
where xx is in hours between 0 and 23 and yy is in minutes between 0 and
59.

To change the interval between launches, use the syntax:

AutoPPP /Ixx:yy myapp myapp_parameters

The /I switch MUST be specified before myapp.  It can be used in 
conjunction with the /H switch.  The order of /I and /H doesn't matter 
as long as they both precede the application.  Again, xx is in hours 
(between 0 and 23) and yy in minutes (between 0 and 59).

How it works

The script parses the command line and sets parameters accordingly.  If 
a start hour is specified, AutoPPP will calculate how long to wait 
before this time occurs from the current time, then sleep for that 
period.  When AutoPPP wakes up (if it was put to sleep by the /H 
switch), it creates a REXX queue, starts a minimized background process 
(Wait4PPP) that monitors this queue, then starts PPP.EXE piping its 
output into the queue.  PPP.EXE is a PM app, therefore no output from 
PPP.EXE is piped into the queue.  Fortunately, SLATTACH.EXE is a VIO 
app, so its output gets placed on the queue.  When Wait4PPP reads that 
the connection has been established out of the queue, it writes a 
message to the queue that the application is launched.  It then launches
the application and sleeps until the application terminates.  When the 
application terminates, it writes a message to the queue stating that 
the application has terminated.  After PPP.EXE terminates, control is 
passed back to AutoPPP.  It reads the queue.  If it finds that the 
application was never launched, it sends a message to the queue to tell 
Wait4PPP to terminate.  It then loops back to re-establish the 
connection and attempt to launch the program again.  If the application 
was started but no message indicates it ended, AutoPPP will attempt to 
re-establish the PPP connection without trying to launch the 
application.  Finally, if PPP.EXE terminates and the application has 
started and ended, PPP calculates the total connect time (including 
possible reconnects), subtracts this from the interval, then sleeps for 
that period of time.  When it wakes up, it repeats the process.

AutoPPP is useful for those who want to download e-mail messages or news
articles automatically (such as when they're sleeping!) such that they 
can read them at there leisure.  I hope you find AutoPPP useful.  Please
send bug reports to David Forrai <dforrai@erinet.com>.
