home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / comm / Internet / IPDial / IPDial.doc < prev    next >
Text File  |  1995-07-22  |  14KB  |  402 lines

  1. IPDial - serial device communication program
  2. ============================================
  3.  
  4.  
  5. IPDial is designed especially for creating a SLIP connection via the
  6. modem to a remote host: It can dial the remote hosts number, login
  7. into the host and initilize a SLIP connection. Configuring IPDial
  8. is rather easy, as it reads its command from a textfile.
  9.  
  10.  
  11.  
  12. 1.) Disclaimer: Copyrights, (No) Warranty
  13. -----------------------------------------
  14.  
  15. This program is Copyright (C) 1994
  16.  
  17.     Jochen Wiedmann
  18.     Am Eisteich 9
  19.     72555 Metzingen
  20.     Germany
  21.  
  22.     Phone: (0049) +7123 / 14881
  23.     Mail: wiedmann@neckar-alb.de
  24.  
  25.  
  26. Permission is granted to make and distribute either verbatim and modified
  27. copies of this documentation and the program IPDial provided the copyright
  28. notice and this permission notice are preserved on all copies and the "GNU
  29. General Public License" (in the file COPYING) is distributed as well.
  30.  
  31. The author gives ABSOLUTELY NO warranty that the program described in this
  32. documentation and the results produced by them are correct. The author
  33. cannot be held responsible for ANY damage resulting from the use of this
  34. software.
  35.  
  36.  
  37. 2.) Installation
  38. ----------------
  39.  
  40. Rather simple. Just copy the program to a place in your path and edit
  41. the two files "login.script" and "hangup.script". (See Script file
  42. syntax below for details.)
  43.  
  44. You might want to enter the line
  45.  
  46.     IPDial login.script
  47.  
  48. at the beginning of AmiTCP's startnet script. Thus you get a SLIP
  49. connection by simply typing startnet.
  50.  
  51. Similar you could add the line
  52.  
  53.     IPDial hangup.script
  54.  
  55. at the bottom of the stopnet script.
  56.  
  57.  
  58. 3.) Invocation
  59. --------------
  60.  
  61. IPDial is started like this:
  62.  
  63.     IPDial SCRIPT,ECHO/S,VERBOSE/S,TERMINAL/S,DEVICE/K,PROTOCOL/K,
  64.            UNIT/K/N,BAUD/K/N,RAW/S
  65.  
  66. What IPDial does, depends on the TERMINAL switch: If this is active,
  67. the arguments DEVICE, UNIT, BAUD and PROTOCOL are used to open the
  68. serial.device. Once it is opened, the program acts as a very simple
  69. terminal program. See the "terminal" command for an explanation of
  70. the RAW argument.
  71.  
  72. If TERMINAL is omitted, the given SCRIPT is read and the commands
  73. of the script are executed line by line. (See below) The argument
  74. ECHO instructs IPDial to print the modems replies to stdout, while
  75. VERBOSE is used to show what the program's doing.
  76.  
  77.  
  78. 4.) Script file syntax
  79. ----------------------
  80.  
  81. - Any line of the script file may contain only one command. In
  82.   general command arguments are parsed with ReadArgs(), thus they
  83.   may look like CLI command line arguments: The characters "" may
  84.   surround a string which contains blanks.
  85.  
  86.   Note, that ReadArgs() treats the character '*' as an escape
  87.   sequence: Thus you have to write
  88.  
  89.     ECHO "**"
  90.  
  91.   if you want to print a single '*'.
  92.  
  93. - Empty lines or lines beginning with a semicolon are assumed to
  94.   be comments and thus ignored.
  95.  
  96. - Lines may begin with a label, an alphanumeric word followed by
  97.   a colon. Labels are ignored, except that they may be used as
  98.   destinations for "goto" instructions. (Anyone said BASIC? Yes,
  99.   it is. :-) Labels are case-sensitive.
  100.  
  101. - This is the list of possible commands:
  102.  
  103.     DEVICE NAME/A,PROTOCOL,UNIT/K/N
  104.         Opens the given device NAME with unit UNIT (Default 0).
  105.         This must be compatible to the serial.device. PROTOCOL
  106.         may be one of XONXOFF, RTSCTS, 7WIRE (Synonym for RTSCTS)
  107.         or NONE. Note that explicitly requesting a protocol
  108.         overwrites the defaults set by the Derial preferences
  109.         program.
  110.  
  111.         The DEVICE command should in general be the first command
  112.         of each script.
  113.  
  114.     SET BAUD/N/K,DATABITS/N/K,STOPBITS/N/K,BUFSIZE/N/K,PARITY/K
  115.         This command is used to modify the serial.device parameters.
  116.         Note, that these overwrite the Serial preferences. Possible
  117.         parameters are:
  118.             BAUD        baud rate
  119.             DATABITS    number of databits
  120.             STOPBITS    number of stopbits
  121.             BUFSIZE     read buffer size
  122.             PARITY      one of ODD, EVEN or NONE
  123.  
  124.     SHOWPARMS
  125.         Writes the current serial.device settings to stdout.
  126.  
  127.     ECHO ARGS/M
  128.         This will write the given ARGS to stdout. Note, that these
  129.         strings may contain patterns like \r (Carriage Return),
  130.         \n (Line Feed), \\ (Backslash :-) or \037 (octal digits,
  131.         representing the character ASCII 31.) The arguments are
  132.         separated by blanks, when they are printed.
  133.  
  134.         Sequences like $VAR or ${VAR} will be replaced with the
  135.         value of the environment variable VAR. (Empty string, if
  136.         VAR doesn't exist.) Use $$ to get the $ character itself.
  137.         Note, that $VAR will only work, if the name VAR consists
  138.         of alphanumeric characters only and the name is separated
  139.         with a non-alphanumeric character from the following. For
  140.         example, $VAR+NAME means $VAR and not $VAR+NAME. On the
  141.         other hand $VARNAME means $VARNAME and not $VAR. (Obvious
  142.         reason. :-)
  143.  
  144.         Note that ECHO does not write any Line Feeds or Carriage
  145.         Returns unless you explicitly request it with the respective
  146.         patterns.
  147.  
  148.     SEND ARGS/M
  149.         This command sends the given strings to the serial.device
  150.         using DoIO(). These strings may contain the same patterns
  151.         as described with the ECHO command. Unlike ECHO the arguments
  152.         aren't separeted by blanks.
  153.  
  154.         See ECHO for a description of patterns that may be inserted
  155.         into SEND arguments.
  156.  
  157.     DELAY SECS/A
  158.         Delays the given number of seconds. The value may contain a
  159.         fraction of seconds which is rounded to ticks: 0.5 means
  160.         25 ticks.
  161.  
  162.     WAIT TIMEOUT/K/N/A,ARGS/M
  163.         This command waits until either one of the given strings
  164.         is read from the serial.device or the number of seconds
  165.         given by TIMEOUT has gone.
  166.  
  167.         A variable called STATUS indicates what happened: It contains
  168.         either -1 for timeout or the number of the string that was
  169.         read, beginning with 0. This variable may be used by the
  170.         ON statement.
  171.  
  172.         WAIT arguments are parsed like ECHO arguments. (See above.)
  173.  
  174.     SCAN FORMAT/A,GLOBAL/S,SAVE/S
  175.         Used to scan the buffer read by the last "WAIT" command for
  176.         certain words. These may be used set environment variables.
  177.         The format string may contain the following patterns:
  178.  
  179.             %{WORD%} Ignores any characters until WORD is found in
  180.                      the buffer. Use %% to insert the '%' character
  181.                      into WORD.
  182.             ' '      Ignores any number (including 0) and kind (blank,
  183.                      tab, line feed, carriage return, form feed) of
  184.                      white space characters.
  185.             %[VAR%]%(SUFFIX%)
  186.                      Reads the next word from the buffer until
  187.                      the first white space character and stores it into
  188.                      the environment variable VAR.
  189.                      The optional SUFFIX is a sequence of characters
  190.                      to be removed from the end of the word.
  191.             Any other characters in the format string are simply
  192.             ignored.
  193.  
  194.         Usually environment variables are local (for IPDial and child
  195.         processes only). Use the GLOBAL and SAVE keywords to store
  196.         them in ENV: and ENVARC:, respectively. Note, that SAVE
  197.         implies GLOBAL.
  198.  
  199.         Note, that you can use the SCAN command more than once on the
  200.         same buffer.
  201.  
  202.         Example:
  203.             SCAN "%{Your IP address is%} %[IPADDRESS]%%(.%)"
  204.  
  205.             Scans the buffer for a sentence like
  206.  
  207.                 Your IP address is 145.2.1.34.
  208.  
  209.             and stores the value 145.2.1.34 into the variable
  210.             IPADDRESS. Note, that the character '.' is removed.
  211.  
  212.         The SCAN command stores the number of created environment
  213.         variables in the STATUS variable, which can later be used
  214.         by the ON command. Note, that the value -1 is never stored
  215.         in the STATUS variable, you have to use a dummy label in the
  216.         ON command.
  217.  
  218.     ON STATUS GOTO LABELS/M
  219.         There's currently only one version of the ON command.
  220.         An ON command must follow a WAIT or SCAN command. ON reads
  221.         the value of the STATUS variable and jumps to the first
  222.         label, if STATUS is -1, to the second label, if STATUS is 0
  223.         and so on. A typical use of WAIT/ON looks like this:
  224.  
  225.             WAIT TIMEOUT=10 "Login:" "Busy"
  226.             ON STATUS GOTO TimeOut Login Busy
  227.  
  228.             TimeOut:
  229.             ECHO "Timeout happened, aborting.\n"
  230.             EXIT 10
  231.  
  232.             Busy:
  233.             ECHO "Remote busy, delaying...\n"
  234.             DELAY 25
  235.             ECHO "Trying again.\n"
  236.             GOTO DialAgain
  237.  
  238.             Login:
  239.             ;   Execute the login procedure
  240.  
  241.         You do not need to supply a label for any wait string:
  242.         This will suppress jumping and instead continue on
  243.         the next line.
  244.  
  245.     GOTO LABEL/A
  246.         Jumps to the given label
  247.  
  248.     TERMINAL NOECHO/S,RAW/S,EOF
  249.         Enters terminal mode: What you enter at the keyboard will
  250.         be sent to the serial.device and likewise the program will
  251.         display any input from the serial.device to you. The
  252.         TERMINAL command will be finished, if you enter EOF
  253.         (Ctrl-\).
  254.  
  255.         The NOECHO and EOF options can be used to enter a password,
  256.         if you don't like to include it into your login file: NOECHO
  257.         makes your input invisible and the EOF string terminates
  258.         terminal mode as soon, as you type in the first character
  259.         of the string. Thus you can do something like
  260.  
  261.             WAIT TIMEOUT=10 "Password:"
  262.             ON STATUS GOTO TimeOut Password
  263.  
  264.             Password:
  265.             ECHO "Enter login password: "
  266.             TERMINAL EOF="\r" NOECHO
  267.  
  268.         Usually you can send only complete lines to the modem,
  269.         especially this means that you have all editing capabilities
  270.         of the shell available. This is not the case in RAW mode:
  271.         Every character you type will be sent immediately to the
  272.         modem without any buffering or conversions.
  273.  
  274.         Notes:
  275.  
  276.             - You probably must put your modem into NOECHO mode too,
  277.               if you use the "terminal" command for entering a password.
  278.             - NOECHO mode implies RAW mode
  279.  
  280.     SYSTEM ARGS/M
  281.         Executes the command given by ARGS. The arguments will be
  282.         parsed like ECHO and SEND arguments (you may insert
  283.         \ and $ patterns) and separated by blanks. The resulting
  284.         string will be executed. For example
  285.  
  286.             SYSTEM "Echo" "Hello!"
  287.  
  288.         will execute the command "Echo Hello!" and not "EchoHello!".
  289.  
  290.     EXIT RESULT
  291.         Terminates the program, returns the given RESULT. (Defaults
  292.         to 0.)
  293.  
  294.     SETVAR NAME/A,VALUE/A,LOCALONLY/S,GLOBAL/S,SAVE/S
  295.         Sets environment variable NAME to VALUE. If you set the
  296.         GLOBAL switch, your variable will be set in ENV: and not
  297.         in the programs local environment. The SAVE switch forces
  298.         copying to ENVARC:.
  299.  
  300.         Note, that SAVE implies GLOBAL.
  301.  
  302.   Commands are case-insensitive.
  303.  
  304. See the scripts Login.IPDial and Hangup.IPDial as examples.
  305.  
  306.  
  307. 5.) How to create a script file?
  308. --------------------------------
  309.  
  310. Enter the terminal mode. You should now be able to type commands like
  311.  
  312.     ATZ<return>
  313.  
  314. If all goes well, the modem should reply
  315.  
  316.     ATZ
  317.     OK
  318.  
  319. provided, that it is in echo mode. Now try to dial into your remote
  320. host with something like
  321.  
  322.     ATDP07071927920<return>
  323.  
  324. If the remote host's phone line isn't busy, you should eventually
  325. see the remote's login message. This message should explain what
  326. to do. Try it and log out. Now have a look at Login.IPDial, in
  327. general you should understand how to edit it.
  328.  
  329.  
  330. 6.) Recommended Usage
  331. ---------------------
  332.  
  333. Each time you reconfigure AmiTCP, it will destroy your startnet
  334. script. Thus it is not a good idea to modify the startnet script.
  335. Instead create a scriptfile, say "neton", which could look as
  336. follows:
  337.  
  338.     .key ECHO/S,VERBOSE/S
  339.  
  340.     IPDial Work:lib/Login.script <ECHO> <VERBOSE>
  341.     If NOT WARN
  342.         startnet
  343.     EndIf
  344.  
  345. Likewise, create a script "netoff" like this
  346.  
  347.     stopnet
  348.     IPDial Work:lib/Hangup.IPDial
  349.  
  350. And, from now on, use "neton" and "netoff" instead of "startnet"
  351. and "stopnet".
  352.  
  353.  
  354. 7.) History
  355. -----------
  356.  
  357. I never expected IPDial to become a little bit popular. However,
  358. the number of questions and/or enhancement requests forced
  359. new versions: This is 1.6 now. Time for a history, as people
  360. might like to know what's different.
  361.  
  362. V 1.1   23.11.94        Initial version
  363.  
  364. V 1.2   27.02.95        Added terminal mode
  365.                         Now using ReadArgs() for command line parsing.
  366.  
  367. V 1.3   09.03.95        Added environment variable aupport to "send"
  368.                         command. Added unit support.
  369.  
  370.                         Suggested by Quarvon (Jürgen Lang)
  371.  
  372. V 1.4   21.04.95        Added "system" command.
  373.  
  374.                         Suggested by Gutgolf (Michael Bauer)
  375.  
  376.                         Added environment variable support to "echo"
  377.                         command. Terminal mode now converts
  378.                         LF to CR/LF, so that modem
  379.                         recognizes commands.
  380.                         (Let's hope, that will still
  381.                         work for entering passwords. :-(
  382.  
  383. V 1.5   30.04.95        Added "scan" command.
  384.  
  385. V 1.6   26.06.95        "delay" command supporting ticks; ParseString()
  386.                         supporting octal characters; "wait" command using
  387.                         ParseString()
  388.  
  389.                         Suggested by Will Bow.
  390.  
  391.                         Fixed bug in SerialSend():
  392.                         *.io_Device = *.io_Unit
  393.  
  394. V 1.7   21.07.95        Added NOECHO, RAW and EOF options to "terminal"
  395.                         command.
  396.  
  397.                         Suggested by Klaus Heinz
  398.  
  399.                         Added BAUD option to command line.
  400.  
  401.                         Added "setvar" command.
  402.