
                            {  SAMPLE SCRIPTS
                            {  ==============

       A typical use for scripts would be to automate your log-in to a
       UNIX or VMS system or IBM mainframe, or to get a string from the
       remote host.  You might accomplish these commonly performed tasks
       with scripts such as the ones shown below.

       Refer to the COMMAND REFERENCE section in this Update Manual for
       explanations of script commands and variables.

{    SAMPLE 1:  Automated Login to a UNIX Host
{    ------------------------------------------

              waitfor /timeout=00:30.00 /errjmp=nologin "login:"
              send SYS_USERNAME
              waitfor/timeout=00:30.00 /errjmp=nopasswd "Password:"
              send SYS_PASSWORD
              send "clear"
              nologin:
              nopasswd:
              exit

           1. {waitfor} waits until it sees the {login:} string sent by
              the remote host.  When it receives the string, {waitfor}
              terminates successfully.

           2. Then {send SYS_USERNAME} sends what the user entered into
              the "User Name" field on the "New Terminal Session" dialog
              box to the remote host.

           3. Next, the {waitfor "Password:"} command is executed.

           4. When the {password:} string comes back from the remote host,
              send {SYS_PASSWORD} is executed.  The password that the user
              typed into the "New Terminal Session" dialog box is sent,
              and the user is logged on.

           5. The script then sends a {clear} command, which clears the
              screen.

           6. The {exit} command on the last line exits the user from the
              script. The {exit} command can be used in more than one
              place in a script.

           7. If the expected string is not received from the host within
              the time specified by the {/TIMEOUT} parameter, the script
              will continue its execution at the command specified by the
              label given in the {/ERRJMP} parameter.

{    SAMPLE 2:  Automated Logon to an IBM Mainframe
{    -----------------------------------------------

       The logon screen for a TN3270 emulation requires the user name and
       password to be entered at a specific location on the screen.
       Use the {Tab} key to move to the next field on the screen. Press
       {Enter} to send the information to the remote host.

              string userprompt /length=20 /value="User"
              read /timeout=00:20.00 /errjmp=nouser userprompt
              movecursor 20,16
              send "isadora"
              sendkey TN_TAB
              send "dance"
              sendkey TN_ENTER
              goto ciao
              nouser:
              echo "Read command timed out!"
              ciao:
              exit


           1. The {userprompt} variable is defined as the string {User}.

           2. The {read} command waits for the user string to appear on
              the screen.  If the read times out, {/ERRJMP} causes the
              program to jump to the statement after the label {nouser}.
              An error message is displayed, then the script exits.

           3. If the read is successful, the next statement in the script
              will be executed.

           4. The {movecursor} command moves the cursor to row 20, column
              16.

           5. The {send} command sends the user name argument {isadora} to
              the remote host.

           6. The {sendkey TN_TAB} command sends a tab to move from the
              user name field to the password field.

           7. The second {send} command sends the password {dance} to the
              remote host.

           8. The {sendkey TN_ENTER} command sends an {Enter} code to the
              remote host.

           9. The {goto} command causes a jump to the {ciao:} line.

          10. When the {exit} command is executed, the script exits.

{    SAMPLE 3:  Get a String from a UNIX Host
{    -----------------------------------------

              string command1 /length=40
              string output /length=80
              append "ls " to command1
              append "-l" to command1
              send command1
              getstring output
              getstring output
              getstring /length = 70 output
              echo output
              exit

           1. An empty string named {command1} that has 40 characters is
              declared.

           2. Another variable string named {output} is declared with a
              length of 80 characters.

           3. "{ls }" is appended to the {command1} string.  "{-l}" is
               appended to the {command1} string, which contains the
               string "{ls }". The strings "{ls}" and "{-l}" are appended
               to the string variable {command1}.

           4. The {command1} string, or {ls -l}, is sent to the remote
              host, which will generate a long file listing.

           5. The first {getstring} command is added because everything
              you send is echoed by the remote host.  This means that the
              first string you get back from the remote host is "{ls -l}".
              Therefore, the first {getstring} command is a dummy command
              to skip the "{ls -l}" line.  Similarly, the second getstring
              command is used to skip the line after the "{ls -l}" line.

           6. The third {getstring} gets the next 70 characters of the
              next line of "{ls}" output and reads it into a variable.

           7. The contents of the output variable are then echoed to the
              screen.

           8. At this point, the script exits.

