ecu - SCO XENIX V/{2,3}86 Extended CU part 40/47

Warren Tucker wht at tridom.uucp
Thu Oct 12 05:17:41 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 40 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file doc/_p_sfunc.txt continued
#
CurArch=40
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file doc/_p_sfunc.txt"
sed 's/^X//' << 'SHAR_EOF' >> doc/_p_sfunc.txt
XIf no connection exists, the function returns null.
X
X.*s 3 "%time"
X
Xusage: %time
X
XThis function returns the current time in the form 'hh:mm'.
X
X.*s 3 "%times"
X
Xusage: %times
X
XThis function returns the current time in the form 'hh:mm:ss'.
X
X.*s 3 "%tty"
X
Xusage: %tty
X
XThis function returns the console tty name in the form "/dev/ttynn".
X
SHAR_EOF
echo "File doc/_p_sfunc.txt is complete"
chmod 0644 doc/_p_sfunc.txt || echo "restore of doc/_p_sfunc.txt fails"
echo "x - extracting doc/_proc.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/_proc.txt &&
X.*s 1 "Procedure Language"
X
XSample procedures are shown in the companion document 'samplproc.man'.
X
X
X.so _p_param.txt
X
X.so _p_cmd.txt
X
X.so _p_ifunc.txt
X
X.so _p_sfunc.txt
X
SHAR_EOF
chmod 0644 doc/_proc.txt || echo "restore of doc/_proc.txt fails"
echo "x - extracting doc/_startup.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/_startup.txt &&
X.*s 1 "Starting the Program"
X
X.*s 2 "Simple Startup - Initial Setup Menu"
X
XECU may be started in a number of ways through use of
Xcommand line switches, but the easiest is to enter
X.DS I
Xecu
X.DE
Xby itself.
XIn this case, the screen is cleared
Xand the folowing screen will be presented.
X
X
X.DS L
X
X  .--[ ecu 1.96 Copyright 1986,1989, W. Tucker ]-----------------.
X  |                                                              |
X  |  Name/phone number to call: ___________________              |
X  |                                                              |
X  |                                                              |
X  |  tty: /dev/tty1a                                             |
X  |                                                              |
X  |  duplex: F  baud: 2400   parity:N  (data bits 8)             |
X  |  Add NL to transmitted CR: N                                 |
X  |  Add NL to received CR:    N                                 |
X  |                                                              |
X  |                                                              |
X  |   TAB:next ^B:prev END:proceed ^D:phone dir  ESC:quit ecu    |
X  `- logical phone directory entry, phone number or empty -------'
X
X
X.DE
X
X.*s 3 "Name/Phone Number Field"
X
XIf a dialing directory has been configured,
Xa literal phone number need not be entered.
XHowever, on your first invocation,  you'll very likely have
Xno directory.  Therefore, you have three options:
X
X.DS I
X1.  Enter a literal telephone number, (e.g. 18005551212).
X    Hyphens and open and close parentheses may also
X    be entered.
X
X2.  Press ENTER to skip the 'Name/phone' field and enter
X    ^D to enter the telephone directory to enter your
X    first directory entry.
X
X3.  Press END to enter interactive mode and use the Dial
X    interactive command to dial a literal telephone num-
X    ber or to enter the dialing directory.
X.DE
X
X.*s 3 "Other Fields"
X
XThe 'tty' field may be used to select an
Xoutgoing line
Xother than the default
X/dev/tty1a.
XNote:  only the last two characters of the tty name
Xneed be entered.  The remainder of the tty name
Xis assumed to be '/dev/tty'.
X
XThe 'duplex' field may be used to select a
Xduplex value other than the default 'F' (full).
X
XThe 'baud' field may be used to select a
Xbaud rate value other than the default 2400.
X
XThe 'parity' field may be used to select a
Xparity value other than the default 'N' (none).
X
X
XThe 'Add NL to transmitted CR' and 'Add NL to received CR'
Xfields are usually left defaulted to 'N' (no).  If you
Xwill be communicating with a terminal (with a human), you
Xwill usually need to set both of these fields to 'Y' as
Xwell as to select 'H'alf duplex.
X
X.*s 3 "Special Characters"
X
XSpecial keyboard characters while filling in the
Xstartup screen are:
X
X
X.DS I
X TAB    move to next field ... if nothing typed in
X        the field, do not disturb contents
X
X ^B     back up to previous field
X
X END    proceed with session, dialing remote if
X        logical directory entry name or literal
X        telephone number enetered
X
X ^D     enter phone directory
X
X ESC    quit ecu without any communications
X.DE
X
X.*s 2 "Command Line Arguments and Switches"
X
XECU can be started in a number of ways:
X
X.DS I
Xecu [-lxx] [-b<baud>] [-h] [-e|-o] [-t] <tel-number>
Xecu [-lxx] [-b<baud>] [-h] [-e|-o] [-t]
Xecu [-t] <logical>
Xecu [-lxx] [-b<baud>] [-h] [-e|-o] [-d] -p <proc> [<arg> ...]
X.DE
X
X.*s 3 "-l"
X
XWhen ECU starts up, it normally chooses a line as described later
Xin the section titled "Choosing a Dialout Line".
XSpecifying the -l switch can suggest that the program
Xchoose a specific line.  The argument to the switch is the
Xlast two charcters of the ttyname; e.g., "-l1a".
X
X.*s 3 "-f"
XNormally, ECU starts up in the full duplex mode.
XIf half duplex is desired, the
X.B
X-f switch
X.R
Xis used.
X
X.*s 3 "-e, -o"
X
XNormally, ECU starts up with 8 data bits and no parity.
XIf even parity is desired, the
X.B
X-e switch
X.R
Xis specified.
XIf odd parity is desired, the
X.B
X-o switch
X.R
Xis specified.
X
XThese switches
X
X.*s 3 "-p <procname>"
X
XThe 
X.B
X-p switch
X.R
Xcauses ECU to execute the procedure <procname> ("<procname>.ep")
Ximmediately.  Such a procedure is termed the
X.B
Xinitial procedure.
X.R
XAll non-switch arguments after <procname> are passed as arguments
Xto the initial procedure (see the descriptions of the
Xinteger function
X.B %argc
Xand the string function
X.B %argv ).
X
X.*s 3 "-d"
X
XThe
X.B
X-d switch
X.R
Xinstructs ECU to "die" (terminate with error status) if
Xany specified initial procedure fails.  This switch ensures a batch
XECU execution will hang up any connection and terminate if
Xa procedure error occurs.
X
XAbsence of the
X.B
X-d switch
X.R
Xcauses ecu (upon any completion of the
Xinitial procedure) to enter the 1) interactive mode if a line
Xwas successfully attached by the procedure or 2) the setup menu
Xif not line was attached.
X
X.*s 3 "-t"
X
XThe
X.B
X-t switch
X.R
Xinstructs ECU to map incoming and outgoing carriage
Xreturns to carriage return/line feed pairs.
XThis is helpful if the remote connection will be to a
Xterminal with a human operator.  Use of the
X.B
X-h switch
X.R
Xis probably also necessary.
X
X.*s 2 "Environment Variables"
X
XPrior to starting ECU, it is useful, but not necessary,
Xto establish two environment variables, ECUPROMPT and ECUHELP.
X
X.*s 3 "ECUPROMPT"
X
XThe ECUPROMPT environment variable determines the prompt printed
Xby ECU when the interactive command key ("HOME") is pressed.
XWhen you first run ECU, try setting it to your name, e. g.,
X.DS I
Xsetenv ECUPROMPT Ralph    if you use csh
X
XECUPROMPT=Ralph           if you use sh, ksh, etc.
Xexport ECUPROMPT
X.DE
XThen, when you see how it used, you may wish to
Xestablish a more permanent choice in your .login or .profile.
X
X.*s 3 "ECUHELP"
X
XOrdinarily, ECU looks for interactive command help information
Xin "/usr/lib/ecu/ecuhelp.data".
XThe ECUHELP environment may be set to the complete
Xpathname of the ecu help file if an alternate file
Xis to be used.
X
XThe help file is explained later in the section
Xtitled "Online Command Dictionary".
X
SHAR_EOF
chmod 0644 doc/_startup.txt || echo "restore of doc/_startup.txt fails"
echo "x - extracting doc/_tech.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/_tech.txt &&
X.*s 1 "Technical Notes"
X
XECU is written in Microsoft/SCO XENIX System V C.  Full use
Xis made of function prototyping for ECU functions and external
Xlibrary functions.  The source consists of 32,000 lines of source
Xfiles (731000 bytes) and 2500 lines of header files (73000 bytes).
XThe output of "size" for a -M3 version:
X
X.DS I
Xtext     data    bss     dec      hex
X136500 + 33824 + 62800 = 233124 = 0x38ea4
X.DE
X
SHAR_EOF
chmod 0644 doc/_tech.txt || echo "restore of doc/_tech.txt fails"
echo "x - extracting doc/_top.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/_top.txt &&
X
X.de *s
X.H "\\$1" "\\$2" \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
X.br
X..
X.po 4
X.ll 7.2i
X.ls 1
X.nh
X.tp
X.sp 2i
X.ft B
X.ce 10
XECU
X
X(Extended Call Utility)
X.ce 0
X.sp 1i
X.ce 100
XPersonal Communications Package
Xfor XENIX System V
X.ce 0
X.ft P
X.sp 2i
X.lp
XCopyright 1986, 1989, Warren H. Tucker, III. All rights reserved.
X.sp 1i
X.ce 100
XTechnical Description
XRevision 0.50 (ecu 2.11)
XPRELIMINARY
X\n(mo/\n(dy/\n(yr
X.ce 0
X.ls 1
X.PH "'ECU Technical Description''%'"
X.PF "'Copyright (C) 1989, Warren H. Tucker''\n(mo/\n(dy/\n(yr'"
X.nr si 2n
X.nr Cl 9
X.nr Ej 1
X.nr U 1
X.SA 1
X.ul
X.bp 1
X
SHAR_EOF
chmod 0644 doc/_top.txt || echo "restore of doc/_top.txt fails"
echo "x - extracting doc/ecu.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/ecu.txt &&
X.so _top.txt
X
X.so _intro.txt
X
X.so _basic.txt
X
X.so _features.txt
X
X.so _startup.txt
X
X.so _icmd.txt
X
X.so _proc.txt
X
X.so _hdb.txt
X
X.so _tech.txt
X
X.so _end.txt
SHAR_EOF
chmod 0644 doc/ecu.txt || echo "restore of doc/ecu.txt fails"
echo "x - extracting doc/samplproc.man (Text)"
sed 's/^X//' << 'SHAR_EOF' > doc/samplproc.man &&
X
X
X
X
X
X
X
X
X
X
X
X
X
X                        Sample ECU Procedures
X
X
X
X
X         Copyright 1989 Warren H. Tucker, III. All Rights Reserved
X
X
X
X
X
X
X
X                           June 25, 1989
X
X
X
X
X
X
X
X
X    bsd_uname.ep
X
X
X    1   #  CHK=0xD3AA
X    2   #--------------------------------------------------------------
X    3   # bsd_uname.ep - get remote username from bsd system
X    4   # return: $s0 = username
X    5   #         $i0 = 1 if success, else 0
X    6   #--------------------------------------------------------------
X    7   #+:EDITS:*/
X    8   #:06-25-1989-13:56-wht-new do command syntax
X    9   #:06-25-1989-12:33-wht-new if/while syntax
X   10   #:06-22-1989-13:30-wht-creation
X   11
X   12       set $s0='whoami'    # send command
X   13       do 'oneline'        # get $s0=username
X   14       ifi $i0 == 0        # we bombed?
X   15       {
X   16           set $i0=%colors; color red
X   17           echo 'bsd_uname: get user name failed'
X   18           icolor $i0
X   19           $i0 = 0
X   20       }
X   21
X
X
X    oneline.ep
X
X
X    1   #  CHK=0x4652
X    2   #--------------------------------------------------------------
X    3   # oneline.ep
X    4   #
X    5   # send command in $s0, expecting a one line response
X    6   # and a csh prompt ending in '% '
X    7   #
X    8   # returns: $s0 = one line response in $s0 if success
X    9   #          $i0 = 1 if success, else 0
X   10   #
X   11   # destroys: $i2
X   12   #--------------------------------------------------------------
X   13   #+:EDITS:*/
X   14   #:06-25-1989-13:56-wht-new do command syntax
X   15   #:06-25-1989-12:33-wht-new if/while syntax
X   16   #:06-22-1989-13:30-wht-creation
X   17
X   18       $i2 = %colors
X   19       color gray
X   20       send $s0                        # send command
X   21       lookfor -e %chr(0x0A) 50        # scan command echo
X   22       ifi $i0 == 0 icolor $i2;return  # if not found, return
X   23       lgets -e $s0 500 5 '\n'         # get one line response
X   24       lookfor '% ' 50                 # get prompt, don't echo
X   25       # $i0 = 1 if prompt, else 0
X   26       icolor $i2
X
X
X
X    rz_update.ep Page 1
X
X
X    1   #  CHK=0x69C9
X    2   #--------------------------------------------------------------
X    3   # rz_update.ep - update local directory
X    4   #
X    5   # parameters:
X    6   # %argv(1) = remote directory to copy from
X    7   # %argv(2) = local directory to copy to
X    8   # %argv(3) = file list to get
X    9   # %argv(4) = remote username needed, if any, else null
X   10   #            if %argv(4) not null, %argv(4)+".ep" must
X   11   #            exist to su to remote
X   12   #
X   13   # variable usage
X   14   # $i30 color settings at entry to procedure
X   15   # $i31 true if su occurred
X   16   # $i32 return code
X   17   # $s30 original working directory
X   18   # $s31 remote username we started with before su
X   19   # $s32 remote directory we started with
X   20   #--------------------------------------------------------------
X   21   #+:EDITS:*/
X   22   #:06-25-1989-13:56-wht-new do command syntax
X   23   #:06-25-1989-12:33-wht-new if/while syntax
X   24   #:06-22-1989-13:30-wht-creation
X   25
X   26       $i30=%colors # get colors at entry
X   27       $i31=0       # have not su'd yet
X   28       $i32=0       # normal return code
X   29
X   30   # check to make sure we are connected
X   31       ifi %conn == 0
X   32       {
X   33           color red; echo 'not connected to anyone!'
X   34           goto SORRY
X   35       }
X   36       color lt_blue;  echo 'Connected to '+%rname
X   37
X   38   # save local current directory and change to target
X   39       $s30=%dir
X   40       color brown
X   41       ifs $s30 == %argv(2)
X   42           echo -n 'local directory already '
X   43       else
X   44       {
X   45           cd %argv(2)
X   46           echo -n 'local directory set to '
X   47       }
X   48       color yellow; echo %dir
X   49
X   50   # make sure remote username ok
X   51       ifs %argv(4) == '' goto REMOTE_CD # if any remote username
X   52       do 'bsd_uname'          # get $s0=username
X   53       ifi $i0 == 0 goto SORRY # test failure
X   54       $s31 = $s0              # save original remote username
X   55       ifs $s0 != %argv(4)
X   56       {                       # need to su
X
X
X   rz_update.ep Page 2
X
X
X   57           color brown
X   58           echo -n 'remote username '
X   59           color yellow
X   60           echo -n $s0
X   61           color brown
X   62           echo ' ... su to '+%argv(4)+' now'
X   63           color gray
X   64           do %argv(4)         # call proc, which calls su.ep
X   65           lookfor '% ' 50     # su leaves prompt in buffer: swallow
X   66           do 'bsd_uname'      # make sure we su'd
X   67           ifi $i0 == 0 goto SORRY
X   68           ifs $s0 != %argv(4)     # failed to su?
X   69           {
X   70               color red;echo 'su to '+%argv(4)+' failed'
X   71               goto SORRY
X   72           }
X   73           $i31 = 1 #remember we su'd
X   74       }   # now we are proper username on remote
X   75
X   76   # establish proper remote working directory
X   77   REMOTE_CD
X   78       color gray
X   79       $s0 = 'pwd';do 'oneline'    # save old remote ...
X   80       $s32 = $s0                  # ... directory in $s32
X   81       ifs $s32 != %argv(1)        # if cd needed, do it
X   82       {
X   83           send 'cd '+%argv(1)     # remote cd
X   84           lookfor -e '\n' 50      # echo command
X   85           lookfor '% ' 50         # swallow prompt
X   86           $s0 = 'pwd'
X   87           do 'oneline'            # make sure we got there
X   88           ifs $s0 != %argv(1)     # dir change failed
X   89           {
X   90               color red;echo 'remote cd failed'
X   91               goto SORRY;
X   92           }
X   93       }
X   94       color brown;  echo -n 'remote directory '
X   95       color yellow; echo -n %argv(1)
X   96       color brown;  echo    ' ... starting transfer now'
X   97
X   98   # transfer files
X   99       color lt_blue
X  100       send 'sz -n -f '+%argv(3)
X  101       lookfor -e '\n' 50  # echo remote command
X  102       ifi $i0 == 0        # command failed?
X  103       {
X  104           color red; echo 'sz command failed or garbled echo'
X  105           goto SORRY
X  106       }
X  107       color brown
X  108       echo 'waiting for sz to start'
X  109       nap 10
X  110       color gray
X  111       lookfor '**'+%chr(0x18)+'B' 150 # wait 15 secs for start
X  112       ifi $i0 == 0    # command failed
X
X
X  rz_update.ep Page 3
X
X
X  113       {
X  114           color red; echo 'sz protocol failure or trigger garbled'
X  115           goto SORRY
X  116       }
X  117       icolor $i30     # restore colors at entry
X  118       rz
X  119       ifi $i0 != 0    # whoops
X  120       {
X  121           color red; echo -n '\nTRANSFER FAILED ... '
X  122           ifi $i0 == 0x100 echo 'interrupt'
X  123           ifi $i0 != 0x100 echo 'termination status '+%itos($i0,04d)
X  124           goto SORRY
X  125       }
X  126       lookfor '% ' 50         # swallow prompt
X  127       goto RETURN
X  128
X  129   SORRY # whoops
X  130       color red;echo 'rz_update failed ... sorry'
X  131       $i32 = 1    # return error
X  132
X  133   RETURN
X  134       echo ''
X  135       color brown;  echo -n 'remote user name '
X  136       color yellow
X  137       ifi $i31 != 0           # we su'd
X  138       {
X  139           send -n %chr(0x04)  # will force a new prompt from remote
X  140           echo -n $s31
X  141           color brown;  echo ' restored (sent ^D to '+%argv(4)+' shell)'
X  142           lookfor '% ' 50     # swallow prompt
X  143       }
X  144       else
X  145           color brown;  echo 'unchanged'
X  146
X  147       ifs $s32 != %argv(1)    # if we did a remote cd
X  148       {
X  149           send 'cd '+$s32     # restore original
X  150           lookfor '\n'
X  151           color brown;  echo -n 'remote working directory '
X  152           color yellow; echo -n $s32
X  153           color brown;  echo    ' restored'
X  154       }
X  155       else
X  156       {
X  157           send ''             # spark a prompt
X  158           color brown;  echo -n 'remote working directory '
X  159           color yellow; echo -n $s32
X  160           color brown;  echo    ' unchanged'
X  161       }
X  162
X  163       ifs $s30 != %dir    # restore original directory
X  164       {
X  165           cd $s30
X  166           color brown;  echo -n 'local working directory '
X  167           color yellow; echo -n $s30
X  168           color brown;  echo    ' restored'
X
X
X  rz_update.ep Page 4
X
X
X  169       }
X  170
X  171       icolor $i30  # restore colors at entry
X  172       echo ''
X  173       return $i32  # return error code (bomb procedure if error)
X
X
X
X    su.ep Page 1
X
X
X    1   #  CHK=0x2846
X    2   #+---------------------------------------------------------
X    3   # su.ep - su <username> <password>
X    4   # destroys $i2
X    5   #----------------------------------------------------------
X    6   #+:EDITS:*/
X    7   #:06-25-1989-13:56-wht-new do command syntax
X    8   #:06-25-1989-12:33-wht-new if/while syntax
X    9   #:06-16-1989-18:12-wht-creation
X   10
X   11       send 'su '+%argv(1)
X   12       lookfor -e 'word:' 50
X   13       send %argv(2)
X   14       lookfor -e %chr(0x0A) 50
X   15       nap 20
X   16       send 'source ~wht/.cshrc'
X   17       lookfor -e '% ' 70
X   18       ifs %argv(1) == 'scm' send 'cd';lookfor -e %chr(0x0A) 50; return
X   19       send ''
X   20       lookfor -e %chr(0x0A) 50
X
X
X
X    unixlogin.ep Page 1
X
X    1   #  CHK=0x0622
X    2   #+-----------------------------------------------------------------
X    3   #  unixlogin.ep - ecu UNIX login procedure
X    4   #  Copyright 1989 Warren H. Tucker, III. All Rights Reserved
X    5   #
X    6   # %argv(1) = remote name
X    7   # %argv(2) = user name
X    8   # %argv(3) = password
X    9   # %argv(4) = term type
X   10   # %argv(5) = optional number of breaks needed
X   11   #+-----------------------------------------------------------------
X   12   #+:EDITS:
X   13   #:07-09-1989-23:50-wht-add breaks
X   14   #:06-28-1989-19:36-wht-use named variables
X   15   #:06-25-1989-13:56-wht-new do command syntax
X   16   #:06-25-1989-12:33-wht-new if/while syntax
X   17   #:06-23-1989-19:46-wht-improved hayes dialer
X   18   #:06-19-1989-22:50-wht-use while and if statements
X   19   #:06-14-1989-15:58-wht-add login capability when already connected
X   20   #:06-11-1989-23:37-wht-creation
X   21   
X   22       mkvar $i_csave,$i_ltimeout,$i_retries
X   23   
X   24       $i_csave = %colors
X   25       $i_ltimeout = 30 # 3 seconds wait for first login prompt
X   26       $i_retries=3
X   27   
X   28       color red;    echo -n '\nauto-logon to '
X   29       color yellow; echo -n %argv(1)
X   30       color red;    echo    ' on '+%date+' at '+%time+'\n'
X   31   
X   32       ifi %argc < 5   # not enough args
X   33       {
X   34           color red
X   35           echo %argv(0)+' needs 5 arguments (got '+%itos(%argc)+')'
X   36           goto SORRY1
X   37       }
X   38       mkvar $i_breaks
X   39       ifi %argc > 5 $i_breaks = %stoi(%argv(5))
X   40   
X   41       ifi %conn == 0 goto DIAL
X   42   
X   43       ifs %rname == %argv(1)
X   44       {
X   45           color brown;  echo -n 'already connected to '
X   46           color yellow; echo    %rname
X   47           send ''
X   48           goto SEND_BREAKS
X   49       }
X   50   
X   51   HANGUP
X   52       ifi %conn <> 0 echo 'hanging up on '+%rname; hangup
X   53   
X   54   DIAL
X   55       color green
X   56       dial %argv(1); set $i1=$i0 #save dial result in $i1
X
X
X
X    unixlogin.ep Page 2
X
X   57       ifi $i1 == 2 color red; echo 'interrupted'; goto SORRY
X   58       ifi $i1 != 0 goto SORRY
X   59   
X   60   # send breaks?
X   61   SEND_BREAKS
X   62       ifi $i_breaks > 0
X   63       {
X   64           whilei $i_breaks > 0
X   65           {
X   66               color blue; echo 'sending break to remote'
X   67               nap 20
X   68               lbreak
X   69               $i_breaks = $i_breaks - 1
X   70           }
X   71           flush
X   72           lookfor '\n' 50
X   73       }
X   74   
X   75   # get login prompt from remote UNIX system: "login: "
X   76   GET_LOGIN_PROMPT
X   77       set $i_retries = 6      # retry count
X   78   
X   79   GET_LOGIN_PROMPT_RETRY      # retry get login prompt
X   80       whilei $i_retries > 0
X   81       {
X   82           color cyan
X   83           lookfor -e 'login: ' $i_ltimeout
X   84           ifi $i0 == 1 break          # go send username
X   85           $i_ltimeout = 50            # later login waits 5 secs
X   86           set $i_retries = $i_retries - 1 # read and decrement retry
X   87           ifi $i_retries == 0 goto SORRY  # but not if retry exhausted
X   88           color yellow
X   89           echo 'sending prompt stimulus'
X   90           color green
X   91           send '' # kick off another login prompt
X   92       }
X   93   
X   94   # give username to remote
X   95   SEND_USERNAME
X   96       nap 3 # system not always ready when it says
X   97       send %argv(2)
X   98   
X   99   # get password prompt: "Password:"
X  100   GET_PASSWORD_PROMPT
X  101       lookfor -e 'Password:' 50
X  102       ifi $i0 != 1        # did not find 'Password: '
X  103       {
X  104           send ''
X  105           gotob GET_LOGIN_PROMPT_RETRY
X  106       }
X  107   
X  108   # send the password
X  109       nap 3 # system not always ready when it says
X  110       send %argv(3)
X  111   
X  112   # get term type prompt "TERM = (ansi) "
X
X
X    unixlogin.ep Page 3
X
X
X  113   # also handle incorect login retry and 'Sorry' hangup indication
X  114   GET_TERMTYPE_PROMPT
X  115       ifs %argv(4) == ''  # if no term type, don't wait for prompt
X  116       {
X  117           $i0 = 0         # return good status
X  118           goto SETCOLOR_AND_RETURN_STATUS
X  119       }
X  120       lgets -re $s0 100 50 ') '
X  121       ifi %instr($s0,'Sorry') > 0 hangup;goto SORRY
X  122       ifi %instr($s0,'incorrect') > 0     # exhausted retry?
X  123       {
X  124           set $i_retries=$i_retries-1
X  125           ifi $i_retries > 0 goto SEND_USERNAME
X  126           goto SORRY
X  127       }
X  128   # send terminal type
X  129       ifi %instr($s0,'TERM') < 0
X  130           lookfor -e ') ' 30
X  131       send %argv(4)
X  132       lookfor -e '\n' 50
X  133       set $i0=0
X  134       goto SETCOLOR_AND_RETURN_STATUS
X  135   
X  136   # procedure failed
X  137   SORRY
X  138       echo ''
X  139       color red
X  140       echo '....... sorry'
X  141       set $i0=0
X  142       goto SETCOLOR_AND_RETURN_STATUS
X  143   
X  144   SORRY1
X  145       echo ''
X  146       color red
X  147       echo '....... sorry'
X  148       set $i0=1
X  149   
X  150   SETCOLOR_AND_RETURN_STATUS
X  151       icolor $i_csave
X  152       ifi $i0 == 0 ifi %conn !=0 prompt %rname+' >'
X  153       return $i0
X  154   
X  155   # vi:set tabstop=4 shiftwidth=4:
X
X
X
X
X    ftst.ep
X
X    1   #------------------------------------------------------------
X    2   #  ftst.ep - test ecu procedure file functions
X    3   #------------------------------------------------------------
X    4
X    5    ptrace off         # turn off trace mode
X    6    fdel 'ftst.log'    # kill any previous file
X    7    plog 'ftst.log'    # turn on logging
X    8
X    9    echo ''
X   10    echo 'ftst '+%date+' '+%time
X   11    echo ''
X   12
X   13    ptrace on                  # turn on trace mode
X   14
X   15    set $s10 = '/tmp/ftst.tmp' # temp file name
X   16    fdel $s10                  # test proc trace warning
X   17    fopen -w 0 $s10            # open file 0 for write
X   18    set i0=%ftell(0)           # should produce 0
X   19    fputs 0 'abcdefghijk'      # put a line in the file
X   20    set i0=%ftell(0)           # should produce 12
X   21    fclose 0 n                 # close the file
X   22
X   23    fopen -r 0 $s10    # open again for reading
X   24    fgets 0 $s0        # should produce 'abcdefghijk'
X   25    fseek 0 0          # rewind to read again
X   26    fgets 0 $s0        # should produce 'abcdefghijk'
X   27    fgets 0 $s0        # should produce null string
X   28    set $i0=%fmode(0)  # test file mode function
X   29    fclose 0           # close the file
X   30
X   31    fchmod 'rw-rw-r-x' $s10 # set mode using string
X   32    set $i0=%fmode($s10)
X   33
X   34    fchmod 0777 $s10        # set mode using constant
X   35    set $i0=%fmode($s10)
X   36
X   37    ptrace off              # show file attributes
X   38    echo ''
X   39    echo -n $s10+' has '+%itos(%fsize($s10),06d)
X   40    echo    ' (0x'+%itos(%fsize($s10),x  )+') bytes'
X   41    echo 'accessed '+%edate(%fatime($s10))
X   42    echo 'modified '+%edate(%fmtime($s10))
X   43    echo ''
X   44    ptrace on
X   45
X   46    # demonstrate "is directory", "is character",
X   47    # "is regular file" functions
X   48    set i0=%isdir($s10),i1=%ischr($s10),i2=%isreg($s10)
X   49
X   50    fdel $s10 # should say 'deleted'
X   51    ptrace off
X   52    plog off
X   53
X
X
X                   fsts.ep output (procedure enables tracing)
X                   ------------------------------------------
X      ftst 06-21-1989 16:12
X
X      ftst 15>  set $s10 = '/tmp/ftst.tmp' # temp file name
X      $s10 = '/tmp/ftst.tmp'
X      ftst 16>  fdel $s10                  # test proc trace warning
X      /tmp/ftst.tmp: No such file or directory
X      ftst 17>  fopen -w 0 $s10            # open file 0 for write
X      opened '/tmp/ftst.tmp' as file 0
X      ftst 18>  set i0=%ftell(0)           # should produce 0
X      $i00 =       0 (0x00000000,00)
X      ftst 19>  fputs 0 'abcdefghijk'      # put a line in the file
X      ftst 20>  set i0=%ftell(0)           # should produce 12
X      $i00 =      12 (0x0000000c,014)
X      ftst 21>  fclose 0 n                 # close the file
X      ftst 23>  fopen -r 0 $s10    # open again for reading
X      opened '/tmp/ftst.tmp' as file 0
X      ftst 24>  fgets 0 $s0        # should produce 'abcdefghijk'
X      fgets set $s00 = 'abcdefghijk'
X      ftst 25>  fseek 0 0          # rewind to read again
X      file 0 set to position 0
X      ftst 26>  fgets 0 $s0        # should produce 'abcdefghijk'
X      fgets set $s00 = 'abcdefghijk'
X      ftst 27>  fgets 0 $s0        # should produce null string
X      fgets set $s00 = ''
X      ftst 28>  set $i0=%fmode(0)  # test file mode function
X      $i00 =   33188 (0x000081a4,0100644)
X      ftst 29>  fclose 0           # close the file
X      ftst 31>  fchmod 'rw-rw-r-x' $s10 # set mode using string
X      '/tmp/ftst.tmp' mode set to 100665
X      ftst 32>  set $i0=%fmode($s10)
X      $i00 =   33205 (0x000081b5,0100665)
X      ftst 34>  fchmod 0777 $s10        # set mode using constant
X      '/tmp/ftst.tmp' mode set to 100777
X      ftst 35>  set $i0=%fmode($s10)
X      $i00 =   33279 (0x000081ff,0100777)
X      ftst 37>  ptrace off              # show file attributes
X
X      /tmp/ftst.tmp has 000012 (0xc) bytes
X      accessed 06-21-1989 16:12:01
X      modified 06-21-1989 16:12:01
X
X      ftst 46>  # demonstrate "is directory", "is character",
X      ftst 47>  # "is regular file" functions
X      ftst 48>  set i0=%isdir($s10),i1=%ischr($s10),i2=%isreg($s10)
SHAR_EOF
echo "End of part 40"
echo "File doc/samplproc.man is continued in part 41"
echo "41" > s2_seq_.tmp
exit 0
-- 
-------------------------------------------------------------------
Warren Tucker, Tridom Corporation       ...!gatech!emory!tridom!wht 
Ker-au'-lo-phon.  An 8-foot partial flue-stop, having metal pipes
surmounted by adjustable rings, and with a hole bored near the top
of each pipe, producing a soft and "reedy" tone.



More information about the Alt.sources mailing list