⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _p_cmd.txt

📁 一个通讯程序源码
💻 TXT
📖 第 1 页 / 共 4 页
字号:
displayed.The majority of procedure tracing features use the current tracestate (from the.B ptracecommand setting) as a binary condition.  That is, either tracing is doneor not.  However,.B exprespadds the tracing level to the number of -v switches to determine itsverbosity level.Escape sequences allow you to insert special or variableinformation in your expect and respond strings.  Escape sequencesbegin with either the backslash or the tilde.  NOTE: remember touse two backslashes inside a literal string constant to get onebackslash in the resulting string.  The procedure language'sstring parser has it's own use for a single backslash followed byanother character.  For instance:.DS L    set $s0='\e\eM' sets $s00 to '\eM'.DESome of the escape sequnces have meaning in both expect and respondtokens while others have a use in only of of the two types..DS L   Meaning of the escape sequences:   \eD - current phone number   \eE - turn on echo checking when sending (for slow devices)   \eK - send a BREAK   \eM - turn on line CLOCAL    \eN - null byte (same as \e000)   \eT - current phone number with Dialcodes and         character translation   \ec - append no new-line to send string (must be last            "character" in a send string)   \ed - delay (2 seconds)    \ee - turn off echo checking when sending   \em - turn off line CLOCAL    \en - send or expect new-line   \ep - pause (approximately 1/4-1/2 second delay)   \er - send or expect carriage return   \e\e - send or expect backslash (same as \e134)   \e~ - send or expect tilde (same as \e176)   \e### - send or expect character respresenting three           character octal value ### (*MUST* be three digits           with leading zeroes as necessary)   ~m[##] - set expect timeout to ## milliseconds (NOT            SUPPORTED BY DIALERS; SEE BELOW)   ~n[##] - nap ## milliseconds (NOT SUPPORTED BY DIALERS;           SEE BELOW)   ~t[##] - set expect timeout to ## seconds (NOT SUPPORTED            BY DIALERS; SEE BELOW)   Speed - Hayes-style CONNECT handler (as sole contents of           an expect string, equivalent to using CONNECT).DE<timeout_msecs> specifies an optional timeout in millisecondsfor waiting on expect strings;  it defaults to 10,000 milliseconds(10 seconds).The resolution for timeouts is limited to the basic tick time ofyour system (HZ, 10 msec for UNIX/386 3.2.0,16 (1000/60) msec for 3.2.1 (ODT 1.0) and 3.2v2 (ODT 1.1),back to 10 msec for 3.2v4 (ODT 2.0) and20 msec for XENIX/386 and XENIX/286). Whew!The timeout for 'Speed' expects is fixed at 90 seconds.~t[##] and ~m[##] may appear at the beginning of an expect portionof a script.  They set the expect timeout delay in seconds andmilliseconds, respectively.  The ## is a decimal number; if it isspecified <= 0, there will be no delay.  The initial timeout setfor each execution of the expresp command is 10 seconds.  Thetimeout period remains as you set it for the remainder of thescript unless you change it again..DS LExamples:    ~t[20]gin:      look for "gin:" for 20 seconds    ~m[500]\001     look for STX for 500 milliseconds    "" ~t[3]gin:--gin: uname ~t[10]word: secret.DE~n[##] may appear anywhere in a respond portion of a script.  It causes ECU to nap the number of milliseconds specifiedby the decimal ## argument.  This function was served by \em priorto ECU 3.20.  Addition of SVR4 \eM and \em necessitatedthe change..DS LExample:    a~n[20]b~n[20]c   send "abc" with 20 msec between each                      character.DEInteger variable $i0 is set to one if the expect-respond script fails, else it is set to 0..*s 2 "fchmod"usage: fchmod <mode> <filenum>This command sets the mode of <filenum> to <mode>.The <mode> argument takes one of two forms, a nine-charactermode string (e.g., 'rwxr-xr-x') or an integer value (0755).The <filenum> argument is either a string value forming afilename or an integer file number representing a file opened with the.B fopencommand.The command sets $i0 = 0 if successful, else to the.B errnofrom the associated system call (refer to the .B %errstrstring function and/or /usr/include/sys/errno.h)..DS LExample:    fopen 1 '/tmp/123'; fchmod 'rwxrwxrwx' 1    fchmod 'rwxrwxrwx' '/tmp/123'    fopen 1 '/tmp/123'; fchmod 0777 1    $i0 = 0777; fchmod $i0 '/tmp/123'All of the above example result in the same result..DE.*s 2 "fclose"usage: fclose <filenum>This command closes <filenum>.The <filenum> argument is aninteger file number representing a file opened with the.B fopencommand.The command is ignored if <filenum> is not open.No integer variable is modified by.I fclose ..DS LExample:    fclose 1.DE.*s 2 "fdel"usage: fdel <filenum>This command removes a file.The command sets $i0 = 0 if successful, else to the.B errnofrom the associated system call (refer to the .B %errstrstring function and/or /usr/include/sys/errno.h)..DS LExample:    fdel '/tmp/123'.DE.*s 2 "fgetc"usage: fgetc <filenum> <destination>This command reads a character from <filenum>.The <filenum> argument is aninteger file number representing a file opened with the.B fopencommand.The argument <destination> is either a string variableor an integer variable.If the file has reached end of file: an integer variablereceives -1; a string variable is returned null.Otherwise, the character's numeric value (0-255) is placedin an integer variable or a string variable is returned with alength of one with the file character as its only character..DS LExample:    fgetc 1 $s0    fgetc 1 $i_input.DE.*s 2 "fgets"usage: fgets <filenum> <strvar>This command reads a character from <filenum>.The <filenum> argument is aninteger file number representing a file opened with the.B fopencommand.The argument <strvar> is a string variable.If the file has reached end of file, <strvar> is returned null andinteger variable $i0 is set to 1.Otherwise, the <strvar> receives input from the file minusthe trailing newline and $i0 is returned zero..DS LExample:    fgets 1 $s0.DE.*s 2 "fkey".DS Lusage: fkey <str>       fkey -r.DEThis command selects a function key definition from the ~/.ecu/keysfile.  The -r version resets to the original defaults, plustloads any entry in keys named "default"..*s 2 "fkmap".DS Lusage: fkmap        fkmap <keyname>       fkmap <keyname> <keylist>       fkmap -l <name>       fkmap -r       fkmap -s <file>.DEThis command manages the mechanism ECU uses to recognize functionkeys when they are entered at the console.  Entering the commandwith no arguments displays the current mapping in funckeymap format.If supplied, the first argument to the command must be therecognized name of a function key from the list:.DS L F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Home End PgUp PgDn CUP CUL CU5 CUR CUD.DEThe case of the entered argument is unimportant.If only one argument is supplied, the mapping for the specified keyis displayed.  If more than one argument is supplied, the keyboardmapping is changed.  Arguments 2-n are character code specifiersin the format used to define a funckeymap entry..B WARNING :If found to be syntactically correct, a mapping changeis installed immediately.  If incorrect mapping of the HOMEkey is requested, you may lose control of ECU.The -l form reads an entire funckeymap definition matching <name>from ~/.ecu/funckeymap (if not found there, in a file by the samename in the library directory).  This form behaves exactlyin the same manner as the command line switch -F.Due to the drastic nature of this command, if it fails toexecute properly, ECU terminates itself.  Note thatimproper use of this form of the command can still renderECU an albatross (with Home unrecognizable).The -r form rereads the original funckeymap definition (asat program invocation), reseting the mapping.  The -s switchsaves the current mapping to <file>.Note: the fkmap command line must contain literal text.No variable or expression expansions are not done.Switches may not be combined.  Only one switch may appear..DS LExamples:    fkmap f10       display F10 mapping    fkmap Home ^Z   map Home to ^Z                    after this command, type ^Z for Home.DE.*s 2 "flush"usage: flushThis command causes any characters received by the systemfrom the line, but not yet read by the procedure to be "forgotten"or flushed..*s 2 "fopen"usage: fopen [-<mode>] <filenum> <filename>This command opens a file named by the string argument <filename>and associates it with the user-chosen file number <filenum> (whichmust be an integer value between 0 and 4, inclusive).The argument switches govern how a file is opened and must be chosenfrom this list:.VL 15 4.LI -rThe file is opened read-only; if it does notexist, an error occurs..LI -r+The file is opened for reading and writing; if it does notexist, an error occurs..LI -wThe file is opened for writing (any previous contentsof the file are lost); if it does notexist, it is created..LI -w+The file is opened for reading and writing (any previous contentsof the file are lost); if it does notexist, it is created..LI -aThe file is opened for appending (writes to the fileare added to the previous file contents); if it does notexist, it is created.All writes are appended to the file (the.B fseekcommand has no effect)..LEThe switches argument may be omitted; in such cases,the file is opened as though '-r' had been supplied.  However,if procedure tracing is enabled (see the description of theinteractive and procedure command.B ptrace ),a warning message will be issued.The command sets $i0 = 0 if successful, else to the.B errnofrom the associated system call (refer to the .B %errstrstring function and/or /usr/include/sys/errno.h)..DS LExample:    fopen 0 -r '/etc/passwd'    fopen 1 -w+ '/tmp/123'    fopen 2 -a 'tranact.log'.DE.*s 2 "fputc"usage: fputc <filenum> <char>This command writes character <char> into <filenum>.The <filenum> argument is aninteger file number representing a file opened with the.B fopencommand.Argument <char> is a integer value of which the lower eightbits are used or a string value of which the first character is used.If a write error occurs, procedure execution is terminated..DS LExample:    $s0='abc'; fputc 1 $s0        writes 'a'    $i0=0x30 ; fputc 1 $i0        writes '0'.DE.*s 2 "fputs"usage: fputs [-n] <filenum> <str>This command writes the string <str> into <filenum>.The <filenum> argument is aninteger file number representing a file opened with the.B fopencommand.If the switch '-n' is omitted, a newline is appended after <str>in the file; if present, no newline is written.If a write error occurs, procedure execution is terminated..DS LExample:    $s0='abc'; fputc 1 $s0        writes 'a'.DE.*s 2 "fseek"usage: fseek <filenum> <position>This command sets the file position of <filenum> to <position>,an integer value.The corresponding integer function.B %ftellmay be used to determine the current file position..B Note :if <filenum> is open for append ('-a'), then the.B fseekcommand will have no effect..*s 2 "getf".DS Lusage: getf -x <int-var-spec> <offset>where: -x ==   -b byte   -w word (little-endian)   -W word (big-endian)   -l 32-bits (little-endian)   -L 32-bits (big-endian).DE.*s 2 "gosub"usage: gosub <label>This command transfers control of procedure to a statementother than the one immediately following.  The <label>argument may be literal text or may be a string, allowinga "computed gosub" feature.When the next return statement is executed, control isreturned to the next statement after the gosub..DS LExample:    gosub GET_NEXT    gosub 'GET_NEXT'    gosub 'GET'+'_NEXT'    $s0 = 'GET_NEXT'; gosub $s0    $s0 = 'NEXT'; gosub 'GET_'+$s0Note: all the above examples cause transfer to the label GET_NEXT..DE.DS LA switch or case function of sorts may be implemented by something like:    #$i0 has been set to the "switch" value    ifi $i0 < 0 || $i0 > 2  # avoid gosub label not found    {        echo 'bad my_case state value'+%itos($i0)        DO SOMETHING LIKE DIE OR DUMP VARS AND DIE    }    $s0 = 'my_case_'+%itos($i0,03)    gosub $s0my_case_000    echo 'handle case 0'    returnmy_case_001    echo 'handle case 1'    returnmy_case_002    ifi $i_already_did_002    {        echo 'whoops'        return    }    echo 'handle case 2'    $i_already_did_002 = 1    return.DE.*s 2 "gosubb"usage: gosubb <label>This command serves the same function as the.B gosubcommand except the programmer is signifying that the labelis.B b ehindthe current statement, resulting in slightly faster execution.(The label is not REQUIRED to be at any specific locationin the procedure relative to the.B gosubbstatement.).*s 2 "goto"usage: goto <label>This command transfers control of procedure to a statementother than the one immediately following.  The <label>argument may be literal text or may be a string, allowinga "computed goto" feature..DS LExample:    goto GET_NEXT    goto 'GET_NEXT'    goto 'GET'+'_NEXT'    $s0 = 'GET_NEXT'; goto $s0    $s0 = 'NEXT'; goto 'GET_'+$s0.DENote: all the above examples cause transfer to the label GET_NEXT..*s 2 "gotob"usage: gotob <label>This command serves the same function as the.B gotocommand except the programmer is signifying that the labelis.B b ehindthe current statement, resulting in slightly faster execution.(The label is not REQUIRED to be at any specific locationin the procedure relative to the.B gotobstatement.).*s 2 "hangup"usage: hangupThis command causes Data Terminal Ready (DTR)to be dropped momentarily, causing (hopefully)the termination of any current connectionto a remote system. This command is only effective if the attached Data CommunicationsEquipment is configuredto terminate its connection on loss of DTR.If no line is attached, the command is ignored (a warningis generated if procedure tracing is enabled)..*s 2 "hexdump".DS Lusage: hexdump [-s] <str>       hexdump -t[s] <str1> <str><str> buf to dump<str1> title (if -t)-s short (terse) dump.DEThis command prints a hexadecimal dump of <str> on the screen(and to the procedure log file, if logging enabled with the.B ptracecommand).The switch '-t' signifies that <str1> is a title to be printed.DS LExample:    $s0='The quick brown fox jumped over the lazy dog\e's back'    hexdump -t 'Example hex dump' $s0---------------------------- Example hex dump ----------------------------0000  54 68 65 20 71 75 69 63 6B 20 62 72 6F 77 6E 20 | The quick brown  |0010  66 6F 78 20 6A 75 6D 70 65 64 20 6F 76 65 72 20 | fox jumped over  |0020  74 68 65 20 6C 61 7A 79 20 64 6F 67 27 73 20 62 | the lazy dog's b |0030  61 63 6B                                        | ack              |.DE.DS L    hexdump %left($s0,9)0000  54 68 65 20 71 75 69 63 6B                      | The quick        |

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -