Path: utzoo!attcan!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!cs.utexas.edu!usc!wuarchive!uunet!sparky!kent From: wht@n4hgf.uucp (Warren Tucker) Newsgroups: comp.sources.misc Subject: v16i057: ECU async comm package rev 3.0, Part33/35 Message-ID: <1991Jan6.054118.29086@sparky.IMD.Sterling.COM> Date: 6 Jan 91 05:41:18 GMT Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield) Organization: Sterling Software, IMD Lines: 1737 Approved: kent@sparky.imd.sterling.com X-Checksum-Snefru: 250a2f93 2220d6b3 24c5f987 67954661 Submitted-by: wht@n4hgf.uucp (Warren Tucker) Posting-number: Volume 16, Issue 57 Archive-name: ecu3/part33 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is part 33 of ecu3 if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= doc/_p_cmd.txt ============== if test ! -d 'doc'; then echo 'x - creating directory doc' mkdir 'doc' fi echo 'x - extracting doc/_p_cmd.txt (Text)' sed 's/^X//' << 'SHAR_EOF' > 'doc/_p_cmd.txt' && X.*s 2 "Commands" X X.*s 3 "baud" X Xusage: baud X XThis command sets the baud rate for the attached line. XThe integer argument must be one of X110, 300, 600, 1200, 2400, 4800, 9600, 19200 and 38400. X.DS L XExample: X baud 9600 X set $i0=2400; baud $i0 X.DE X X.*s 3 "break" X Xusage: break X XThis command is used inside a X.B whilei Xor X.B whiles Xcompound statement to exit the loop. X.DS L XExample: X X whilei 1=1 #forever unless break command executed X { X echo -n 'Answer yes or no: ' X set $s0=%cgets # get answer X ifi %instr($s0,'y') == 0 set $i0 = 1; break X ifi %instr($s0,'n') == 0 set $i0 = 0; break X # got neither 'y' nor 'n' ... keep trying X } X # now $i0 = 1 if yes, 0 if no X.DE X XNOTE: further examples of X.B break Xusage may be found in the example for the Xelse Xcommand. X X.*s 3 "cd" X Xusage: cd X XThis command changes ECU's current working directory. XThe string argument may contain any Xdirectory pathname specification legal to be submitted to Xthe shell csh. Wild card characters may be used, provided Xthe expansion produces only one pathname. X X.DS L XExample: X X cd '~user/bin' X cd %envvar('HOME')+'/bin' X.DE X X.*s 3 "clrx" X Xusage: clrx X XThis command clears the attached line's transmitter XOFF state. XIssuing the command is the equivalent to receiving an XON from Xthe remote system. X X.*s 3 "cls" X Xusage: cls X XThis command clears the screen. X X.*s 3 "color" X X.DS L Xusage: color [] Xusage: color -r [] X.DE X XThis command changes the current normal or reverse video colors in a Xmanner similar to the setcolor(C) command. It has no effect on systems Xusing a monochrome monitor. If the second (background) color is Xomitted, it is assumed to be black. X XThe command also forces normal video mode. Refer to the X.B vidnorm Xand X.B vidrev Xcommands. XRefer also to the X.B vidcolor Xcommand. X X.DS L XColor names X blue magenta brown black X lt_blue lt_magenta yellow gray X cyan white green red X lt_cyan hi_white lt_green lt_red X.DE X.DS L XExample: X X color lt_green # normal video light green on black X color -r red white # reverse video red on white X.DE X X.*s 3 "continue" X Xusage: continue X XThis command is used inside a X.B whilei Xor X.B whiles Xcompound statement to skip the remainder of any Xcommands in the loop and continue execution at the first Xcommand in the loop. X.DS L XExample: X X send '' # send ENTER to get prompt X whilei 1=1 # forever unless break command executed X { X lookfor -e 'login: ' # look for login prompt X ifi $i0 == 0 # if we dont get prompt ... X { X send '' # send ENTER again X continue # and look for login prompt X } X send $s_name # send username X lookfor -e 'Password:' X send $s_password X get -e 0 50 # wait 10 seconds for response X X # if incorrect not found in response, ... X if %instr($s0,'incorrect') < 0 # ... must have won X break X X # garbled line?: system will send another 'login: ' X } X X.DE X XNOTE: further examples of X.B continue Xusage may be found in the example for the X.B else Xcommand. X X.*s 3 "cursor" X Xusage: cursor [] X XThis command places the cursor at a specified position on Xthe video screen. The top left of the scrren is row 0, column 0. XIf is not specified, it is assumed 0 (left margin). X.DS L XExample: X X cls X $i0 = 5 X whilei $i5 < 12 X { X cursor $i5 X echo 'This is line '+%itos($i5,2d)+' of the display' X } X.DE X X.*s 3 "delline" X Xusage: delline X XThis command deletes the current line from the video display. X X.*s 3 "dial" X Xusage: dial X XThis command causes an outgoing call to be placed. The string Xargument can take one of two forms: a numeric telephone Xnumber or an alphanumeric "logical" number or system name. X XA numeric phone number ('1(800)555-1212' or '2345678') must begin Xwith a digit and must consist entirely of digits, parentheses Xor hyphens. XIf a telephone number is supplied, the phone number is Xdialed; you must first have set the desired baud rate and Xparity using the 'baud' and 'parity' commands. X XIf a logical name is entered, the phone directory (managed by Xthe interactive X.B dial Xcommand) is searched; Xif the entry is found, the baud rate and parity Xis automatically set from values in the directory entry; then, Xthe number in the directory entry is dialed. X XSee the section on the interactive X"Dial" command and the section titled "Choosing a Dialout Line" for Xmore information. X XWhen the X.B dial Xcommand returns, integer variable $i0 is set to a status code Xand string variable $s0 has a text message (the modem verbal Xresult code if the ECU dialer is used, a representation of Xthe return status code if a uucp dialer is used [see below]). X.DS L X.B XDial Command $i0 Status Codes X.R X X 0 successful connect X 1 failed to connect (call progress) X 2 dial interrupted by signal X 3 modem error (non responsive or commands rejected) X.DE X.DS L X.B XDial Command $s0 Status Messages (uucp dialer) X.R X X CONNECT #### #### = baud rate X BUSY only some modems X NO ANSWER only some modems X NO CARRIER most generic "fail to connect" X NO DIAL TONE only some modems X !Connect bad baud rate modem reported different rate X !Interrupted call interrupted by signal X !Invalid arguments ECU error X !Invalid phone number too long or bad characters X !Ioctl error should not be reported here X !Line in use should not be reported here X !Line open error should not be reported here X !Modem Error modem did not respond X XNote: if the ECU dialer is used, the actual modem result code Xis returned in $s0 or one of the following two strings: X X !Interrupted call interrupted by signal X !Modem Error modem did not respond X.DE X X.*s 3 "do" X Xusage: do [ ...] X XThis command executes a procedure whose name appears as the command's Xfirst (string) argument. One or more arguments (up to 19) may be passed Xto the called procedure; an argument may consist of any valid string Xexpression, provided, that, when expanded, the argument does not Xexceed 256 characters in length. X XThe called procedure may read its arguments using the X.B %argv Xstring function. %argv(0) is the name of the procedure. XThe quantity of arguments may be obtained using the X.B %argc Xinteger function. X X.DS L XExample: X X do 'proc' %rname %date+' '+%time %argv(0) X XNote: in this example, the called procedure is passed the name Xof the calling procedure as the last argument. X.DE X X.*s 3 "duplex" X X.DS L Xusage: duplex full | half X duplex 'full' | 'half' X.DE X XThis command specifies whether or not ECU is to locally echo Xcharacters typed by you at the keyboard. The overwhelming Xmajority of remote systems provide the echo function, in Xwhich case full duplex must be used. For the rare occasions Xwhen the remote system does not echo your keyboard input, Xsetting half duplex will allow you to see what you are Xtyping. X XWhen communicating with another terminal in a "teletype Xconversation", setting half duplex is generally required. XIn such cases, use of the interactive X.B nl , X.B nlin Xand X.B nlout Xcommands may also be required. X.DS L XExample: X X duplex full X $s0 = 'full'; duplex $s0 X.DE X X X.*s 3 "echo" X Xusage: echo [-n] X XThis command prints the contents of the string argument Xon the screen. If the -n switch is not present, a newline follows Xthe output of . X.DS L XExample: X X echo 'Procedure '+%argv(0)+' executing at '+%time X echo -n 'Enter your first name: '; $s0 = %cgets X.DE X X.*s 3 "eeol" X Xusage: eeol X XThis command erases the video display to the end of the line. X X.*s 3 "else" X X.DF L Xusage: else X X else X X X else X { X any kind and number of statements X } X X else X X else X { X any kind and number of statements X } X X.DE X XThis statement may follow an X.B ifi Xor X.B ifs Xcommand to specify one or more statements to be executed if Xthe if-type command condition is false. Else commands may be Xchained together in the traditional structured language manner. X XFor the purposes of describing this command, is Xany single or compound statement X.B NOT Xcontaining a X.B whilei Xor X.B whiles Xcommand. XIf you wish to have a while-type command executed as part of an X.B else Xcondition, the while must occur within braces ("{}"). X X is an X.B ifi Xor X.B ifs Xcommand followed by an (see the description of the X.B ifi Xor X.B ifs Xcommands below). X.DS L XExample: X X#+------------------------------------------------------ X# finger.ep - procedure to send 'finger' to remote X# BSD Unix system; print resulting lines in different X# colors: uucp logins green, root red, others cyan X#------------------------------------------------------- X X mkvar $icolor; $icolor = %colors X mkvar $itimeout X $itimeout = 50 # timeout for first line 5 secs X send 'ps -aux' # send command, but do not echo X lookfor '\n' 40 # swallow command X whilei 1==1 # forever, or until break X { X lgets 0 $itimeout 1 '\n' #get a line X ifi $i0 = 0 break #if no chaacters read X $itimeout = 10 #wait 1 sec for later lines X X ifi %instr($s0,'% ') >= 0 # if csh prompt seen X break # exit while loop X else ifi %instr($s0,'Login') >= 0 X color gray X else ifi %instr($s0,'root') >= 0 X color red X else ifi %instr($s0,'uucp') >= 0 X color green X else color cyan X echo $s0 X } X icolor $icolor #restore entry colors X send '' #force a new prompt from remote X X.DE X X.*s 3 "exit" X Xusage: exit [] X XThis command causes an abrupt termination of the ECU program. XAny existing connection with a remote system Xis terminated immediately. XIf no integer argument is found, ECU exits Xwith a program exit status of 0. XIf is found and the value is zero, then ECU exits Xwith a program exit status of 0. XIf non-zero,its value must be in the range of 1 to 31, Xand ECU exits Xwith a program exit status of 192 plus . XThis feature allows batch executions of ECU by shell script Xdetect user-determined ECU execution status. XSee the section titled "Exit Codes". X X.*s 3 "expresp" X Xusage: expresp [-v[v...]] [] X XThis command emulates the uuchat function as described in the XSCO HDB UUCP documentation and in the /usr/lib/uucp/Dialers Xfile. X X-v causes the expect-respond conversation between ECU and the Xremote system to be displayed on the screen. This switch is Xautomatically enabled if procdedure tracing is enabled. X Xmultiple v's (e.g., -vv, -vvv) up to 3 'v's produce Xmore verbose debug output. -vv causes each base level Xexpect and respond string to be displayed. -vvv causes Xa hexadecimal dump of each interpreted expect string to be Xdisplayed. X X is as defined in /usr/lib/ecu/Dialers. X.DS L X Meaning of some of the escape characters: X \\\p - pause (approximately 1/4-1/2 second delay) X \\\d - delay (2 seconds) X \\\D - phone number/token X \\\T - phone number with Dialcodes and character translation X \\\N - null byte X \\\K - insert a BREAK X \\\E - turn on echo checking (for slow devices) X \\\e - turn off echo checking X \\\r - carriage return X \\\c - no new-line X \\\n - send new-line X \\\nnn - send octal number X \\\m## - delay ## milliseconds (NOT SUPPORTED BY DIALERS; X SEE BELOW) X ~t[##] - set timeout to ## seconds (see below) X ~m[##] - set timeout to ## milliseconds (see below) X Speed - Hayes-specific speed-adaptive connect handler X.DE X X specifies an optional timeout in milliseconds Xfor waiting on expect strings; it defaults to 10,000 milliseconds X(10 seconds). XThe resolution for timeouts is limited to the basic tick time of Xyour system (HZ, 10 msec for UNIX/386, 20 msec for XENIX/386 and XENIX/286). XThe timeout for 'Speed' expects is fixed at 90 seconds. X X\\\m### causes a ### millisecond delay. Note this adds an ambiguity to Xthe syntax of the send string: you may not follow an \m delay with a Xliteral digit to send. For example, suppose you wish to delay 300 Xmissileconds then send "4A". \\\m3004A will delay for 3004 X(approximately) milliseconds, then send an "A". X XInteger variable $i0 is set to one if the expect-respond script Xfails, else it is set to 0. X X X.*s 3 "fchmod" X Xusage: fchmod X XThis command sets the mode of to . XThe argument takes one of two forms, a nine-character Xmode string (e.g., 'rwxr-xr-x') or an integer value (0755). XThe argument is either a string value forming a Xfilename or an integer file number representing a file opened with the X.B fopen Xcommand. X XThe command sets $i0 = 0 if successful, else to the X.B errno Xfrom the associated system call (refer to the X.B %errstr Xstring function and/or /usr/include/sys/errno.h). X X.DS L XExample: X X fopen 1 '/tmp/123'; fchmod 'rwxrwxrwx' 1 X fchmod 'rwxrwxrwx' '/tmp/123' X fopen 1 '/tmp/123'; fchmod 0777 1 X $i0 = 0777; fchmod $i0 '/tmp/123' X XAll of the above example result in the same result. X.DE X X.*s 3 "fclose" X Xusage: fclose X XThis command closes . XThe argument is an Xinteger file number representing a file opened with the X.B fopen Xcommand. X XThe command is ignored if is not open. XNo integer variable is modified by X.I fclose . X X.DS L XExample: X X fclose 1 X.DE X X.*s 3 "fdel" X Xusage: fdel X XThis command removes a file. X XThe command sets $i0 = 0 if successful, else to the X.B errno Xfrom the associated system call (refer to the X.B %errstr Xstring function and/or /usr/include/sys/errno.h). X X.DS L XExample: X X fdel '/tmp/123' X.DE X X.*s 3 "fgetc" X Xusage: fgetc X XThis command reads a character from . XThe argument is an Xinteger file number representing a file opened with the X.B fopen Xcommand. X XThe argument is either a string variable Xor an integer variable. XIf the file has reached end of file: an integer variable Xreceives -1; a string variable is returned null. XOtherwise, the character's numeric value (0-255) is placed Xin an integer variable or a string variable is returned with a Xlength of one with the file character as its only character. X X.DS L XExample: X X fgetc 1 $s0 X fgetc 1 $i_input X.DE X X.*s 3 "fgets" X Xusage: fgets X XThis command reads a character from . XThe argument is an Xinteger file number representing a file opened with the X.B fopen Xcommand. X XThe argument is a string variable. XIf the file has reached end of file, is returned null and Xinteger variable $i0 is set to 1. XOtherwise, the receives input from the file minus Xthe trailing newline and $i0 is returned zero. X X.DS L XExample: X X fgets 1 $s0 X.DE X X.*s 3 "fkey" X Xusage: fkey X XThis command selects a function key definition from the ~/.ecu/keys Xfile. X X.*s 3 "flush" X Xusage: flush X XThis command causes any characters received by the system Xfrom the line, but not yet read by the procedure to be "forgotten" Xor flushed. X X.*s 3 "fopen" Xusage: fopen [-switches] X XThis command opens a file named by the string argument Xand associates it with the user-chosen file number (which Xmust be an integer value between 0 and 4, inclusive). X XThe argument switches govern how a file is opened and must be chosen Xfrom this list: X.VL 15 4 X.LI -r XThe file is opened read-only; if it does not Xexist, an error occurs. X.LI -r+ XThe file is opened for reading and writing; if it does not Xexist, an error occurs. X.LI -w XThe file is opened for writing (any previous contents Xof the file are lost); if it does not Xexist, it is created. X.LI -w+ XThe file is opened for reading and writing (any previous contents Xof the file are lost); if it does not Xexist, it is created. X.LI -a XThe file is opened for appending (writes to the file Xare added to the previous file contents); if it does not Xexist, it is created. XAll writes are appended to the file (the X.B fseek Xcommand has no effect). X.LE X XThe switches parameter may be omitted; in such cases, Xthe file is opened as though '-r' had been supplied. However, Xif procedure tracing is enabled (see the description of the Xinteractive and procedure command X.B ptrace ), Xa warning message will be issued. X XThe command sets $i0 = 0 if successful, else to the X.B errno Xfrom the associated system call (refer to the X.B %errstr Xstring function and/or /usr/include/sys/errno.h). X.DS L XExample: X X fopen 0 -r '/etc/passwd' X fopen 1 -w+ '/tmp/123' X fopen 2 -a 'tranact.log' X.DE X X.*s 3 "fputc" X Xusage: fputc X XThis command writes character into . XThe argument is an Xinteger file number representing a file opened with the X.B fopen Xcommand. XArgument is a integer value of which the lower eight Xbits are used or a string value of which the first character is used. X XIf a write error occurs, procedure execution is terminated. X.DS L XExample: X X $s0='abc'; fputc 1 $s0 writes 'a' X $i0=0x30 ; fputc 1 $i0 writes '0' X.DE X X.*s 3 "fputs" X Xusage: fputs [-n] X XThis command writes the string into . XThe argument is an Xinteger file number representing a file opened with the X.B fopen Xcommand. X XIf the switch '-n' is omitted, a newline is appended after Xin the file; if present, no newline is written. X XIf a write error occurs, procedure execution is terminated. X.DS L XExample: X X $s0='abc'; fputc 1 $s0 writes 'a' X.DE X X.*s 3 "fseek" X Xusage: fseek X XThis command sets the file position of to is open for append ('-a'), then the X.B fseek Xcommand will have no effect. X X.*s 3 "getf" X X.DS L Xusage: getf -x X Xwhere: -x == X -b byte X -w word (little-endian) X -W word (big-endian) X -l 32-bits (little-endian) X -L 32-bits (big-endian) X.DE X X.*s 3 "gosub" X Xusage: gosub