ckermit2.txt
资源名称:cku197.tar.Z [点击查看]
上传用户:dufan58
上传日期:2007-01-05
资源大小:3407k
文件大小:668k
源码类别:
通讯/手机编程
开发平台:
Windows_Unix
- indicated number of NUL bytes. If /SIZE was not given, this switch is
- ignored.
- /RPAD[:value]
- Like LPAD, but pads on the right.
- /CHARACTER
- Specifies that one character should be written. If the <text> is empty or
- not given, a NUL character is written; otherwise the first character of
- <text> is given. Synonym: /BYTE.
- /STRING
- Specifies that the <text> is to be written as-is, with no terminator added.
- Here's an example in which we copy a text file line by line:
- file open /read %c oofa.txt ; Open input file
- if fail exit 1 Can't open input file ; Check that it's open
- file open /write %d new.txt ; Open output file
- if fail exit 1 Can't open output file ; Check
- while true { ; Loop to copy lines
- file read /line %c line ; Read a line
- if fail break ; Assume failure = end of file
- file write /line %d {m(line)} ; Write the line to output file
- if fail exit 1 Write failure ; Failure here is fatal
- }
- file close %c ; Close the two files
- file close %d
- Note that since /LINE is the default for both FILE READ and FILE WRITE, it can
- be omitted as in the following example, where we also use the short names for
- the FILE commands.
- fopen /read %c oofa.txt ; Open input file
- if fail exit 1 Can't open input file ; Check that it's open
- fopen /write %d new.txt ; Open output file
- if fail exit 1 Can't open output file ; Check
- while true { ; Loop to copy lines
- fread %c line ; Read a line
- if fail break ; Assume failure = end of file
- fwrite %d {m(line)} ; Write the line to output file
- if fail exit 1 Write failure ; Failure here is fatal
- }
- fclose %c ; Close the two files
- fclose %d
- Here's the same example using "record i/o" (the open and close sequences are
- are omitted since they are the same as above). The result is the same, but
- execution is much faster:
- while true { ; Loop to copy blocks
- fread /size:512 %c block ; Read a block into %a
- if fail break ; Assume failure = end of file
- fwrite /string %d {m(block)} ; Write the block to output file
- if fail exit 1 Write failure ; Failure here is fatal
- }
- Although record i/o is faster, it should not be used in line-oriented
- applications, since it returns arbitrary chunks of the file to your script,
- rather than lines. In this example, FWRITE /STRING is used rather than FWRITE
- /SIZE:512 to avoid the last output block being padded beyond the original
- file's length.
- A file can also be copied character by character, but this is much slower than
- line i/o and VERY much slower than block i/o:
- while true { ; Loop to copy blocks
- fread /char %c c ; Read a character into c
- if fail break ; Assume failure = end of file
- fwrite /char %d {m(c)} ; Write character to output file
- if fail exit 1 Write failure ; Failure is fatal
- }
- Although character i/o is slow, it is the only way to process files that
- contain NUL characters (i.e. bytes composed of only zero bits). In the
- example above, when "fread /char %c c" returns a NUL, the c variable is
- empty. But since the FREAD /CHAR command did not fail, we know the result was
- really a NUL. FWRITE /CHAR, when given an empty variable (or no variable at
- all) writes a NUL. Thus the loop above will copy any file at all (very
- slowly). In non-copying applications, NULs are detected like this:
- fread /char %c c
- if fail (do something)
- if not def c (a NUL byte was read)
- Finally some advanced file operations:
- FILE FLUSH <channel>
- For output files only: commits all previous writes to disk,
- in case the computer was buffering them. Synonym: FFLUSH.
- FILE COUNT [ { /BYTES, /LINES, /LIST, /NOLIST } ] <channel>
- By default, or if the /BYTES switch is given, counts the bytes in the
- file, if any, open on the given channel. If the /LINES switch is given,
- counts lines in the file. If the /LIST switch is given, the result is
- printed. If the /NOLIST switch is given, the result is not printed.
- /QUIET is a synonym for /NOLIST. If neither /LIST nor /NOLIST is given,
- the result is printed if the command is given at top level, i.e. not from
- a command file or macro. In all cases, the result of the most recent FILE
- COUNT command is stored in the variable v(f_count). Note that FILE COUNT
- /LINE works (and can only work) by reading the entire file; expect it to
- take some time if the file is large. Synonym: FCOUNT.
- FILE REWIND <channel>
- Moves the read/write pointer to the beginning of the file. Equivalent to
- FILE SEEK <channel> 0. Synonym: FREWIND.
- FILE SEEK [ switches ] <channel> { [{+,-}]<number>, LAST, EOF }
- Moves the read/write pointer for the file on this channel to the given
- position, which may be a byte (character) number or a line number,
- expressed in either absolute or relative terms. Switches:
- /BYTE - The number given is a byte number. Synonym: /CHARACTER.
- /LINE - The number given is a line number.
- /ABSOLUTE - The number given is absolute.
- /RELATIVE - The number given is relative to the current position.
- By default, or if the /BYTE switch is given, the <number> is a
- byte number (0 = first byte). If /LINE is given, the <number> is a line
- number (0 = first line). EOF means to move to the end of the file.
- LAST means to move to the last line or character of the file, depending
- on whether it's a line or character seek.
- If neither the /RELATIVE nor the /ABSOLUTE switch is given, then if a
- signed number is given, the motion is relative to the current position.
- An expression that evaluates to a negative number is not considered signed
- for this purpose; that is, a sign (+ or -) must be included as the first
- character of the <number> in the command itself to force a relative seek
- (in the absence of /RELATIVE or /ABSOLUTE).
- If the number has no sign, or if the /ABSOLUTE switch is given, the number
- represents an absolute position (relative to the beginning of the file).
- Subsequent FILE READs or WRITEs will take place at the new position.
- If the read/write pointer is placed after the end of the file, a
- subsequent FILE READ will fail, but a FILE WRITE will succeed (possibly
- creating a file with "holes"). If a FILE SEEK /BYTE command is given, the
- current line becomes unknown (unless the position is 0) and subsequent
- FILE SEEK /RELATIVE /LINE commands will fail until the next non-relative
- FILE SEEK /LINE command is given. Synonym: FSEEK.
- An absolute FILE SEEK to a negative position fails silently, as does a
- relative seek to a position before the beginning of the file.
- A caution about relative SEEKs: remember that the number is relative to the
- current position. Whenever you read or write, this changes the position.
- In each of the following examples, assume the file open on channel %c is
- positioned at line "n" (the FREAD target variable is omitted for lack of
- space):
- { FREAD %c, FSEEK /LINE %c -1, FREAD %c } <-- Reads line n twice
- { FREAD %c, FSEEK /LINE %c +0, FREAD %c } <-- Reads lines n and n+1
- { FREAD %c, FSEEK /LINE %c +1, FREAD %c } <-- Reads lines n and n+2
- { FREAD %c, FSEEK /LINE %c -2, FREAD %c } <-- Reads lines n and n-1
- { FREAD %c, FSEEK /LINE %c -3, FREAD %c } <-- Reads lines n and n-2
- Another caution: Using FSEEK and FREAD /SIZE to repeatedly read the same disk
- block (e.g. when sampling a database record that is frequently updated) might
- not give you updated disk blocks due to the internal buffering and caching of
- the C library (this probably varies from one platform/compiler combination to
- another). If necessary you can force a fresh disk read with a close/open
- sequence:
- FCLOS %c
- FOPEN %c <samefilename>
- FSEEK %c <samespot>
- FREAD /SIZE:<howmanybytes> %c <variable>
- 1.22.3. FILE Command Examples
- To read the last 10 lines of a text file into an array:
- fopen /read %c oofa.txt ; Open the file
- if fail exit 1 Can't open oofa.txt ; Always check for failure
- dcl &a[10] ; Declare a 10-element array
- fcount /line %c ; Count lines in the file
- fseek /line %c v(f_count)-10 ; Seek to 10 lines from the end
- if fail exit 1 Can't seek ; Check for failure
- for %i 1 10 1 { fread %c &a[%i] } ; Read the last 10 lines
- fclose %c ; Close the file
- Note that blank lines show up as empty (undefined) array elements, for example
- if you give a "show array a" command at this point. This is normal. You
- can still use these elements; e.g.:
- for %i 1 10 1 { echo %i. &a[%i] } ; Display the 10 lines
- Here is how to read the last line of a file (already open on channel %c):
- fseek /line %c last ; Seek directly to last line
- Alternatively:
- fseek /line %c eof ; Seek to end of file
- fseek /line %c -1 ; Seek to beginning of last line
- Alternatively:
- fcount /line %c ; Count the file's lines
- fseek /line %c v(f_count)-1 ; Seek to last line
- fread %c ; Read it
- To read every other line from the file (using relative SEEK), skipping
- the first line:
- fopen /read %c oofa.txt ; Open the file
- while ( success ) { ; Loop through lines
- fseek /line %c +1 ; Skip a line
- if success fread %c ; Read & display a line
- }
- fclose %c ; Close the file
- Here is how to read the lines of a file in reverse order:
- fopen /read %c oofa.txt ; Open
- if fail exit 1 ; Check
- fseek /line %c last ; Seek to last line
- while success { ; Loop
- fread %c ; Read line
- fseek /line %c -2 ; Seek backwards two lines
- }
- fclose %c ; Close the file
- The loop works because a relative SEEK outside the file fails.
- It is also possible to use block i/o to manage random-access files with
- fixed-length records (as long as they don't contain NUL characters). Suppose,
- for example, you have a file of "card image" records with fixed-field
- information about customers, such as:
- Name: Columns 1-32 (column numbers are 1-based)
- Address: Columns 33-72
- Balance: Columns 73-80
- The records are indexed by customer number, starting with 0. There are no
- line terminators separating them. Therefore the record for customer number
- n starts at position n x 80 (%n*80).
- Now suppose we received a payment from customer number 173 and want to update
- the balance:
- .%n = 173 ; Customer (record) number
- .%a = 12.72 ; Amount
- fopen /read /write %c customer.db ; Open the file
- if fail stop 1 OPEN FAILED: f_errmsg() ; Check
- fseek /byte %c 80*%n ; Seek to record
- fread /size:80 %c r ; Read the record
- if fail stop 1 READ FAILED: f_errmsg() ; Check (IMPORTANT)
- .%b := fright(m(r),8) ; Extract the balance
- .%b := ffpadd(%b,%a,2) ; Add the new payment
- if fail stop 1 ARITHMETIC ERROR: %b/%a ; Catch bad records
- .r := {fleft(m(r),72)flpad(%b,8)} ; Update the record
- fseek /byte %c 80*%n ; Reposition to same spot
- fwrite /size:80 %c {m(r)} ; Replace the record
- if fail stop 1 WRITE FAILED: f_errmsg() ; Check
- fclose %c ; Close the file
- REMEMBER: Using FILE SEEK to move beyond the end of file can result in a file
- with holes when writing; when reading, an end-of-file error will occur --
- be sure to check for it.
- 1.22.4. Channel Numbers
- C-Kermit's channel numbers are integers from 0 to some platform-dependent
- limit, such as 46 or 1985 (the value of v(f_max)). This is the limit placed
- by the operating system on the number of files that may be opened by one
- process or user or job, minus the standard input, output, and error files, and
- minus the number of files reserved by C-Kermit for logs, OPEN READ and WRITE,
- and file transfer (and maybe some command files -- the v(f_max) number can't
- be exact).
- Although you must include a variable in the FILE OPEN command, to which the
- channel number is assigned, you don't have to use a variable in the other FILE
- commands if you know what the number is -- you can just put the number. This
- saves you a few keystrokes when typing commands at the prompt:
- fopen %c oofa.txt
- flist
- 0. /usr/olga.oofa.txt (R) 0
- This tells the channel number is 0 (the number on the left is the channel
- file's channel number). Of course you can also find it by echoing the
- variable:
- echo %c
- 0
- Or with "fstatus %c". Now you can type commands like:
- fread 0
- to read a line from the file. Obviously, however, using digits rather than
- a variable for the channel number would be poor practice in a script.
- If in commands like:
- fread %c %a
- you have trouble remembering which variable is which, note that the channel
- number is, indeed, a number. Anywhere C-Kermit accepts a number it can also
- accept an expression, so you can put parentheses around the channel number to
- remind you it's the channel number and not the variable into which data is to
- be read:
- fread (%c) %a
- Normally channel numbers are assigned sequentially as 0, 1, 2, ... up to the
- limit. However, once you start closing files, there can be holes in the
- sequence. New channels are assigned to fill in the holes. Thus you can't
- depend on channel numbers being in any particular sequence.
- 1.22.5. FILE Command Errors
- Each FILE command sets the variable v(f_error) to one of the following values:
- 0 = No error
- -1 = System error
- -2 = Attempt to read after end of file
- -3 = Channel not open
- -4 = Channel number out of range (negative or too large)
- -5 = Numeric argument (size, ...) out of range
- -6 = File not found
- -7 = Bad or missing filename
- -8 = Too many files are already open (FILE OPEN only)
- -9 = Forbidden operation (e.g. write to a read-only file)
- -10 = Access denied
- -11 = Illegal combination of OPEN modes (FILE OPEN only)
- -12 = Buffer overflow
- -13 = Current line number unknown (for relative line seeks)
- -14 through -98: Reserved.
- -99 = Requested operation not implemented in this version of C-Kermit
- -999 = Unknown error
- When v(f_error) is -1, this means the FILE command failed because because
- of a system error, in which case you can examine the following variables:
- v(errno) = System error number.
- v(errstring) = Error message corresponding to v(errno).
- A special function is available for translating the v(f_error) code to an
- error message string:
- f_errmsg([code])
- If the code is -1, returns error message of the most recent system
- error; otherwise if the code is a valid v(f_error) value, the associated
- message is returned. If the code is omitted, the status message
- corresponding to the current v(f_error) value is returned.
- A FILE command that fails prints the appropriate error message automatically,
- except when the command is READ or SEEK and the error is -2 (end of file); in
- that case, the command still fails, but does not print a message. This allows
- constructions such as:
- fopen %c oofa.txt
- while success { fread %c }
- fclose %c
- to work as expected, i.e. without an annoying message when the end of file
- is reached.
- 1.22.6. File I/O Variables
- The variables associated with the file i/o package are:
- v(f_count) - Result of the most recent FILE COUNT (FCOUNT) command.
- v(f_error) - Numeric error code of most recent FILE command (0 = no error).
- v(f_max) - Maximum number of files open simultaneously.
- 1.22.7. File I/O Functions
- Some of the FILE commands can also be issued as function calls, which makes
- script writing a bit more convenient, especially for C programmers. Also,
- several functions are provided that do not have command equivalents. Each of
- these functions takes a channel number as the first argument. These functions
- do not work for OPEN { READ, !READ, WRITE, !WRITE, and APPEND } files.
- f_status(channel)
- Returns 0 if the channel is not open, otherwise a number between 1 and 15
- which is the sum of the OPEN modes:
- 1 = /READ
- 2 = /WRITE
- 4 = /APPEND
- 8 = /BINARY
- The remaining functions work only for open channels. Each of these functions
- can fail for the applicable reasons listed in Section 1.22.5. For instructions
- on handling function errors, see Section 7.12.
- f_pos(channel)
- Returns the file's current read/write pointer (0-based). There is no FILE
- command equivalent.
- f_line(channel)
- Returns the file's current line number (0-based), if known, otherwise -1.
- There is no FILE command equivalent. The line number is known as long as
- no character or block i/o has been done on the channel.
- f_handle(channel)
- Returns the "file handle" of the file. That is, it translates the portable
- C-Kermit channel number into a system-specific file handle or number that
- can be passed to other programs on the same platform. In UNIX this is a
- file descriptor. There is no FILE command equivalent.
- f_eof(channel)
- Returns 1 if the read/write pointer of the file on the given channel is at
- the end of the file, 0 otherwise. Convenient in WHILE statements, e.g.:
- while not f_eof(%c) { fread %c }
- f_getchar(channel)
- Equivalent to FREAD /CHAR. Returns the character actually read.
- If f_getchar() does not fail but the return value is empty, this means
- a NULL character was read.
- f_getline(channel)
- Equivalent to FREAD /LINE. Returns the line actually read, but with the line
- terminator stripped. If f_getline() does not fail but the return value is
- empty, this normally means an empty line was read.
- f_getblock(channel,n)
- Equivalent to FREAD /SIZE:n. Returns the block of characters actually read.
- If the returned block is smaller than n, it indicates either that the end
- of file was reached or a NUL character is in the block.
- f_putchar(channel,c)
- Equivalent to FWRITE /CHARACTER. Writes the character c. If c contains
- more than one character, only the first is written. If c is empty a NUL
- is written. Returns the number of characters written on success, or a
- negative error code upon failure.
- f_putline(channel,string)
- Equivalent to FWRITE /LINE. Writes the string and adds the appropriate line
- termination character or sequence. If the string is empty or omitted, an
- empty line is written. Returns the number of characters written on success,
- or a negative error code upon failure.
- f_putblock(channel,string)
- Equivalent to FWRITE /STRING. Writes the string as given. If the string is
- empty or omitted, nothing is written. Returns the number of characters
- written on success, or a negative error code upon failure.
- 1.22.8. File I/O Function Examples
- fopen /read %c oofa.txt ; Open our favorite file for reading
- if failure exit 1 ; Check that it's open
- while not f_eof(%c) { ; Loop until EOF
- .line := f_getline(%c) ; Get a line
- if success echo {m(line)} ; Echo it
- }
- if not f_eof(%c) { ; Check reason for loop exit
- exit 1 File Error: f_errmsg() ; If not EOF say so.
- }
- frewind %c ; Rewind the file
- while not f_eof(%c) { ; Same thing but with block i/o
- .block := f_getblock(%c,256) ; (much faster than line i/o)
- if success xecho {m(block)}
- }
- frewind %c ; Rewind again
- while not f_eof(%c) { ; Same deal but with character i/o
- .c := f_getchar(%c) ; (much slower than line i/o)
- if success xecho {m(c)}
- }
- close %c
- To close all open files (equivalent to FCLOSE ALL):
- for %i 0 v(f_max)-1 1 {
- if f_status(%i) fclose %i
- }
- 1.23. The EXEC Command
- The EXEC command is available only in UNIX.
- EXEC [ /REDIRECT ] <command> [ <arg1> [ <arg2> [ ... ] ]
- Runs the given command with the arguments in such a way that the <command>
- replaces C-Kermit in memory, and C-Kermit ceases to execute. EXEC is like
- RUN, except instead of returning to C-Kermit when finished, the <command>
- returns to whatever process invoked Kermit.
- In the normal case, no files are closed, so the EXEC'd command inherits the
- open files, read/write pointers, working directory, process ID, user ID
- (unless <command> is SUID), group ID (unless command is SGID), groups, etc.
- (In UNIX, the EXEC command is simply a front end for execvp().)
- If the /REDIRECT switch is included, then if a connection is open (SET LINE
- or SET HOST), it becomes the standard input and output of the EXEC'd program.
- If no connection is open, the /REDIRECT switch has no effect. For example
- to use C-Kermit for PPP dialing in Linux:
- set modem type usr ; Specify the kind of modem you have
- set line /dev/ttyS1 ; Specify the device it's connected to
- set speed 57600 ; and the speed
- set flow rts/cts ; and flow control.
- set dial retries 100 ; Try the dial sequence up to 100 times.
- dial {{9-212-555-1212}{9-212-555-1213}{9-212-555-1214}{9-212-555-1215}}
- if fail exit 1
- for %i 1 16 1 { ; Try up to 16 times to get login prompt
- input 10 Login: ; Wait 10 sec for it to appear
- if success break ; Got it - proceed...
- output 13 ; Send a carriage return and try again
- }
- if ( > %i 16 ) stop 1 NO LOGIN PROMPT
- lineout (myuserid) ; Send user ID
- input 30 assword: ; Wait for Password prompt
- if fail stop 1 NO PASSWORD PROMPT
- lineout m(mypassword) ; Send the password.
- exec /redirect pppd ; Replace ourselves with pppd.
- In this example we assume that the script has already set up the myuserid and
- mypassword variables -- normally the password should be prompted for, rather
- than stored on disk. Notice the advantages over the well-known "chat script":
- . You don't have to control the modem itself with AT commands; Kermit's
- DIAL command does this for you.
- . You can have Kermit automatically redial as many times as you want
- until it gets a connection (if this is legal in your country).
- . You can have Kermit fetch the number or numbers from a dialing directory.
- . You can have Kermit cycle through a list of phone numbers (this is new
- to C-Kermit 7.0; see Section 2.1.16) without having to enter the numbers
- in a dialing directory.
- . Dialing is location-independent; you can use the same script to dial from
- different areas or countries.
- . Once the connection is made, the full power of Kermit's script language
- is available to manage the dialog with the terminal server or other
- device that answers the phone call.
- 1.24. Getting Keyword Lists with '?'
- Suppose you type "te" at the C-Kermit> prompt and then Esc or Tab to request
- keyword completion. Kermit beeps, indicating that more than one command
- starts with "te". But if you type '?' to see what they are, Kermit shows
- only "telnet". So why the beep? Because of invisible keywords like "telopt",
- "terminal", and "text". Lots of keywords are invisible because they are
- either synonyms for other keywords or else esoteric options to be used only
- in special circumstances, so we don't want them cluttering up the menus.
- But then there is no way for you to discover them. So in C-Kermit 7.0, if you
- type '?' AFTER the beginning of a keyword field, then invisible keywords are
- shown too:
- C-Kermit>te<Esc><BEEP>
- C-Kermit>te? Command, one of the following:
- telnet telopt terminal text
- C-Kermit>te
- But if '?' is typed at the beginning of a field, only visible keywords are
- shown, as before (so, in this example, if '?' is typed at the C-Kermit>
- prompt, "telnet" is the only command shown that starts with "te").
- (2) MAKING AND USING CONNECTIONS
- The SET LINE, SET HOST, and SET PORT (a synonym for SET LINE) commands have
- new synonyms, in which the word SET is replaced by the word OPEN: OPEN LINE,
- etc. There is no new functionality here, but OPEN is a better verb, since SET
- generally takes no action, whereas these commands actually try to open a
- connection. Furthermore, there is the symmetry with CLOSE.
- 2.0. SET LINE and SET HOST Command Switches
- The SET LINE (SET PORT) and SET HOST commands now allow switches before the
- device or host name, in most cases, and under certain circumstances, also at
- the end. The new syntax is backwards compatible with the previous syntax;
- thus SET LINE, SET PORT, and SET HOST commands in command files written for
- C-Kermit 6.0 or earlier still work. The expanded syntax is:
- { OPEN,SET } { LINE,PORT,HOST } [ switches ] <device-or-address> [ switches ]
- The first group of switches is:
- /NETWORK-TYPE:{TCP/IP,X.25,PIPE,PTY...}
- When more than one network type is available, this lets you specify the
- type of network to use for this connection without affecting your global
- SET NETWORK TYPE. See Section 2.7 about pipes and ptys.
- /USERID:[string]
- This switch is equivalent to SET LOGIN USERID. If a string is given, it
- sent to host during Telnet negotiations; if this switch is given but the
- string is omitted, no user ID is sent to the host. If this switch is not
- given, your current LOGIN USERID (v(userid) value), if any, is sent.
- Unlike most other switches, this one is "sticky", since the value must
- persist throughout the session in case the server requests the ID string
- at a later time.
- /CONNECT
- Enter CONNECT mode immediately and automatically after the device or
- connection is open. On serial devices, however, when CARRIER-WATCH is
- not OFF, wait up to 1 second for the Carrier Detect signal to appear
- before trying to connect, to give the device time to react DTR, which
- might have been off prior to opening the device.
- /SERVER
- Enter server mode immediately and automatically after the device or
- connection is open. Treatment of carrier is the same as for /CONNECT.
- /WAIT
- /NOWAIT
- For Telnet connections only: Like SET TELNET WAIT { ON, OFF }, but applies
- only to this connection, and in fact applies only when OPENing this
- connection (which is usually the only place it matters). Typically you
- would use TELNET /NOWAIT to make a connection to a misbehaving Telnet
- server that does not reply to negotiations as required by the Telnet
- protocol definition.
- Note: /CONNECT and /SERVER switches are not available in the RLOGIN and TELNET
- commands, since these commands already include an implicit /CONNECT and
- preclude automatic entry into server mode.
- The /CONNECT and /SERVER switches are especially useful with "set host *"
- connections. For example, suppose you want to start a Kermit server on socket
- 3000 of your TCP host. Normally you would have to give the command:
- set host * 3000
- and then wait for a connection to come in, and only then could you give the
- SERVER command (or else define a macro to do this, and then execute the macro).
- Now you can do it in one step:
- set host /server * 3000
- This tells C-Kermit to wait for the connection and then enter server mode
- once it comes in, no matter how long it takes. Similarly, "set host /conn *"
- can be used to wait for a "chat" connection to come in.
- Another set of switches is available in VMS only, for use only with SET LINE:
- /SHARE
- Allows the SET LINE device to be opened in shared mode. Normally it makes
- no sense to open a serial device in shared mode, but it's necessary when
- C-Kermit is running in an environment such as DECIntact, that opens your
- job's controlling terminal in such a way that C-Kermit can't open it too,
- unless it enables SHARE privilege. Note: SHARE privilege is required.
- /NOSHARE
- Requires that the SET LINE device not be in use by any other process in
- order for it to be successfully opened by C-Kermit. If neither /SHARE nor
- /NOSHARE is specified, /NOSHARE is used.
- The second group of switches is:
- /NO-TELNET-INIT
- Do not send initial Telnet negotiations even if this is a Telnet port.
- /RAW-SOCKET
- This is a connection to a raw TCP socket (Section 2.3.5).
- /RLOGIN
- Use Rlogin protocol even if this is not an Rlogin port.
- /TELNET
- Send initial Telnet negotiations even if this is not a Telnet port.
- As of C-Kermit 7.0 and K95 1.1.18, the TELNET command includes an implicit
- /TELNET switch. So if you TELNET to a non-TELNET port, Kermit sends initial
- Telnet negotiations. This makes sense, since that's what "telnet" means.
- If you want to make a connection to a non-Telnet port without sending initial
- Telnet negotiations, use:
- set host [ /connect ] <name-or-address> <port>
- or:
- telnet <name-or-address> <port> /no-telnet-init
- Additional switches might be added in the future; type "set host ?" or "set
- line ?" to see a current list.
- 2.1. Dialing
- Automatic redialing is illegal or restricted in many countries, so until
- C-Kermit 7.0, it was disabled by default, i.e. until a SET DIAL RETRIES
- command was given. In C-Kermit 7.0, if no SET DIAL RETRIES command has been
- given, a default is picked dynamically at DIAL time based on the calling
- country code, if known. At this writing, the only country code known to have
- no restrictions on automatic redialing is 1. So in this case a limit of 10
- is chosen; otherwise 1. If you have not given an explicit SET DIAL RETRIES
- command, SHOW DIAL shows the value as "(auto)", and then the value actually
- used is shown when you give the DIAL command.
- As of C-Kermit 7.0, automatic redialing is automatically canceled if the
- call could not be placed because no dialtone was detected.
- 2.1.1. The Dial Result Message
- If DIAL DISPLAY is not ON, the "Call complete" message now shows the modem's
- call result message, for example:
- Dialing: ...
- Call complete: "CONNECT 31200/ARQ/V32/LAPM/V42BIS"
- The exact format and contents of this message, of course, depends on the
- make, model, and configuration of your modem, so use your modem manual to
- interpret it. The call result message is also available in C-Kermit's
- v(dialresult) variable.
- C-Kermit> echo v(dialresult)
- CONNECT 31200/ARQ/V32/LAPM/V42BIS
- C-Kermit> echo Speed = fword(v(dialresult),2)
- Speed = 31200
- C-Kermit>
- Suppose your modem reports the modulation speed as shown above and you want to
- ensure your call is completed at (say) 24000 bps or more. You can use a
- little macro to do the job:
- define HSDIAL { ; High Speed DIAL
- local %s
- if < v(argc) 1 if not def v(dialnumber) end 1 Usage: %0 number
- set dial retries 100
- set dial interval 1
- while true {
- dial %*
- if fail end 1 DIAL failed.
- asg %s fword(v(dialresult),2)
- if def %s if numeric %s if not < %s 24000 break
- }
- }
- (See section 7.5 about the %* variable.)
- 2.1.2. Long-Distance Dialing Changes
- Due to the glut of cell phones, pagers, fax machines, ISPs, etc, area codes
- and dialing rules are changing all the time. In the North American Numbering
- Plan (NANP) countries (USA, Canada, etc), area codes are split or overlayed
- with increasing frequency, and 10- and 11-digit dialing is gradually becoming
- the norm for local calls. Changes are occurring In Europe, too, partly for
- these reasons and partly because of some new EC rules.
- In France, effective 18 October 1996, all calls, even local ones, must be
- dialed with an area code. French area codes are presently 1-digit numbers,
- 1-6, and the long-distance dialing prefix is 0. All calls within France are
- considered long distance and begin with 01, 02, ..., 06.
- Effective 1 May 1997, all calls within the US state of Maryland, even local
- ones, must be dialed with an area code but WITHOUT the long-distance prefix --
- this is the now widely-known North American phenomenon of "ten digit dialing".
- The same is happening elsewhere -- many cities in Florida adopted 10-digit
- dialing in 1998.
- In Italy beginning 19 June 1998, all calls to fixed (as opposed to mobile)
- numbers must be prefixed by 0. When calling into Italy from outside, the 0
- must follow the country code (39). Calls to cell phones, however, must be
- placed without the 0. Then on 29 December 2000, the 0 will become a 4 (for
- calling fixed numbers) and a prefix of 3 must used for calling mobile phones.
- More info at: http://www.telecomitalia.it/npnn/.
- In Spain, effective 4 April 1998, with hard cutover on 18 July 1998, all
- calls within the country must be dialed with 9 digits, and all calls from
- outside Spain must also be dialed with 9 digits (after the country code, 34).
- The new 9-digit numbers all begin with "9". More info at:
- http://www.telefonica.es/cambiodenumeracion/
- Several new dialing features and commands have been added in version 6.1 and
- 7.0 to address these changes.
- C-Kermit 6.0 and Kermit 95 1.1.11 and earlier handle the French situation
- via a reasonable subterfuge (setting the local area code to a nonexistent
- one), but did not handle "ten-digit dialing" well at all; the recommended
- technique was to change the long-distance dialing prefix to nothing, but this
- defeated Kermit's "list numbers for one name" feature when the numbers were in
- different locations. For example:
- set dial ld-prefix
- dial onlineservice
- where "onlineservice" is a dialing directory entry name corresponding to
- entries that are in (say) Maryland as well as other states, would not
- correctly dial the numbers not in Maryland.
- A new command lets you specify a list of area codes to be considered local,
- except that the area code must be dialed:
- SET DIAL LC-AREA-CODES [ areacode [ areacode [ areacode [ ... ] ] ] ]
- The list may include up to 32 area codes. If a number is called whose area
- code is in this list, it is dialed WITHOUT the long-distance prefix, but WITH
- the area code. So in Maryland, which (last time we looked) has two area
- codes, 410 and 301, the setup would be:
- SET DIAL LC-AREA-CODES 410 301
- Example:
- SET DIAL LD-PREFIX 1
- SET DIAL AREA-CODE 301
- SET DIAL LC-AREA-CODES 410 301 <-- Area codes in 10-digit dialing region
- DIAL +1 (301) 765-4321 <-- Dials 3017654321 (local with area code)
- DIAL +1 (410) 765-4321 <-- Dials 4107654321 (local with area code)
- DIAL +1 (212) 765-4321 <-- Dials 12127654321 (long distance)
- The SET DIAL LC-AREA-CODES command does not replace the SET DIAL AREA-CODE
- command. The latter specifies the area code you are dialing from. If the
- called number is in the same area code, then the area code is dialed if it is
- also in the LC-AREA-CODES list, and it is not dialed otherwise. So if "301"
- had not appeared in the LC-AREA-CODES list in the previous example:
- SET DIAL LD-PREFIX 1
- SET DIAL AREA-CODE 301
- SET DIAL LC-AREA-CODES 410 <-- Area codes in 10-digit dialing region
- DIAL +1 (301) 765-4321 <-- Dials 7654321 (local)
- DIAL +1 (410) 765-4321 <-- Dials 4107654321 (local with area code)
- DIAL +1 (212) 765-4321 <-- Dials 12127654321 (long distance)
- The new Kermit versions also add a Local Call Prefix and Local Call Suffix, in
- case you have any need for it. These are added to the beginning and of local
- phone numbers (i.e. numbers that are not long-distance or international).
- Examples:
- SET DIAL LD-PREFIX 1
- SET DIAL LC-PREFIX 9
- SET DIAL LC-SUFFIX *
- SET DIAL LC-AREA-CODES 410 <-- Area codes in 10-digit dialing region
- SET DIAL AREA-CODE 301
- DIAL +1 (301) 765-4321 <-- Dials 97654321* (local)
- DIAL +1 (410) 765-4321 <-- Dials 94107654321* (local with area code)
- DIAL +1 (212) 765-4321 <-- Dials 12127654321 (long distance)
- 2.1.3. Forcing Long-Distance Dialing
- Suppose a number is in your country and area, but for some reason you need to
- dial it long-distance anyway (as is always the case in France). There have
- always been various ways to handle this:
- 1. Temporarily set your area code to a different (or nonexistent or
- impossible) one (but this required knowledge of which area codes were
- nonexistent or impossible in each country).
- 2. Dial the number literally instead of using the portable format, but this
- defeats the purpose of the portable dialing directory.
- Now there is also a new command that, very simply, can force long-distance
- dialing:
- SET DIAL FORCE-LONG-DISTANCE { ON, OFF }
- If a call is placed to a portable phone number within the same country
- code as the calling number, it is dialed with the long-distance prefix
- and the area code if FORCE-LONG-DISTANCE is ON. If OFF, the regular
- rules and procedures apply.
- Example (France):
- SET DIAL COUNTRY-CODE 33
- SET DIAL AREA-CODE 6
- SET DIAL FORCE-LONG-DISTANCE ON
- (In fact, SET DIAL COUNTRY-CODE 33 automatically sets DIAL FORCE-LONG-DISTANCE
- ON...)
- Example (USA, for a certain type of reverse-charge calling in which the
- called number must always be fully specified):
- SET DIAL PREFIX 18002666328$ ; 1-800-COLLECT
- SET DIAL COUNTRY-CODE 1
- SET DIAL AREA-CODE 212
- SET DIAL FORCE-LONG-DISTANCE ON
- Example (Toronto, where calls to exchange 976 within area code 416 must be
- dialed as long distance, even when you are dialing from area code 416):
- SET DIAL COUNTRY-CODE 1
- SET DIAL AREA-CODE 416
- SET DIAL FORCE-LONG-DISTANCE ON
- DIAL +1 (416) 976-xxxx
- If dialing methods were consistent and sensible, of course it would be
- possible to always dial every domestic call as if it were long distance. But
- in many locations this doesn't work or if it does, it costs extra. The
- following macro can be used for dialing any given number with forced
- long-distance format:
- define LDIAL {
- local %x
- set dial force-long-distance on
- dial %*
- asg %x v(success)
- set dial force-long-distance off
- end %x
- }
- (See section 7.5 about the %* variable.)
- 2.1.4. Exchange-Specific Dialing Decisions
- This applies mainly to the North American Numbering Plan (NANP). Refer to the
- section "Alternative notations" in "Using C-Kermit" 2nd Edition, pages
- 106-107, and the story about Toronto on page 110. Using the new LC-AREA-CODES
- list, we can address the problem by treating the exchange as part of the area
- code:
- SET DIAL LD-PREFIX 1
- SET DIAL AREA-CODE 416
- SET DIAL LC-AREA-CODES 905276
- DIAL +1 416 765 4321 <-- 7654321 (local)
- DIAL +1 905 276 4321 <-- 9052764321 (local with area code)
- DIAL +1 905 528 4321 <-- 19055284321 (long distance)
- The same technique can be used in Massachusetts (story at top of page 111)
- and in any other place where dialing to some exchanges within a particular
- area code is local, but to others in the same area code is long distance.
- 2.1.5. Cautions about Cheapest-First Dialing
- Kermit does not maintain a knowledge base of telephony information; it only
- provides the tools to let you enter a phone number in a standard format and
- dial it correctly from any location in most cases.
- In particular, Kermit does not differentiate the charging method from the
- dialing method. If a call that is DIALED as long-distance (e.g. from 212 to
- 718 in country code 1) is not CHARGED as long distance, we have no way of
- knowing that without keeping a matrix of charging information for every
- area-code combination within every country, and any such matrix would be
- obsolete five minutes after it was constructed. Thus, "cheapest-first"
- sorting is only as reliable as our assumption that the charging method follows
- the dialing method. A good illustration would be certain online services that
- have toll-free dialup numbers which they charge you a premium (in your online
- service bill) for using.
- 2.1.6. Blind Dialing (Dialing with No Dialtone)
- C-Kermit's init string for Hayes-like modems generally includes an X4 command
- to enable as many result codes as possible, so that Kermit can react
- appropriately to different failure reasons. One of the result codes that X4
- enables is "NO DIALTONE". A perhaps not obvious side effect of enabling this
- result code that the modem must hear dialtone before it will dial.
- It is becoming increasingly necessary to force a modem to dial even though it
- does not hear a dialtone on the phone line; for example, with PBXs that have
- strange dialtones, or with phone systems in different countries, or with ISDN
- phones, etc. This is called "blind dialing".
- C-Kermit 7.0 has two new commands to cope with this situation:
- SET DIAL IGNORE-DIALTONE { ON, OFF }
- OFF (the default) means to tell the modem to wait for dialtone before
- dialing. ON means to enable "blind dialing", i.e. tell the modem NOT
- to wait for dialtone before dialing. Generally this is accomplished by
- sending ATX3 to the modem just prior to dialing. SET MODEM TYPE xxx
- and then SHOW MODEM displays Kermit's built-in "ignore dialtone" command.
- SET DIAL COMMAND IGNORE-DIALTONE <text>
- This lets you change the built-in ignore-dialtone command (such as ATX3)
- to whatever you choose, in case the built-in one does not work, or another
- command works better.
- Notes:
- 1. The ignore-dialtone command is not sent unless SET DIAL IGNORE-DIALTONE
- is ON.
- 2. The ATX3 command generally disables not only NO DIALTONE, but also BUSY.
- So this will prevent Kermit from detecting when the line is busy. This
- is a property of the modem, not of Kermit.
- 2.1.7. Trimming the Dialing Dialog
- The command:
- SET MODEM COMMAND <action> [ <command> ]
- is used to override Kermit's built-in modem commands for each action, for
- each kind of modem in its internal database. If you include a <command>,
- this is used instead of the built-in one. If you omit the <command>, this
- restores the original built-in command.
- If you want to omit the command altogether, so Kermit doesn't send the command
- at all, or wait for a response, use:
- SET MODEM COMMAND <action> {}
- That is, specify a pair of empty braces as the command, for example:
- SET MODEM COMMAND ERROR-CORRECTION ON {}
- 2.1.8. Controlling the Dialing Speed
- The rate at which characters are sent to the modem during dialing is normally
- controlled by the built-in modem database. You might want to override this
- if Kermit seems to be dialing too slowly, or it is sending characters to the
- modem faster than the modem handle them. A new command was added for this
- in C-Kermit 7.0:
- SET DIAL PACING <number>
- Specifies the number of milliseconds (thousandths of seconds) to pause
- between each character when sending commands to the modem during DIAL or
- ANSWER command execution. 0 means no pause at all, -1 (the default) or any
- other negative number means to use the value from the database. Any number
- greater than 0 is the number of milliseconds to pause.
- HINT: You might also need to control the rate at which the modem generates
- Touch Tones during dialing, for example when sending a numeric page. There
- are two ways to do this. One way is to insert pause characters into the
- dialing string. For modems that use the AT command set, the pause character
- is comma (,) and causes a 2-second pause. On most modems, you can use the S8
- register to change the pause interval caused by comma in the dialing string.
- The other way is to set your modem's tone generation interval, if it has a
- command for that. Most AT-command-set modems use S11 for this; the value is
- in milliseconds. For example on USR modems:
- ATS11=200
- selects an interval of 200 milliseconds to separate each dialing tone.
- Hint: To add S-Register settings or other commands to your dialing procedure,
- use the new SET MODEM COMMAND PREDIAL-INIT command (Section 2.2.2).
- 2.1.9. Pretesting Phone Number Conversions
- The LOOKUP command now accepts telephone numbers as well as directory-entry
- names, for example:
- LOOKUP +1 (212) 7654321
- When given a phone number, LOOKUP prints the result of converting the phone
- number for dialing under the current dialing rules. For example, if my
- country code is 1 and my area code is 212, and I am dialing out from a PBX
- whose outside-line prefix is "93,":
- C-Kermit> lookup +1 (212) 7654321
- +1 (212) 7654321 => 93,7654321
- C-Kermit>
- You can also use the fdialconvert(phone-number) function (Section 2.1.11)
- to do this programmatically:
- C-Kermit> echo "fdialconvert(+1 (212) 7654321)"
- "93,7654321"
- C-Kermit>
- So the new LOOKUP behaves as follows:
- LOOKUP <portable-format-phone-number>
- Displays how the number would actually be dialed
- Sets FAILURE if there was a conversion error, otherwise SUCCESS.
- LOOKUP <literal-format-phone-number>
- Displays the same <literal-format-phone-number>
- Always sets SUCCESS.
- LOOKUP <dialing-directory-name>
- Displays all matching entries and converts portable phone numbers.
- Sets SUCCESS if at least one entry was found, otherwise FAILURE.
- LOOKUP =anything
- Displays "=anything" and sets SUCCESS.
- There is, at present, no programmatic way to fetch numbers from the dialing
- directory. This will be considered for a future release.
- 2.1.10. Greater Control over Partial Dialing
- The following rules now apply to partial dialing:
- . Phone number transformations based on country and area code,
- application of prefixes, etc, are performed only on the first PDIAL.
- . Each PDIAL argument is looked up in the dialing directory, so it is
- possible have directory entries for pieces of phone numbers or other
- information.
- . Suffixes are not applied automatically, since there is no way for C-Kermit
- to know in which PDIAL segment you want them to be applied.
- However, the suffix that *would* have been applied, based on the dialing rules
- that were invoked when processing the first PDIAL command, is stored in the
- variable:
- v(dialsuffix)
- which you can include in any subsequent PDIAL or DIAL commands.
- Example:
- pdial {m(my_long_distance_pager_number_part_1)}
- pdial {m(my_long_distance_pager_number_part_2)}
- pdial {v(dialsuffix)}
- pdial {m(my_long_distance_pager_number_part_3)}
- pdial {@m(numeric_pager_code)#}
- 2.1.11. New DIAL-related Variables and Functions
- fdialconvert(s)
- s is a phone number in either literal or portable format (not a dialing
- directory entry name). The function returns the dial string that would
- actually be used by the DIAL command when dialing from the current location,
- after processing country code, area code, and other SET DIAL values, and
- should be the same as the result of LOOKUP when given a telephone number.
- v(dialsuffix)
- Contains the suffix, if any, that was applied in the most recent DIAL
- command, or the suffix that would have been applied in the most recent PDIAL
- command. Use this variable to send the dial suffix at any desired point in
- a PDIAL sequence.
- v(dialtype)
- A number indicating the type of call that was most recently placed. Can
- be used after a normal DIAL command, or after the first PDIAL command in
- a PDIAL sequence. Values are:
- -2: Unknown because TAPI handled the phone number translation.
- -1: Unknown because some kind of error occured.
- 0: Internal within PBX.
- 1: Toll-free.
- 2: Local within calling area.
- 3: Unknown (e.g. because a literal-format phone number was given).
- 4: Long distance within country.
- 5: International
- v(dialcount)
- The current value of the DIAL retry counter, for use in a DIAL macro
- (Section 2.1.13).
- v(d$px)
- PBX Exchange (see Section 2.1.12).
- Other dial-related variables, already documented in "Using C-Kermit" (or
- other sections of this document, e.g. 2.1.1), include v(dialnumber),
- v(dialstatus), etc. A convenient way to display all of them is:
- show variable dial ; hint: abbreviate "sho var dial"
- This shows the values of all the variables whose names start with "dial".
- Also "show variable d$" (to show the v(d$...) variables).
- 2.1.12. Increased Flexibility of PBX Dialing
- Refer to "Using C-Kermit", 2nd Edition, pages 107-108. Recall that three
- commands are needed to configure C-Kermit for dialing from a PBX:
- SET DIAL PBX-EXCHANGE <number>
- SET DIAL PBX-INSIDE-PREFIX <number>
- SET DIAL PBX-OUTSIDE-PREFIX <number>
- Unfortunately, this model does not accommodate PBXs that have more than one
- exchange. For example our PBX at Columbia University (which must handle more
- than 10,000 phones) has 853-xxxx and 854-xxxx exchanges.
- Beginning in C-Kermit 7.0, the SET DIAL PBX-EXCHANGE command accepts a list of
- exchanges, e.g.:
- SET DIAL PBX-EXCHANGE 853 854
- (multiple exchanges are separated by spaces, not commas).
- So now when dialing a portable-format number that has the same country and
- area codes as those of your dialing location, C-Kermit compares the exchange
- of the dialed number with each number in the PBX Exchange list (rather than
- with a single PBX Exchange number, as it did formerly) to determine whether
- this is an internal PBX number or an external call. If it is an external
- call, then the PBX Outside Prefix is applied, and then the normal dialing
- rules for local or long-distance calls.
- If it is an inside call, the exchange is replaced by the PBX Inside Prefix.
- But if the PBX has more than one exchange, a single fixed PBX Inside Prefix is
- probably not sufficient. For example, at Columbia University, we must dial
- 3-xxxx for an internal call to 853-xxxx, but 4-xxxx for a call to 854-xxxx.
- That is, the inside prefix is the final digit of the exchange we are dialing.
- For this reason, C-Kermit 7.0 provides a method to determine the inside prefix
- dynamically at dialing time, consisting of a new variable and new syntax for
- the SET DIAL PBX-INSIDE-PREFIX command:
- v(d$px)
- This variable contains the exchange that was matched when a PBX internal
- call was detected. For example, if the PBX exchange list is "853 854"
- and a call is placed to +1 (212) 854-9999, v(d$px) is set to 854.
- SET DIAL PBX-INSIDE-PREFIX fxxx(...)
- If the PBX Inside Prefix is defined to be a function, its evaluation is
- deferred until dialing time. Normally, this would be a string function
- having v(d$px) as an operand. Of course, you can still specify a constant
- string, as before.
- So given the following setup:
- SET DIAL COUNTRY-CODE 1
- SET DIAL AREA-CODE 212
- SET DIAL PBX-OUTSIDE-PREFIX 93,
- SET DIAL PBX-EXCHANGE 853 854
- SET DIAL PBX-INSIDE-PREFIX fright(v(d$px),1)
- The following numbers give the results indicated:
- Number Result
- +1 (212) 854-9876 4-9876
- +1 (212) 853-1234 3-1234
- +1 (212) 765-4321 93,765-4321
- +1 (333) 765-4321 93,1333765-4321
- Furthermore, the K_PBX_XCH environment variable may now be set to a list of
- exchanges to automatically initialize C-Kermit's PBX exchange list, for
- example (in UNIX ksh or bash):
- export K_PBX_XCH="853 854"
- (Quotes required because of the space.) Of course, this variable can also be
- set to a single exchange, as before:
- export K_PBX_XCH=853
- 2.1.13. The DIAL macro - Last-Minute Phone Number Conversions
- After a DIAL or LOOKUP command is given, a list of phone numbers is assembled
- from the dialing directory (if any), with all location-dependent conversion
- rules applied as described in Chapter 5 of "Using C-Kermit".
- However, additional conversions might still be required at the last minute
- based on local or ephemeral conditions. So that you can have the final word
- on the exact format of the dial string, C-Kermit 7.0 lets you pass the
- converted string through a macro of your own design for final processing
- before dialing. The relevant command is:
- SET DIAL MACRO [ name ]
- Specifies the name of a macro to be run on each phone number after all
- built-in conversions have been applied, just before the number is dialed.
- If no name is given, no macro is run. The phone number, as it would have
- been dialed if there were no dial macro, is passed to the macro.
- The dial macro can do anything at all (except start a file transfer).
- However, the normal use for the macro would be to modify the phone number.
- For this reason the phone number is passed to the macro as argument number 1
- (%1). To cause a modified number to be dialed, the macro should terminate
- with a RETURN statement specifying a return value. To leave the number alone,
- the macro should simply end. Example:
- define xxx return 10108889999$%1
- set dial macro xxx
- dial xyzcorp
- This defines a DIAL MACRO called xxx, which puts an access code on the
- front of the number. Another example might be:
- def xxx if equal "v(modem)" "hayes-1200" return freplace(%1,$,{,,,,,})
- set dial macro xxx
- dial xyzcorp
- which replaces any dollar-sign in the dial string by a series of five commas,
- e.g. because this particular modem does not support the "wait for bong"
- feature (remember that commas that are to be included literally in function
- arguments must be enclosed in braces to distinguish them from the commas that
- separate the arguments) and when the IF condition is not satisfied, the macro
- does not return a value, and so the number is not modified. Then when a DIAL
- command is given referencing a dialing directory entry, "xyzcorp". The macro
- is automatically applied to each matching number.
- Numerous dial-, modem-, communications-, and time-related variables are
- available for decision making your dial macro. Type SHOW VARIABLES for a
- list. Of particular interest is the v(dialcount) variable, which tells how
- many times the DIAL command gone through its retry loop: 1 on the first try,
- 2 on the second, 3 on the third, and so on, and the v(dialresult) and
- v(dialstatus) variables.
- Here are some other applications for the DIAL MACRO (from users):
- . Phone numbers in the dialing directory are formatted with '-'
- for readability, but some modems don't like the hyphens, so the DIAL
- macro is used to remove them before dialing; e.g 0090-123-456-78-99
- becomes 00901234567899: "def xxx return freplace(%1,-)".
- . To set some specific modem (or other) options depending on the called
- customer or telephone number.
- . Choosing the most appropriate provider based on (e.g.) time of day,
- or cycling through a list of providers in case some providers might
- be busy.
- To illustrate the final item, suppose you have a choice among many phone
- service providers; the provider is chosen by dialing an access code before the
- number. Different providers might be better (e.g. cheaper) for certain times
- of day or days of the week, or for dialing certain locations; you can use the
- DIAL macro to add the access for the most desirable provider.
- Similarly, when the same number might be reached through multiple providers,
- it's possible that one provider might not be able to complete the call, but
- another one can. In that case, you can use the DIAL macro to switch providers
- each time through the DIAL loop -- that's where the v(dialcount) variable
- comes in handy.
- The following command can be used to debug the DIAL macro:
- SET DIAL TEST { ON, OFF }
- Normally OFF, so the DIAL command actually dials. When ON, the DIAL
- command performs all lookups and number conversions, and then goes through
- the number list and retry loop, but instead of actually dialing, lists
- the numbers it would have called if none of the DIAL attempts succeeded
- (or more precisely, every number was always busy).
- 2.1.14. Automatic Tone/Pulse Dialing Selection
- SET DIAL METHOD { AUTO, DEFAULT, PULSE, TONE }
- Chooses the dialing method for subsequent calls.
- Prior to version 7.0, C-Kermit's DIAL METHOD was DEFAULT by default, meaning
- it does not specify a dialing method to the modem, but relies on the modem
- to have an appropriate default dialing method set. So, for example, when
- using Hayes compatible modems, the dial string would be something like
- ATD7654321, rather than ATDT7654321 or ATDP7654321.
- In C-Kermit 7.0 and K95 1.1.18, the dial method can be set from the
- environment variable:
- K_DIAL_METHOD
- when Kermit starts. The values can be TONE, PULSE, or DEFAULT, e.g. (UNIX):
- set K_DIAL_METHOD=TONE; export K_DIAL_METHOD
- In the absence of a K_DIAL_METHOD definition, the new default SET DIAL METHOD
- is AUTO rather than DEFAULT. When DIAL METHOD is AUTO and the local country
- code is known, then if tone dialing is universally available in the
- corresponding area, tone dialing is used; if dialing from a location where
- pulse dialing is mandatory, pulse dialing is used.
- The "tone country" and "pulse country" lists are preloaded according to our
- knowledge at the time of release. You can see their contents in the SHOW
- DIAL listing. You can change the lists with:
- SET DIAL TONE-COUNTRIES [ cc [ cc [ ... ] ] ]
- Replaces the current TONE-COUNTRIES list with the one given. Each cc is
- a country code; separate them with spaces (not commas). Example:
- set dial tone-countries 1 358 44 46 49
- If no country codes are given, the current list, if any, is removed, in
- which case SET DIAL METHOD AUTO is equivalent to SET DIAL METHOD DEFAULT.
- SET DIAL PULSE-COUNTRIES [ cc [ cc [ ... ] ] ]
- Replaces the current PULSE-COUNTRIES list with the one give. Syntax and
- operation is like SET DIAL TONE-COUNTRIES.
- If the same country code appears in both lists, Pulse takes precedence.
- The SET DIAL TONE- and PULSE-COUNTRIES commands perform no verification
- whatsoever on the cc's, since almost any syntax might be legal in some
- settings. Furthermore, there is no facility to edit the lists; you can only
- replace the whole list. However, since the only purpose of these lists is to
- establish a basis for picking tone or pulse dialing automatically, all you
- need to override the effect of the list is to set a specific dialing method
- with SET DIAL METHOD TONE or SET DIAL METHOD PULSE.
- 2.1.15. Dial-Modifier Variables
- As of C-Kermit 7.0, dial modifiers are available in the following variables:
- v(dm_lp) Long pause
- v(dm_sp) Short pause
- v(dm_pd) Pulse dial
- v(dm_td) Tone dial
- v(dm_wa) Wait for answer
- v(dm_wd) Wait for dialtone
- v(dm_rc) Return to command mode
- You can use these in your dial strings in place of hardwired modifiers like
- "@", ",", etc, for increased portability of scripts. Example:
- C-Kermit>set modem type usrobotics
- C-Kermit>sho variables dm
- v(dm_lp) = ,
- v(dm_sp) = /
- v(dm_pd) = P
- v(dm_td) = T
- v(dm_wa) = @
- v(dm_wd) = W
- v(dm_rc) = ;
- C-Kermit>exit
- 2.1.16. Giving Multiple Numbers to the DIAL Command
- Prior to C-Kermit 7.0, the only way to give a DIAL command a list of phone
- numbers to try until one answers was to create a dialing directory that had
- multiple entries under the same name, and then use that entry name in the DIAL
- command. Now a list of numbers can be given to the DIAL command directly in
- the following format:
- dial {{number1}{number2}{number3}...}
- This is the same list format used by SEND /EXCEPT: and other commands that
- allow a list where normally a single item is given. Restrictions on this
- form of the DIAL command are:
- . The first two braces must be adjacent; spacing is optional thereafter.
- . Each number must be an actual number to dial, not a dialing directory entry.
- . Dialing directory entries may not contain number lists in this format.
- In all other respects, the numbers are treated as if they had been fetched
- from the dialing directory; they can be in literal or portable format, etc.
- Example:
- dial {{7654321} {+1 (212) 5551212} { 1-212-5556789 }}
- The list can be any length at all, within reason.
- This feature is especially handy for use with the K95 Dialer, allowing a list
- of phone numbers to be specified in the Telephone Number box without having
- to set up or reference a separate dialing directory.
- You can also use it to add commonly-dialed sequences as variables in your
- C-Kermit customization file, e.g.:
- define work {{7654321}{7654322}{7654323}}
- and then:
- dial {m(work)}
- (the variable name must be enclosed in braces).
- Or more simply:
- define work dial {{7654321}{7654322}{7654323}}
- and then:
- work
- 2.2. Modems
- 2.2.1. New Modem Types
- Since C-Kermit 6.0:
- atlas-newcom-33600ifxC Atlas/Newcom 33600
- att-keepintouch AT&T KeepinTouch PCMCIA V.32bis Card Modem
- att-1900-stu-iii AT&T Secure Data STU-III Model 1900
- att-1910-stu-iii AT&T Secure Data STU-III Model 1910
- bestdata Best Data
- cardinal Cardinal V.34 MVP288X series.
- compaq Compaq Data+Fax (e.g. in Presario)
- fujitsu Fujitsu Fax/Modem Adapter
- generic-high-speed Any modern error-correcting data-compressing modem
- itu-t-v25ter/v250 ITU-T (CCITT) V.25ter (V.250) standard command set
- megahertz-att-v34 Megahertz AT&T V.34
- megahertz-xjack Megahertz X-Jack
- motorola-codex Motorola Codex 326X Series
- motorola-montana Motorola Montana
- mt5634zpx Multitech MT5634ZPX
- rockwell-v90 Rockwell V.90 56K
- rolm-244pc Siemens/Rolm 244PC (AT command set)
- rolm-600-series Siemens/Rolm 600 Series (AT command set)
- spirit-ii QuickComm Spirit II
- suprasonic SupraSonic V288+
- supra-express-v90 Supra Express V.90
- One of the new types, "generic-high-speed" needs a bit of explanation. This
- type was added to easily handle other types that are not explicitly covered,
- without going through the bother of adding a complete user-defined modem type.
- This one works for modern modems that use the AT command set, on the
- assumption that all the default ("factory") settings of the modem (a) are
- appropriate for Kermit, (b) include error correction, data compression,
- and speed buffering; and (c) are recallable with the command AT&F.
- If the command to recall your modem's profile is not AT&F, use the SET MODEM
- COMMAND INIT-STRING command to specify the appropriate modem command. The
- default init-string is AT&F13 (that is, AT, ampersand, F, and then carriage
- return); a survey of about 20 modern modem types shows they all support this,
- but they might mean different things by it. For example, the USR Sportster or
- Courier needs AT&F1 (not AT&F, which is equivalent to AT&F0, which recalls an
- inappropriate profile), so for USR modems:
- set modem type generic-high-speed
- set modem command init AT&F113
- Of course, USR modems already have their own built-in modem type. But if you
- use this one instead, it will dial faster because it has fewer commands to
- give to the modem; in that sense "&F1" is like a macro that bundles numerous
- commands into a single one. See your modem manual for details about factory
- profiles and commands to recall them.
- WARNING: Do not use the generic-high-speed modem type in operating systems
- like VMS where hardware flow control is not available, at least not unless you
- change the init string from AT&F13 to something else that enables local
- Xon/Xoff or other appropriate type of flow control.
- Also see Section 2.1.7 for additional hints about making dialing go faster.
- 2.2.2. New Modem Controls
- SET MODEM CAPABILITIES <list>
- In C-Kermit 7.0, this command automatically turns MODEM SPEED-MATCHING OFF
- if SB (Speed Buffering) is in the <list>, and turns it ON if SB is absent.
- SET MODEM COMMAND PREDIAL-INIT [ <text> ]
- Commands to be sent to the modem just prior to dialing. Normally none.
- SET MODEM SPEAKER { ON, OFF }
- Determines whether modem speaker is on or off while call is being placed.
- ON by default. Note: This command does not provide fine-grained control
- over when the speaker is on or off. Normally, ON means while the call is
- being placed, until the point at which carrier is successfully established.
- If your modem has a different speaker option that you want to choose, then
- use the SET MODEM COMMAND SPEAKER ON <text> command to specify this option.
- SET MODEM COMMAND SPEAKER { ON, OFF } [ <text> ]
- Specify or override the commands to turn your modem's speaker on and off.
- SET MODEM VOLUME { LOW, MEDIUM, HIGH }
- When MODEM SPEAKER is on, select volume. Note: In some modems, especially
- internal ones, these commands have no effect; this is a limitation of the
- particular modem, not of Kermit.
- SET MODEM COMMAND VOLUME { LOW, MEDIUM, HIGH } [ <text> ]
- Specify or override the commands to set your modem's speaker volume.
- SET MODEM COMMAND IGNORE-DIALTONE [ <text> ]
- The command to enable blind dialing (section 2.1.6).
- SET MODEM ESCAPE-CHARACTER <code>
- Has been augmented to allow codes of 0 or less:
- < 0 means the escape mechanism is disabled.
- = 0 means to use (restore) the default value from the modem database.
- > 0 and < 128 is a literal value to be used instead of the default one.
- > 127 means the escape mechanism is disabled.
- This affects "modem hangup". When the escape mechanism is disabled, but
- SET MODEM HANGUP-METHOD is MODEM-COMMAND, it sends the hangup command
- immediately, without the <pause>+++<pause> business first. This is useful
- (for example) when sending lots of numeric pages, a process in which we
- never go online, and so never need to escape back. Eliminating the
- unnecessary pauses and escape sequence allows a lot more pages to be sent
- per unit time.
- Recall that C-Kermit can dial modems to which it is connected via TCP/IP
- (Telnet or Rlogin) as described on page 126 of "Using C-Kermit", 2nd Ed.
- In this case the MODEM HANGUP-METHOD should be MODEM-COMMAND, since RS-232
- signals don't work over TCP/IP connections. As noted in the manual, such
- connections are set up by the following sequence:
- set host <host> [ <port> ]
- set modem type <name>
- dial <number>
- But this can cause complications when you use Kermit to switch between serial
- and TCP/IP connections. In the following sequence:
- set host <name>
- set modem type <name>
- set port <name>
- the first two commands obey the rules for dialing out over Telnet. However,
- the SET PORT command requires that Kermit close its current (Telnet)
- connection before it can open the serial port (since Kermit can only have one
- connection open at a time). But since a modem type was set after the "set
- host" command was given, Kermit assumes it is a Telnet dialout connection and
- so sends the modem's hangup sequence is sent to the Telnet host. To avoid
- this, close the network connection explicitly before opening the serial one:
- set host <name>
- close
- set modem type <name>
- set port <name>
- 2.3. TELNET and RLOGIN
- For additional background, please also read the TELNET.TXT file.
- Cautions:
- If making a Telnet connection with C-Kermit takes a very long time, like
- over a minute, whereas the system Telnet program makes the same connection
- immediately, try including the /NOWAIT switch:
- C-Kermit> telnet /nowait hostname
- See TELNET.TXT for details. If it also takes a very long time to make a
- Telnet connection with system Telnet, then the delay is most likely caused
- by reverse DNS lookups when your host is not properly registered in DNS.
- When supplying numeric IP addresses to C-Kermit or to any other application
- (regular Telnet, Rlogin, etc), do not include leading 0's in any fields unless
- you intend for those fields to be interpreted as octal (or hex) numbers. The
- description of the Internet address interpreter (the sockets library
- inet_addr() routine) includes these words:
- All numbers supplied as "parts" in a "." notation may be decimal, octal,
- or hexadecimal, as specified in the C language (that is, a leading 0x or
- 0X implies hexadecimal; otherwise, a leading 0 implies octal; otherwise,
- the number is interpreted as decimal).
- To illustrate, 128.59.39.2 and 128.059.039.002 are NOT the same host! Even
- though most of the fields contain non-octal digits. Using system Telnet (not
- Kermit):
- $ telnet 128.059.039.002
- Trying 128.49.33.2 ...
- Of course the same thing happens with Kermit because it uses (as it must) the
- same system service for resolving network addresses that Telnet, FTP, and all
- other TCP/IP applications use.
- The RLOGIN section on page 123 does not make it clear that you can use the
- SET TELNET TERMINAL-TYPE command to govern the terminal type that is reported
- by C-Kermit to the RLOGIN server.
- Note that the SET TCP commands described on pages 122-123 might be absent;
- some platforms that support TCP/IP do not support these particular controls.
- New commands:
- TELOPT { AO, AYT, BREAK, CANCEL, EC, EL, EOF, EOR, GA, IP, DMARK, DO, DONT,
- NOP, SB, SE, SUSP, WILL, WONT }
- This command was available previously, but supported only DO, DONT, WILL,
- and WONT. Now it lets you send all the Telnet protocol commands. Note
- that certain commands do not require a response, and therefore can be used
- as nondestructive "probes" to see if the Telnet session is still open; e.g.:
- set host xyzcorp.com
- ...
- telopt nop
- if fail stop 1 Connection lost
- SET TCP ADDRESS [ <ip-address> ]
- Specifies the IP address of the computer that C-Kermit is running on.
- Normally this is not necessary. The exception would be if your
- machine has multiple network adapters (physical or virtual) with a
- different address for each adapter AND you want C-Kermit to use a
- specific address when making outgoing connections or accepting
- incoming connections.
- SET TCP DNS-SERVICE-RECORDS {ON, OFF}
- Tells C-Kermit whether to try to use DNS SRV records to determine the
- host and port number upon which to find an advertised service. For
- example, if a host wants regular Telnet connections redirected to some
- port other than 23, this feature allows C-Kermit to ask the host which
- port it should use. Since not all domain servers are set up to answer
- such requests, this feature is OFF by default.
- SET TCP REVERSE-DNS-LOOKUP { ON, OFF, AUTO }
- Tells Kermit whether to perform a reverse DNS lookup on TCP/IP connections.
- This allows Kermit to determine the actual hostname of the host it is
- connected to, which is useful for connections to host pools, and is required
- for Kerberos connections to host pools and for incoming connections. If the
- other host does not have a DNS entry, the reverse lookup could take a long
- time (minutes) to fail, but the connection will still be made. Turn this
- option OFF for speedier connections if you do not need to know exactly which
- host you are connected to and you are not using Kerberos. AUTO, the
- default, means the lookup is done on hostnames, but not on numeric IP
- addresses.
- SET TELNET WAIT-FOR-NEGOTIATIONS { ON, OFF }
- Each Telnet option must be fully negotiated either On or Off before the
- session can continue. This is especially true with options that require
- sub-negotiations such as Authentication, Encryption, and Kermit; for
- proper support of these options Kermit must wait for the negotiations to
- complete. Of course, Kermit has no way of knowing whether a reply is
- delayed or not coming at all, and so will wait a minute or more for
- required replies before continuing the session. If you know that Kermit's
- Telnet partner will not be sending the required replies, you can set this
- option of OFF to avoid the long timeouts. Or you can instruct Kermit to
- REFUSE specific options with the SET TELOPT command.
- SET TELOPT [ { /CLIENT, /SERVER } ] <option> -
- { ACCEPTED, REFUSED, REQUESTED, REQUIRED } -
- [ { ACCEPTED, REFUSED, REQUESTED, REQUIRED } ]
- SET TELOPT lets you specify policy requirements for Kermit's handling of
- Telnet option negotiations. Setting an option is REQUIRED causes Kermit
- to offer the option to the peer and disconnect if the option is refused.
- REQUESTED causes Kermit to offer an option to the peer. ACCEPTED results
- in no offer but Kermit will attempt to negotiate the option if it is
- requested. REFUSED instructs Kermit to refuse the option if it is
- requested by the peer.
- Some options are negotiated in two directions and accept separate policies
- for each direction; the first keyword applies to Kermit itself, the second
- applies to Kermit's Telnet partner; if the second keyword is omitted, an
- appropriate (option-specific) default is applied. You can also include a
- /CLIENT or /SERVER switch to indicate whether the given policies apply
- when Kermit is the Telnet client or the Telnet server; if no switch is
- given, the command applies to the client.
- Note that some of Kermit's Telnet partners fail to refuse options that
- they do not recognize and instead do not respond at all. In this case it
- is possible to use SET TELOPT to instruct Kermit to REFUSE the option
- before connecting to the problem host, thus skipping the problematic
- negotiation.
- Use SHOW TELOPT to view current Telnet Option negotiation settings.
- SHOW TELNET displays current Telnet settings.
- 2.3.0. Bug Fixes
- If "set host nonexistent-host" was given (and it properly failed), followed by
- certain commands like SEND, the original line and modem type were not restored
- and C-Kermit thought that it still had a network hostname; fixed in 7.0.
- 2.3.1. Telnet Binary Mode Bug Adjustments
- SET TELNET BUG BINARY-ME-MEANS-U-TOO { ON, OFF } was added to edit 192
- after the book was printed. Also SET TELNET BUG BINARY-U-MEANS-ME-TOO.
- The default for both is OFF. ON should be used when communicating with a
- Telnet partner (client or server) that mistakenly believes that telling
- C-Kermit to enter Telnet binary mode also means that it, too, is in binary
- mode, contrary to the Telnet specification, which says that binary mode must
- be negotiated in each direction separately.
- 2.3.2. VMS UCX Telnet Port Bug Adjustment
- A new command, SET TCP UCX-PORT-BUG, was added for VMS versions with UCX (DEC
- TCP/IP), applying only to early versions of UCX, like 2.2 or earlier. If you
- try to use VMS C-Kermit to make a Telnet connection using a port name (like
- "telnet", which is used by default), the underlying UCX getservbyname()
- function might return the service number with its bytes swapped and the
- connection will fail. If "telnet hostname 23" works, then your version of UCX
- has this bug and you can put "set tcp ucx-port-bug on" in your CKERMIT.INI
- file to get around it.
- 2.3.3. Telnet New Environment Option
- The TELNET NEW-ENVIRONMENT option (RFC1572) is supported as 7.0. This option
- allows the C-Kermit Telnet client to send certain well-known variables to the
- Telnet server, including USER, PRINTER, DISPLAY, and several others. This
- feature is enabled by default in Windows and OS/2, disabled by default
- elsewhere. The command to enable and disable it is:
- SET TELNET ENVIRONMENT { ON, OFF }
- When ON, and you Telnet to another computer, you might (or might not) notice
- that the "login:" or "Username:" prompt does not appear -- that's because your
- username was sent ahead, in which case the remote system might prompt you only
- for your password (similar to Rlogin). Use "set telnet environment off" to
- defeat this feature, particularly in scripts where the dialog must be
- predictable. You can also use this command to specify or override specific
- well-known environment variable values:
- SET TELNET ENVIRONMENT { ACCT,DISPLAY,JOB,PRINTER,SYSTEMTYPE,USER } [ <text> ]
- 2.3.4. Telnet Location Option
- The TELNET LOCATION option (RFC779) is supported in 7.0. This option allows
- the C-Kermit Telnet client to send a location string to the server if the
- server indicates its willingness to accept one. If an environment variable
- named LOCATION exists at the time C-Kermit starts, its value is used as the
- location string. If you want to change it, use:
- SET TELNET LOCATION <text>
- If you omit the <text> from this command, the Telnet location feature is
- disabled.
- SET TELNET ENVIRONMENT DISPLAY is used to set the DISPLAY variable that is
- sent to the host, as well as the the XDISPLAY location.
- 2.3.5. Connecting to Raw TCP Sockets
- The SET HOST and TELNET commands now accept an optional switch, /RAW-SOCKET,
- at the end, only if you first give a host and a port. Example:
- set host xyzcorp.com 23 /raw-socket
- set host 128.49.39.2:2000 /raw-socket
- telnet xyzcorp.com 3000 /raw
- Without this switch, C-Kermit behaves as a Telnet client when (a) the port is
- 23 or 1649, or (b) the port is not 513 and the server sent what appeared to be
- Telnet negotiations -- that is, messages starting with 0xFF (IAC). With this
- switch, Kermit should treat all incoming bytes as raw data, and will not
- engage in any Telnet negotiations or NVT CRLF manipulations. This allows
- transparent operation through (e.g.) raw TCP ports on Cisco terminal servers,
- through the 'modemd' modem server, etc.
- 2.3.6. Incoming TCP Connections
- Accomplished via SET HOST * <port>, were introduced in C-Kermit 6.0, but for
- UNIX only. In Version 7.0, they are also available for VMS.
- 2.4. The EIGHTBIT Command
- EIGHTBIT is simply a shorthand for: SET PARITY NONE, SET TERMINAL BYTESIZE 8,
- SET COMMAND BYTESIZE 8; that is, a way to set up an 8-bit clean connection
- in a single command.
- 2.5. The Services Directory
- Chapter 7 of "Using C-Kermit" does not mention the ULOGIN macro, which is
- used by our sample services directory, CKERMIT.KND. Unlike UNIXLOGIN,
- VMSLOGIN, etc, this one is for use with systems that require a user ID but
- no password. Therefore it doesn't prompt for a password or wait for a
- password prompt from the remote service.
- In version 7.0, the CALL macro was changed to not execute a SET MODEM TYPE
- command if the given modem type was the same as the current one; otherwise the
- new SET MODEM TYPE command would overwrite any customizations that the user
- had made to the modem settings. Ditto for SET LINE / SET PORT and SET SPEED.
- 2.6. Closing Connections
- Until version 7.0, there was never an obvious and general way to close a
- connection. If a serial connection was open, it could be closed by "set
- line" or "set port" (giving no device name); if a network connection was
- open, it could be closed by "set host" (no host name).
- In version 7.0, a new command closes the connection in an obvious and
- straightforward way, no matter what the connection type:
- CLOSE [ CONNECTION ]
- The CLOSE command was already present, and required an operand such as
- DEBUG-LOG, WRITE-FILE, etc, and so could never be given by itself. The new
- CONNECTION operand is now the default operand for CLOSE, so CLOSE by itself
- closes the connection, if one is open, just as you would expect, especially
- if you are a Telnet or Ftp user.
- Also see the description of the new SET CLOSE-ON-DISCONNECT command in
- Section 2.10.
- 2.7. Using C-Kermit with External Communication Programs
- C-Kermit 7.0 includes a new ability to create and conduct sessions through
- other communications programs. Two methods are available:
- a. Pty (pseudoterminal): The external program is run on a "pseudoterminal",
- which is controlled by Kermit. This method works with practically any
- external program, but it is not portable. At this writing, it works only
- on some (not all) UNIX versions, and not on any non-UNIX platforms.
- b. Pipe: The external program's standard input and output are redirected
- through a "pipe" controlled by Kermit. This method is relatively
- portable -- it should work across all UNIX versions, and it also works
- in Windows and OS/2 -- but it is effective only when the external
- program actually uses standard i/o (and many don't).
- The two methods are started differently but are used the same way thereafter.
- The purpose of this feature is to let you use C-Kermit services like file
- transfer, character-set translation, scripting, automatic dialing, etc, on
- connections that Kermit can't otherwise make itself.
- This feature is the opposite of the REDIRECT feature, in which C-Kermit makes
- the connection, and redirects an external (local) command or program over this
- connection. In a pty or pipe connection, C-Kermit runs and controls a local
- command or program, which makes the connection. (The same method can be used
- to simply to control a local program without making a connection; see Section
- 2.8.)
- To find out if your version of Kermit includes PTY support, type "show
- features" and look for NETPTY in the alphabetical list of options. For pipes,
- look for NETCMD.
- The commands are:
- SET NETWORK TYPE PTY or SET NETWORK TYPE PIPE
- SET HOST <command>
- where <command> is any interactive command. If the command does not use
- standard i/o, you must use SET NETWORK TYPE PTY.
- Notes:
- a. COMMAND is an invisible synonym for PIPE.
- b. The <command> and its arguments are case-sensitive in UNIX.
- The SET NETWORK TYPE, SET HOST sequence sets the given network type for all
- subsequent SET HOST commands until another SET NETWORK TYPE command is given
- to change it.
- You can also use the new /NETWORK-TYPE:PTY or /NETWORK-TYPE:PIPE (or simply
- /PIPE or /PTY) switches on the SET HOST command itself:
- SET HOST /NETWORK-TYPE:PIPE <command> ; These two are the same
- SET HOST /PIPE <command>
- SET HOST /NETWORK-TYPE:PTY <command> ; Ditto
- SET HOST /PTY <command>
- These are like SET NETWORK TYPE followed by SET HOST, except they apply only
- to the connection being made and do not change the global network type setting
- (see Section 1.5 about the difference between switches and SET commands).
- Include any command-line options with the <command> that might be needed, as
- in this example where C-Kermit uses another copy of itself as the
- communications program:
- SET HOST /PIPE /CONNECT kermit -YQJ xyzcorp.com
- As usual, if you include the /CONNECT switch, SET HOST enters CONNECT mode
- immediately upon successful execution of the given command. Therefore a new
- command is available as a shorthand for SET HOST /CONNECT /PTY:
- PTY [ <command> ]
- And for SET HOST /CONNECT /PIPE:
- PIPE [ <command> ]
- Thus, the PTY and PIPE commands work like the TELNET and RLOGIN commands: they
- set up the connection (in this case, using the given command) and then enter
- CONNECT mode automatically (if the PIPE or PTY command is given without a
- <command>, it continues the current session if one is active; otherwise it
- gives an error message).
- The PIPE command is named after the mechanism by which C-Kermit communicates
- with the <command>: UNIX pipes. C-Kermit's i/o is "piped" through the given
- command. Here is a typical example:
- PIPE rlogin -8 xyzcorp.com
- This is equivalent to:
- SET HOST /PIPE rlogin -8 xyzcorp.com
- CONNECT
- and to:
- SET HOST /PIPE /CONNECT rlogin -8 xyzcorp.com
- IMPORTANT:
- If you are writing a script, do not use the PIPE, PTY, TELNET, or RLOGIN
- command unless you really want C-Kermit to enter CONNECT mode at that
- point. Normally SET HOST is used in scripts to allow the login and
- other dialogs to be controlled by the script itself, rather than by
- an actively participating human at the keyboard.
- Throughput of pty and pipe connections is limited by the performance of the
- chosen command or program and by the interprocess communication (IPC) method
- used and/or buffering capacity of the pipe or pty, which in turn depends on
- the underlying operating system.
- In one trial (on SunOS 4.1.3), we observed file transfer rates over an rlogin
- connection proceeding at 200Kcps for downloads, but only 10Kcps for uploads on
- the same connection with the same settings (similar disparities were noted in
- HP-UX). Examination of the logs revealed that a write to the pipe could take
- as long as 5 seconds, whereas reads were practically instantaneous. On the
- other hand, using Telnet as the external program rather than rlogin, downloads
- and uploads were better matched at about 177K each.
- Most external communication programs, like C-Kermit itself, have escape
- characters or sequences. Normally these begin with (or consist entirely of) a
- control character. You must be sure that this control character is not
- "unprefixed" when uploading files, otherwise the external program will "escape
- back" to its prompt, or close the connection, or take some other unwanted
- action. When in CONNECT mode, observe the program's normal interaction rules.
- Of course C-Kermit's own escape character (normally Ctrl-) is active too,
- unless you have taken some action to disable it.
- On PTY connections, the underlying PTY driver is not guaranteed to be
- transparent to control characters -- for example, it might expand tabs,
- translate carriage returns, generate signals if it sees an interrupt
- character, and so on. Similar things might happen on a PIPE connection. For
- this reason, if you plan to transfer files over a PTY or PIPE connection, tell
- the file sender to:
- SET PREFIXING ALL
- This causes all control characters to be prefixed and transmitted
- as printable ASCII characters.
- If the external connection program is not 8-bit clean, you should also:
- SET PARITY SPACE
- This causes 8-bit data to be encoded in 7 bits using single and/or
- locking shifts.
- And if it does not make a reliable connection (such as those made by Telnet,
- Rlogin, Ssh, etc), you should:
- SET STREAMING OFF
- This forces C-Kermit to treat the connection as unreliable and
- to engage in its normal ACK/NAK protocol for error detection and
- correction, rather than "streaming" its packets, as it normally
- does on a network connection (Section 4.20).
- In some cases, buffer sizes might be restricted, so you might also need to
- reduce the Kermit packet length to fit; this is a trial-and-error affair. For
- example, if transfers always fail with 4000-byte packets, try 2000. If that
- fails too, try 1000, and so on. The commands are:
- SET RECEIVE PACKET-LENGTH <number>
- This tells the file receiver to tell the file sender the longest
- packet length it can accept.
- SET SEND PACKET-LENGTH <number>
- This tells the file sender not to send packets longer than the given
- length, even if the receiver says longer ones are OK. Of course, if
- the receiver's length is shorter, the shorter length is used.
- If none of this seems to help, try falling back to the bare minimum,
- lowest-common-denominator protocol settings:
- ROBUST
- No sliding windows, no streaming, no control-character unprefixing,
- packet length 90.
- And then work your way back up by trial and error to get greater throughput.
- Note that when starting a PIPE connection, and the connection program (such as
- telnet or rlogin) prints some greeting or information messages before starting
- the connection, these are quite likely to be printed with a stairstep effect
- (linefeed without carriage return). This is because the program is not
- connected with the UNIX terminal driver; there's not much Kermit can do about
- it. Once the connection is made, everything should go back to normal. This
- shouldn't happen on a PTY connection because a PTY is, indeed, a terminal.
- On a similar note, some connection programs (like Solaris 2.5 rlogin) might
- print lots of error messages like "ioctl TIOCGETP: invalid argument" when
- used through a pipe. They are annoying but usually harmless. If you want to
- avoid these messages, and your shell allows redirection of stderr, you can
- redirect stderr in your pipe command, as in this example where the user's
- shell is bash:
- PIPE rlogin xyzcorp.com 2> /dev/null
- Or use PTY rather than PIPE, since PTY is available on Solaris.
- 2.7.0. C-Kermit over tn3270 and tn5250
- Now you can make a connection from C-Kermit "directly" to an IBM mainframe and
- transfer files with it, assuming it has Kermit-370 installed. Because tn3270
- is neither 8-bit clean nor transparent to control characters, you must give
- these commands:
- SET PREFIXING ALL ; Prefix all control characters
- SET PARITY SPACE ; Telnet connections are usually not 8-bit clean
- and then:
- SET HOST /PTY /CONNECT tn3270 abccorp.com
- or simply:
- pty tn3270 abccorp.com
- SET HOST /PIPE does not work in this case, at least not for file transfer.
- File transfer does work, however, with SET HOST /PTY, provided you use the
- default packet length of 90 bytes; anything longer seems to kill the session.
- You can also make connections to IBM AS/400 computers if you have a tn5250
- program installed:
- pty tn5250 <hostname>
- In this case, however, file transfer is probably not in the cards since
- nobody has ever succeeded in writing a Kermit program for the AS/400.
- Hint:
- define tn3270 {
- check pty
- if fail end 1 Sorry - no PTY support...
- pty tn3270 %*
- }
- Similarly for tn5250. Note that CHECK PTY and CHECK PIPE can be used in
- macros and scripts to test whether PTY or PIPE support is available.
- 2.7.1. C-Kermit over Telnet
- Although C-Kermit includes its own Telnet implementation, you might need to
- use an external Telnet program to make certain connections; perhaps because it
- has access or security features not available in C-Kermit itself. As noted
- above, the only precautions necessary are usually:
- SET PREFIXING ALL ; Prefix all control characters
- SET PARITY SPACE ; Telnet connections might not be 8-bit clean
- and then:
- SET HOST /PTY (or /PIPE) /CONNECT telnet abccorp.com
- or, equivalently:
- PTY (or PIPE) telnet abccorp.com
- 2.7.2. C-Kermit over Rlogin
- C-Kermit includes its own Rlogin client, but this can normally be used only if
- you are root, since the rlogin TCP port is privileged. But ptys and pipes let
- you make rlogin connections with C-Kermit through your computer's external
- rlogin program, which is normally installed as a privileged program:
- SET PREFIXING ALL
- and then:
- SET HOST /PTY (or /PIPE) /CONNECT rlogin -8 abccorp.com
- or, equivalently:
- PTY (or PIPE) rlogin -8 abccorp.com
- The "-8" option to rlogin enables transmission of 8-bit data. If this is
- not available, then include SET PARITY SPACE if you intend to transfer files.
- Note that the normal escape sequence for rlogin is Carriage Return followed by
- Tilde (~), but only when the tilde is followed by certain other characters;
- the exact behavior depends on your rlogin client, so read its documentation.
- 2.7.3. C-Kermit over Serial Communication Programs
- Ptys and pipes also let you use programs that make serial connections, such as
- cu or tip. For example, C-Kermit can be used through cu to make connections
- that otherwise might not be allowed, e.g. because C-Kermit is not installed
- with the required write permissions to the dialout device and the UUCP
- lockfile directory.
- Suppose your UUCP Devices file contains an entry for a serial device tty04 to
- be used for direct connections, but this device is protected against you (and
- Kermit when you run it). In this case you can:
- SET CONTROL PREFIX ALL
- PTY (or PIPE) cu -l tty04
- (Similarly for dialout devices, except then you also need to include the phone
- number in the "cu" command.)
- As with other communication programs, watch out for cu's escape sequence,
- which is the same as the rlogin program's: Carriage Return followed by Tilde
- (followed by another character to specify an action, like "." for closing the
- connection and exiting from cu).
- 2.7.4. C-Kermit over Secure Network Clients
- DISCLAIMER: There are laws in the USA and other countries regarding
- use, import, and/or export of encryption and/or decryption or other
- forms of security software, algorithms, technology, and intellectual
- property. The Kermit Project attempts to follow all known statutes,
- and neither intends nor suggests that Kermit software can or should
- be used in any way, in any location, that circumvents any regulations,
- laws, treaties, covenants, or other legitimate canons or instruments
- of law, international relations, trade, ethics, or propriety.
- For secure connections or connections through firewalls, C-Kermit 7.0 can be a
- Kerberos, SRP, and/or SOCKS client when built with the appropriate options and
- libraries. But other application-level security acronyms and methods -- SSH,
- SSL, SRP, TLS -- pop up at an alarming rate and are (a) impossible to keep up
- with, (b) usually mutually incompatible, and (c) have restrictions on export
- or redistribution and so cannot be included in C-Kermit itself.
- However, if you have a secure text-based Telnet (or other) client that employs
- one of these security methods, you can use C-Kermit "through" it via a pty
- or pipe.
- 2.7.4.1. SSH
- C-Kermit does not and can not incorporate SSH due to licensing, patent,
- and USA export law restrictions.
- The UNIX SSH client does not use standard input/output, and therefore can be
- used only by Kermit's PTY interface, if one is present. The cautions about
- file transfer, etc, are the same as for Rlogin. Example:
- SET PREFIXING ALL
- PTY ssh XYZCORP.COM
- Or, for a scripted session:
- SET PREFIXING ALL
- SET HOST /PTY ssh XYZCORP.COM
- Hint:
- define ssh {
- check pty
- if fail end 1 Sorry - no PTY support...
- pty ssh %*
- }
- 2.7.4.2. SSL
- Secure Sockets Layer (SSL) is another TCP/IP security overlay, this one
- designed by and for Netscape. An SSL Telnet client is available for UNIX
- from the University of Queensland. More info at:
- http://www.psy.uq.oz.au/~ftp/Crypto/
- Interoperability with C-Kermit is unknown. C-Kermit also includes its own
- built-in SSL/TLS support, but it is not exportable; see the C-Kermit
- security.txt file for details.
- 2.7.4.3. SRP
- SRP(TM) is Stanford University's Secure Remote Password protocol. An SRP
- Telnet client is available from Stanford:
- http://srp.stanford.edu/srp/
- Stanford's SRP Telnet client for UNIX has been tested on SunOS and works fine
- with C-Kermit, as described in Section 2.7.1, e.g.
- SET PREFIX ALL
- PTY (or PIPE) srp-telnet xenon.stanford.edu
- C-Kermit itself can be built as an SRP Telnet client on systems that have
- libsrp.a installed; the C-Kermit support code, however, may not be exported
- outside the USA or Canada.
- 2.7.4.4. SOCKS
- C-Kermit can be built as a SOCKS-aware client on systems that have a SOCKS
- library. See section 8.1.1 of the ckccfg.txt file.
- C-Kermit 7.0 can also be run over SOCKSified Telnet or rlogin clients with SET
- NETWORK TYPE COMMAND. Suppose the Telnet program on your system is SOCKS
- enabled but C-Kermit is not. Make Kermit connections like this:
- SET PREFIX ALL
- PTY (or PIPE) telnet zzz.com
- 2.7.4.5. Kerberos
- UNIX C-Kermit can be built with MIT Kerberos IV or V authentication and
- encryption. Instructions are available in a separate document, security.txt.
- Additional modules are required that can not be exported from the USA to any
- country except Canada, by US law.
- If you have Kerberos installed but you don't have a Kerberized version of
- C-Kermit, you can use ktelnet as C-Kermit's external communications program
- to make secure connections without giving up C-Kermit's services:
- SET PREFIX ALL
- PTY (or PIPE) ktelnet cia.gov
- 2.8. Scripting Local Programs
- If your version of Kermit has PTY support built in, then any text-based
- program can be invoked with SET HOST /PTY or equivalent command and controlled
- using the normal sequence of OUTPUT, INPUT, IF SUCCESS commands (this is the
- same service that is provided by the 'expect' program, but controlled by the
- Kermit script language rather than Tcl).
- When PTY service is not available, then any program that uses standard input
- and output can be invoked with SET HOST /PIPE.
- Here's an example in which we start an external Kermit program, wait for its
- prompt, give it a VERSION command, and then extract the numeric version number
- from its response:
- set host /pty kermit -Y
- if fail stop 1 {Can't start external command}
- input 10 C-Kermit>
- if fail stop 1 {No C-Kermit> prompt}
- output version13
- input 10 {Numeric: }
- if fail stop 1 {No match for "Numeric:"}
- clear input
- input 10 10
- echo VERSION = "fsubstr(v(input),1,6)"
- output exit13
- This technique could be used to control any other interactive program, even
- those that do screen formatting (like Emacs or Vi), if you can figure out the
- sequence of events. If your Kermit program doesn't have PTY support, then the
- commands are restricted to those using standard i/o, including certain shells,
- interactive text-mode "hardcopy" editors like ex, and so on.
- If you are using the PTY interface, you should be aware that it runs the
- given program or command directly on the pty, without any intervening shell
- to interpret metacharacters, redirectors, etc. If you need this sort of
- thing, include the appropriate shell invocation as part of your command; for
- example:
- pty echo *
- just echoes "*"; whereas:
- pty ksh -c "echo *"
- echoes all the filenames that ksh finds matching "*".
- Similarly for redirection:
- set host /pty ksh -c "cat > foo" ; Note: use shell quoting rules here
- set transmit eof 4
- transmit bar
- And for that matter, for built-in shell commands:
- set host /pty ksh -c "for i in *; do echo $i; done"
- The PIPE interface, on the other hand, invokes the shell automatically, so:
- pipe echo *
- prints filenames, not "*".
- 2.9. X.25 Networking
- X.25 networking is documented in "Using C-Kermit", 2nd Edition. When the book
- was published, X.25 was available only in SunOS, Solaris, and Stratus VOS.
- Unlike TCP/IP, X.25 APIs are not standardized; each vendor's X.25 libraries
- and services (if they have them at all) are unique.
- This section describes new additions.
- 2.9.1. IBM AIXLink/X.25 Network Provider Interface for AIX
- Support for X.25 was added via IBM's Network Provider Interface (NPI),
- AIXLink/X.25 1.1, to the AIX 4.x version of C-Kermit 7.0. Unfortunately,
- AIXLink/X.25 is a rather bare-bones facility, lacking in particular any form
- of PAD support (X.3, X.28, X.29). Thus, the AIX version of C-Kermit, when
- built to include X.25 networking, has neither a PAD command, nor a SET PAD
- command. The same is true for the underlying AIX system: no PAD support.
- Thus it is not possible to have an interactive shell session over an X.25
- connection into an AIX system (as far as we know), even from X.25-capable
- Kermit versions (such as Solaris or VOS) that do include PAD support.
- Thus the X.25 capabilities in AIX C-Kermit are limited to peer-to-peer
- connections, e.g. from a C-Kermit client to a C-Kermit server. Unlike the
- Solaris, SunOS, and VOS versions, the AIX version can accept incoming X.25
- connections:
- set network type x.25
- if fail stop 1 Sorry - no X.25 support
- ; Put any desired DISABLE or ENABLE or SET commands here.
- set host /server *
- if fail stop 1 X.25 "set host *" failed
- And then access it from the client as follows:
- set network type x.25
- if fail stop 1 Sorry - no X.25 support
- set host xxxxxxx ; Specify the X.25/X.121 address
- if fail stop 1 Can't open connection
- And at this point the client can use the full range of client commands:
- SEND, GET, REMOTE xxx, FINISH, BYE.
- The AIX version also adds two new variables:
- v(x25local_nua) The local X.25 address.
- v(x25remote_nua) The X.25 address of the host on the other end
- of the connection.
- C-Kermit's AIX X.25 client has not been tested against anything other than
- a C-Kermit X.25 server on AIX. It is not known if it will interoperate with
- C-Kermit servers on Solaris, SunOS, or VOS.
- To make an X.25 connection from AIX C-Kermit, you must:
- set x25 call-user-data xxxx
- where xxxx can be any even-length string of hexadecimal digits, e.g. 123ABC.
- 2.9.2. HP-UX X.25
- Although C-Kermit presently does not include built-in support for HP-UX X.25,
- it can still be used to make X.25 connections as follows: start Kermit and
- tell it to:
- set prefixing all
- set parity space
- pty padem <address>
- This should work in HP-UX 9.00 and later (see Section 2.7). If you have an
- earlier HP-UX version, or the PTY interface doesn't work or isn't available,
- try:
- set prefixing all
- set parity space
- pipe padem <address>
- Failing that, use Kermit to telnet to localhost and then after logging back
- in, start padem as you would normally do to connect over X.25.
- 2.10. Additional Serial Port Controls
- C-Kermit 7.0 adds the following commands for greater control over serial
- ports. These commands are available only in C-Kermit versions whose
- underlying operating systems provide the corresponding services (such as
- POSIX and UNIX System V), and even then their successful operation depends
- on the capabilities of the specific device and driver.
- SET DISCONNECT { ON, OFF }
- On a SET LINE or SET PORT connection with SET CARRIER ON or AUTO, if
- the carrier signal drops during the connection, indicating that the
- connection has been lost, and C-Kermit notices it, this setting governs
- what happens next. With SET DISCONNECT OFF, which is consistent with
- previous behavior, and therefore the default, C-Kermit continues to keep the
- device open and allocated. With SET DISCONNECT ON, C-Kermit automatically
- closes and releases the device when it senses a carrier on-to-off
- transition, thus allowing others to use it. However, it remains the default
- device for i/o (DIAL, REDIAL, INPUT, SEND, CONNECT, etc), so if a subsequent
- i/o command is given, the device is reopened if it is still available. When
- it has been automatically closed in this manner, SHOW COMMUNICATIONS puts
- "(closed)" after its name, and in UNIX, the lockfile disappears -- both from
- SHOW COMM and from the lockfile directory itself. Synonym:
- SET CLOSE-ON-DISCONNECT.
- SET EXIT ON-DISCONNECT { ON, OFF }
- Like DISCONNECT, but makes the program exit if a connection drops.
- Note that SET CLOSE-ON-DISCONNECT and SET EXIT ON-DISCONNECT apply only to
- connections that drop; they do not apply to connections that can't be made
- in the first place. For example, they have no effect when a SET LINE,
- SET HOST, TELNET, or DIAL command fails.
- HANGUP
- If [CLOSE-ON-]DISCONNECT is ON, and the HANGUP command is given on a serial
- device, and the carrier signal is no longer present after the HANGUP
- command, the device is closed and released.
- SET PARITY HARDWARE { EVEN, ODD }
- Unlike SET PARITY { EVEN, ODD, MARK, SPACE }, which selects 7 data bits
- plus the indicated kind of parity (to be done in software by Kermit itself),
- SET PARITY HARDWARE selects 8 data bits plus even or odd parity, to be done
- by the underlying hardware, operating system, or device driver. This
- command is effective only with a SET LINE or SET PORT device. That is, it
- has no effect in remote mode, nor on network connections. There is
- presently no method for selecting 8 data bits plus mark or space parity.
- If hardware parity is in effect, the variable v(hwparity) is set to
- "even" or "odd". Note: some platforms might also support settings of
- SPACE, MARK, or NONE.
- SET STOP-BITS { 1, 2 }
- This tells the number of 1-bits to insert after an outbound character's
- data and parity bits, to separate it from the next character. Normally 1.
- Choosing 2 stop bits should do no harm, but will slow down serial
- transmission by approximately 10 percent. Historically, 2 stop bits were
- used with Teletypes (at 110 bps or below) for print-head recovery time.
- There is presently no method for choosing any number of stop bits besides
- 1 and 2.
- SET SERIAL [ <dps> ]
- <dps> stands for Data-bits, Parity, Stop-bits. This is the notation
- familiar to many people for serial port configuration: 7E1, 8N1, 7O2, etc.
- The data bits number also becomes the TERMINAL BYTESIZE setting. The second
- character is E for Even, O for Odd, M for Mark, S for Space, or N for None.
- The list of available options depends on the capabilities of the specific
- platform. If <dps> is omitted, 8N1 is used. Type "set serial ?" for a
- list of available choices. Examples:
- SET SERIAL 7E1
- Equivalent to SET PARITY EVEN, SET STOP-BITS 1, SET TERM BYTE 7.
- SET SERIAL 8N1
- Equivalent to SET PARITY NONE, SET STOP-BITS 1, SET TERM BYTE 8.
- SET SERIAL 7E2
- Equivalent to SET PARITY EVEN and SET STOP-BITS 2, SET TERM BYTE 7.
- SET SERIAL 8E2
- Same as SET PARITY HARDWARE EVEN, SET STOP-BITS 2, SET TERM BYTE 8.
- SET SERIAL
- Same as SET PARITY NONE and SET STOP-BITS 1, SET TERM BYTE 8.
- Notes:
- . The SET SERIAL xx2 options are available only in Kermit versions where the
- SET PARITY HARDWARE command is also available. (SHOW FEATURES includes
- "HWPARITY" in its options list.)
- . The SET SERIAL 7xx and 8N1 options affect the software parity setting, even
- for network connections.
- . As noted in the manual, selecting 8 data bits does not give you 8-bit
- terminal sessions in CONNECT mode unless you also SET TERMINAL BYTESIZE 8.
- The default terminal bytesize remains 7, to protect against the situation
- where the remote host is generating parity but you don't know about it. If
- the terminal bytesize was 8 by default and you CONNECTed to such a host,
- you would see only garbage on your screen.
- . If you do not give a SET STOP-BITS or SET SET SERIAL command, C-Kermit
- does not attempt to set the device's stop bits; instead, it uses whatever
- setting the device uses when not given explicit instructions about stop
- bits.
- SHOW COMMUNICATIONS displays the current settings. Stop bits and hardware
- parity are shown only for SET PORT / SET LINE (serial) devices, since they
- do not apply to network connections or to remote mode. STOP-BITS is shown
- as "(default)" if you have not given an explicit SET STOP-BITS or SET SERIAL
- command.
- The v(serial) variable shows the SET SERIAL setting (8N1, 7E1, etc).
- 2.11. Getting Access to the Dialout Device
- This section is for UNIX only; note the special words about QNX
- at the end. Also see Section 2.0 for SET LINE switches, particularly
- the /SHARE switch for VMS only.
- C-Kermit does its best to obey the UUCP lockfile conventions of each platform
- (machine, operating system, OS version) where it runs, if that platform uses
- UUCP.
- But simply obeying the conventions is often not good enough, due to the
- increasing likelihood that a particular serial device might have more than one
- name (e.g. /dev/tty00 and /dev/term/00 are the same device in Unixware 7;
- /dev/cua and /dev/cufa are the same device in NeXTSTEP), plus the increasingly
- widespread use of symlinks for device names, such as /dev/modem.
- C-Kermit 7.0 goes to greater lengths than previous versions to successfully
- interlock with other communications program (and other instances of Kermit
- itself); for example, by:
- . Creation of dual lockfiles whenever a symlink is used; one for the link
- name and one for the "real" name as revealed by readlink().
- . Creation of dual lockfiles in HP-UX according to HP rules.
- . Creation of dual uppercase/lowercase lockfile names in SCO UNIX/ODT/OSR5.
- . The use of ttylock() in versions of AIX where it works.
- . The use, wherever possible, of lockfile names based on inode/major/minor
- device number rather than device name.
- See the ckuins.txt and ckubwr.txt files for details.
- QNX is almost unique among UNIX varieties in having no UUCP programs nor
- UUCP-oriented dialout-device locking conventions. QNX does, however, allow a
- program to get the device open count. This can not be a reliable form of
- locking unless all applications do it (and they don't), so by default, Kermit
- uses this information only for printing a warning message such as:
- C-Kermit>set line /dev/ser1
- WARNING - "/dev/ser1" looks busy...
- However, if you want to use it as a lock, you can do so with:
- SET QNX-PORT-LOCK { ON, OFF }
- QNX-PORT-LOCK is OFF by default; if you set in ON, C-Kermit fails to open
- any dialout device when its open count indicates that another process has it
- open. SHOW COMM (in QNX only) displays the setting, and if you have a port
- open, it also shows the current open count (with C-Kermit's own access
- always counting as 1).
- 2.12. The Connection Log
- C-Kermit 7.0 adds the ability to log connections, so you can see where you've
- been and have a record of calls you've made. A connection is defined as any
- communications session that is begun by SET LINE, SET PORT, DIAL, SET HOST,
- TELNET, or RLOGIN. Connections are not logged unless you request it; the
- command is:
- LOG CX [ filename [ { NEW, APPEND } ] ]
- Enables logging of connections in the given file. If the trailing
- { NEW, APPEND } keyword is omitted, the file is opened for appending;
- i.e. new records are written to the end. If NEW is specified, a new
- file is created; if a file of the same name already existed, it is
- overwritten. If the filename is omitted, CX.LOG in your home (login)
- directory is used (note: uppercase). To accept all defaults, just use
- "log connections" (or "l c" for short). Synonym: LOG CONNECTIONS.
- CLOSE CX-LOG
- This closes the connection log if it was open. (Note, the CLOSE CONNECTION
- command closes the connection itself).
- SHOW CX
- This shows your current connection, if any, including the elapsed time
- (since you opened it). Synonym: SHOW CONNECTION.
- v(cx_time)
- This variable shows the elapsed time of your current connection, or if
- there is no current connection, of your most recent connection, of if there
- have been no connections, 0.
- The connection contains one line per connection, of the form:
- yyyymmdd hh:mm:ss username pid p=v [ p=v [ ... ] ]
- where the timestamp (in columns 1-18) shows when the connection was made;
- username is the login identity of the person who made the connection; pid is
- Kermit's process ID when it made the connection. The p's are parameters that
- depend on the type of connection, and the v's are their values:
- T = Connection Type (TCP, SERIAL, DIAL, DECNET, etc).
- H = The name of the Host from which the connection was made.
- N = Destination phone Number or Network host name or address.
- D = Serial connections only: Device name.
- O = Dialed calls only: Originating country code & area code if known.
- E = Elapsed time in hh:mm:ss format (or hhh:mm:ss, etc).
- If you always want to keep a connection log, simply add:
- log connections
- to your C-Kermit customization file. Note, however, that if you make a lot of
- connections, your CX.LOG will grow and grow. You can handle this by adding a
- "logrotate" procedure like the following to your customization file, before
- the "log connections" command:
- define LOGROTATE { ; Define LOGROTATE macro
- local %i %m %d %n %f MAX
- def MAX 4 ; How many months to keep
- if not def %1 - ; No argument given
- end 1 %0: No filename given
- if not = 1 ffiles(%1) - ; Exactly 1 file must match
- end 1 %0: %1 - File not found
- .%d := fsubstr(fdate(%1),1,6) ; Arg OK - get file year & month
- if = %d - ; Compare file year & month
- fsubstr(v(ndate),1,6) - ; with current year & month
- end 0 ; Same year & month - done
- rename %1 %1.%d ; Different - rename file
- .%n := ffiles(%1.*) ; How many old files
- if < %n m(MAX) end 0 ; Not enough to rotate
- .%m := %1.999999 ; Initial compare string
- for %i 1 %n 1 { ; Loop thru old logs
- .%f := fnextfile() ; Get next file name
- if llt %f %m .%m := %f ; If this one older remember it
- }
- delete %m ; Delete the oldest one
- }
- log connections ; Now open the (possibly new) log
- logrotate v(home)CX.LOG ; Run the LOGROTATE macro
- As you can see, this compares the yyyymm portion of the modification date
- (fdate()) of the given file (%1) with the current yyyymm. If they differ,
- the current file has the yyyymm suffix (from its most recent modification
- date) appended to its name. Then we search through all other such files, find
- the oldest one, and delete it. Thus the current log, plus the logs from the
- most recent four months, are kept. This is all done automatically every time
- you start C-Kermit.
- On multiuser systems, it is possible to keep a single, shared, system-wide
- connection log, but this is not recommended since (a) it requires you keep a
- publicly write-accessible logfile (a glaring target for mischief), and (b) it
- would require each user to log to that file and not disable logging. A better
- method for logging connections, in UNIX at least, is syslogging (see
- ckuins.txt Section 15 and iksd.txt Section 4.2 for details).
- 2.13. Automatic Connection-Specific Flow Control Selection
- Beginning in C-Kermit 7.0, the appropriate flow-control method for each
- connection type is kept in a table, for example:
- Remote: NONE
- Modem: RTS/CTS
- Direct-Serial: NONE
- TCPIP: NONE
- The size of the table and values for each connection type can vary from
- platform to platform. Type "set flow ?" for a list of available flow-control
- types.
- The table is used to automatically select the appropriate kind of flow
- control whenever you make a connection. You can display the table with:
- SHOW FLOW-CONTROL
- The defaults are as follows:
- Remote:
- NONE or XON/XOFF. This is because C-Kermit is not allowed to find out what
- type of connection the incoming user has (*). No kind of flow control will
- work on every kind of connection, including (unexpectedly) KEEP, which we
- would have liked to use, but not turning off flow control at the remote end
- during file transfer on TCP/IP connections is fatal to the transfer (except
- in VMS and HP-UX, where it must be set to Xon/Xoff!) Therefore if you are
- dialing in to a serial port on a server (UNIX or VMS) where C-Kermit is
- running, you will need to tell C-Kermit to "set flow keep" before
- transferring files (assuming the modem and port are configured correctly by
- the system administrator; otherwise you'll need to give a specific kind of
- flow control, e.g. "set flow xon/xoff"), so in this case C-Kermit will not
- disable flow control, as it must do when you are coming via Telnet (directly
- or through a terminal server, except on VMS and HP-UX).
- Modem:
- This applies when you dial out with a modem. In this case, the MODEM
- FLOW-CONTROL setting takes affect after the SET FLOW setting, so it can pick
- the most appropriate flow control for the combination of the particular
- modem and the computer/port/driver that is dialing.
- Direct-Serial:
- The default here is NONE because C-Kermit has no way of knowing what kind
- of flow control, if any, is or can be done by the device at the other end
- of the connection. RTS/CTS would be a bad choice here, because if the CTS
- signal is not asserted, the connection will hang. And since direct
- connections are often made with 3-wire cables, there is a good chance the
- CTS signal will not be received.
- TCPIP:
- NONE, since TCP and IP provide their own flow control transparently to the
- application, except in VMS, where Xon/Xoff is the default due to the
- requirements of the VMS TCP/IP products.
- Other networks:
- NONE, since networks should provide their flow control transparently to the
- application.
- (*) This is possibly the worst feature of UNIX, VMS, and other platforms
- where C-Kermit runs. If C-Kermit was able to ask the operating system
- what kind of connection it had to the user, it could set up many things
- for you automatically.
- You can modify the default-flow-control table with:
- SET FLOW-CONTROL /xxx { NONE, KEEP, RTS/CTS, XON/XOFF, ... }