home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckv196.zip / ckermit2.txt < prev    next >
Text File  |  2000-01-06  |  699KB  |  16,047 lines

  1. File CKERMIT2.TXT, Supplement to "Using C-Kermit", Second Edition
  2.  
  3.   D R A F T
  4.  
  5. As of C-Kermit version:  7.0.196
  6. This file last updated:  Sat Jan  1 11:03:15 2000
  7.  
  8. Authors: Frank da Cruz and Christine M. Gianone
  9. Address: The Kermit Project
  10.          Columbia University
  11.          612 West 115th Street
  12.          New York NY 10025-7799
  13.          USA
  14. Fax:     +1 (212) 662-6442
  15. E-Mail:  kermit-support@columbia.edu
  16. Web:     http://www.columbia.edu/kermit/
  17. Or:      http://www.kermit-project.org/
  18. Or:      http://www.columbia.nyc.ny.us/kermit/
  19.  
  20. NOTICES:
  21.  
  22. This document:
  23.   Copyright (C) 1997, 2000, Frank da Cruz and Christine M. Gianone.
  24.   All rights reserved.
  25.  
  26. Kermit 95:
  27.   Copyright (C) 1995, 2000, Trustees of Columbia University in the City of
  28.   New York.  All rights reserved.
  29.  
  30. C-Kermit:
  31.   Copyright (C) 1985, 2000,
  32.     Trustees of Columbia University in the City of New York.
  33.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  34.     copyright text in the ckcmai.c module for disclaimer and permissions.
  35.  
  36. When Kerberos(TM) and/or SRP(TM) (Secure Remote Password) and/or SSL
  37. protocol are included:
  38.   Portions Copyright (C) 1990, Massachusetts Institute of Technology.
  39.   Portions Copyright (C) 1991, 1993 Regents of the University of California.
  40.   Portions Copyright (C) 1991, 1992, 1993, 1994, 1995 by AT&T.
  41.   Portions Copyright (C) 1997, Stanford University.
  42.   Portions Copyright (C) 1995-1997, Eric Young <eay@cryptosoft.com>.
  43.  
  44. For the full text of the third-party copyright notices, see Appendix V.
  45.  
  46. ------------------------------
  47. WHAT IS IN THIS FILE
  48.  
  49. This file lists changes made to C-Kermit since the second edition of the book
  50. "Using C-Kermit" was published and C-Kermit 6.0 was released in November 1996.
  51. Use this file as a supplement to the second edition of "Using C-Kermit" until
  52. the third edition is published some time in 2000.  If the "most recent update"
  53. shown above is long ago, contact Columbia University to see if there is a
  54. newer release.
  55.  
  56. For further information, also see the CKCBWR.TXT ("C-Kermit beware") file for
  57. hints, tips, tricks, restrictions, frequently asked questions, etc, plus the
  58. system-specific "beware file", e.g. CKUBWR.TXT for UNIX, CKVBWR.TXT for VMS,
  59. etc, and also any system-specific update files such as KERMIT95.HTM for Kermit
  60. 95 (in the DOCS\MANUAL\ subdirectory of your K95 directory).
  61.  
  62. IMPORTANT: A major new feature of C-Kermit 7.0 is its ability to be an
  63. Internet Kermit Services Daemon (IKSD), as well as an IKSD client.  All of
  64. this is described in a separate file, IKSD.TXT.
  65.  
  66. ---------------
  67. ABOUT FILENAMES
  68.  
  69. In this document, filenames are generally shown in uppercase, but on file
  70. systems with case-sensitive names such as UNIX, OS-9, and AOS/VS, lowercase
  71. names are used: ckcbwr.txt, ckermit2.txt, etc.
  72.  
  73. ----------------
  74. ADDITIONAL FILES
  75.  
  76. Several other files accompany this new Kermit release:
  77.  
  78. SECURITY.TXT
  79.   Discussion of Kermit's new authentication and encryption features.
  80.  
  81. IKSD.TXT
  82.   How to install and manage an Internet Kermit Service Daemon.
  83.  
  84. TELNET.TXT
  85.   A thorough presentation of Kermit's new advanced Telnet features and
  86.   controls.
  87.  
  88. ------------------------
  89. THE NEW C-KERMIT LICENSE
  90.  
  91. The C-Kermit license was rewritten for version 7.0 to grant automatic
  92. permission to packagers of free operating-system distributions to include
  93. C-Kermit 7.0.  Examples include Linux (GNU/Linux), FreeBSD, NetBSD, etc.
  94. The new license is in the COPYING.TXT file, and is also displayed by C-Kermit
  95. itself when you give the VERSION or COPYRIGHT command.  The new C-Kermit
  96. license does not apply to Kermit 95.
  97.  
  98. ---------------
  99. ACKNOWLEDGMENTS
  100.  
  101. Thanks to Jeff Altman, who joined the Kermit Project in 1995, for much of what
  102. you see in C-Kermit 7.0, especially in the networking and security areas, and
  103. his key role in designing and implementing the Internet Kermit Service Daemon.
  104. And special thanks to Lucas Hart for lots of help with the VMS version; to
  105. Peter Eichhorn for continuous testing on the full range of HP-UX versions and
  106. for a consolidated set of HP-UX makefile targets; and to Peter Mauzey, Fred
  107. Smith, Christian Mondrup, Gerry Belanger, Clarence Dold, Graham Jenkins,
  108. William Bader, Martin Whitaker, Nigel Roles, Dat Nguyen, Dragan Milicic, Steve
  109. Walton, Nelson Beebe, JP Radley, Joe Doupnik, Ted T'so, Carl Friend, and many
  110. others for binaries, hosting, reviews, suggestions, advice, bug reports, and
  111. all the rest over the 3+ year C-Kermit 7.0 development cycle.  Thanks to Russ
  112. Nelson and the board of the Open Software Initiative (www.opensource.org) for
  113. their cooperation in developing the new C-Kermit license and to the
  114. proprietors of those "free UNIX" distributions that have incorporated C-Kermit
  115. 7.0 for their cooperation and support, especially FreeBSD's Joerg Wunsch.
  116.  
  117. -----------------------
  118. NOTE TO KERMIT 95 USERS
  119.  
  120. Like the book "Using C-Kermit", this file concentrates on the aspects of
  121. C-Kermit that are common to all versions: UNIX, VMS, VOS, AOS/VS, etc.  Please
  122. refer to your Kermit 95 documentation for information that is specific to
  123. Kermit 95.
  124.  
  125. C-Kermit 7.0 corresponds to Kermit 95 1.1.18.
  126.  
  127. -------------------------------------
  128. C-KERMIT VERSIONS AND VERSION NUMBERS
  129.  
  130. "C-Kermit" refers to all the many programs that are compiled in whole or in
  131. part from common C-language source code, comprising:
  132.  
  133.  . A Kermit file transfer protocol module
  134.  . A command parser and script execution module
  135.  . A modem-dialing module
  136.  . A network support module
  137.  . A character-set translation module.
  138.  
  139. and several others.  These "system-independent" modules are combined with
  140. system-dependent modules for each platform to provide the required
  141. input/output functions, and also in some cases overlaid with an alternative
  142. user interface, such as Macintosh Kermit's point-and-click interface, and in
  143. some cases also a terminal emulator, as Kermit 95.
  144.  
  145. The C-Kermit version number started as 1.0, ... 3.0, 4.0, 4.1 and then
  146. (because of confusion at the time with Berkeley UNIX 4.2), 4B, 4C, and so on,
  147. with the specific edit number in parentheses, for example 4E(072) or 5A(188).
  148. This scheme was used through 5A(191), but now we have gone back to the
  149. traditional numbering scheme with decimal points:  major.minor.edit; for
  150. example 7.0.196.  Internal version numbers (the \v(version) variable),
  151. however, are compatible in C-Kermit 5A upwards.
  152.  
  153. Meanwhile, C-Kermit derivatives for some platforms (Windows, Macintosh) might
  154. go through several releases while C-Kermit itself remains the same.  These
  155. versions have their own platform-specific version numbers, such as Kermit 95
  156. 1.1.1, 1.1.2, and so on.
  157.  
  158. C-Kermit Version History:
  159.  
  160.   1.0       1981-1982         Command-line only, 4.2 BSD UNIX only
  161.   2.0       (*)               (who remembers...)
  162.   3.0       May 1984          Command-line only, supports several platforms
  163.   4.0-4.1   Feb-Apr 1985 (*)  First interactive and modular version
  164.   4C(050)   May 1985
  165.   4D(060)   April 1986
  166.   4E(066)   August 1987       Long packets
  167.   4E(068)   January 1988
  168.   4E(072)   January 1989
  169.   4F(095)   August 1989 (*)   Attribute packets
  170.   5A(188)   November 1992     Scripting, TCP/IP, sliding windows (1)
  171.   5A(189)   September 1993    Control-char unprefixing
  172.   5A(190)   October 1994      Recovery
  173.   5A(191)   April 1995        OS/2 only
  174.   6.0.192   September 1996    Intelligent dialing, autodownload, lots more (2)
  175.   6.1.193   1997-98 (*)       Development only
  176.   6.1.194   June 1998         K95 only - switches, directory recursion, more
  177.   7.0.195   August 1999       IKSD + more (CU only as K95 1.1.18-CU)
  178.   7.0.196   1 January 2000    Unicode, lots more
  179.  
  180. (*) Never formally released (4.0 was a total rewrite)
  181. (1) "Using C-Kermit", 1st Edition
  182. (2) "Using C-Kermit", 2nd Edition
  183.  
  184. ------------------------------
  185. CONTENTS
  186.  
  187.  I.  C-KERMIT DOCUMENTATION: Information about the C-Kermit manual
  188.  
  189.  II. NEW FEATURES: Documentation for Features Added Since C-Kermit 6.0
  190.  
  191.      (0) INCOMPATIBILITIES WITH PREVIOUS RELEASES
  192.      (1) PROGRAM AND FILE MANAGEMENT AND COMMANDS
  193.          1.0.  Bug fixes
  194.          1.1.  Command Continuation
  195.          1.2.  Editor Interface
  196.          1.3.  Web Browser and FTP Interface
  197.          1.4.  Command Editing
  198.          1.5.  Command Switches
  199.                1.5.1. General Switch Syntax
  200.                1.5.2. Order and Effect of Switches
  201.                1.5.3. Distinguishing Switches from Other Fields
  202.                1.5.4. Standard File Selection Switches
  203.                1.5.5. Setting Preferences for Different Commands
  204.          1.6.  Dates and Times
  205.          1.7.  Partial Completion of Keywords
  206.          1.8.  Command Recall
  207.          1.9.  EXIT Messages
  208.          1.10. Managing Keyboard Interruptions
  209.          1.11. Taming the Wild Backslash -- Part Deux
  210.            1.11.1. Background
  211.            1.11.2. Kermit's Quoting Rules
  212.                1.11.3. Passing DOS Filenames from Kermit to Shell Commands
  213.            1.11.4. Using Variables to Hold DOS Filenames
  214.            1.11.5. Passing DOS Filenames as Parameters to Macros
  215.            1.11.6. Passing DOS File Names from Macro Parameters to
  216.                        the DOS Shell
  217.                1.11.7. Passing DOS Filenames to Kermit from the Shell
  218.          1.12. Debugging
  219.          1.13. Logs
  220.          1.14. Automatic File-Transfer Packet Recognition at the Command Prompt
  221.          1.15. The TYPE Command
  222.          1.16. The RESET Command
  223.          1.17. The COPY and RENAME Commands
  224.          1.18. The MANUAL Command
  225.          1.19. String and Filename Matching Patterns
  226.          1.20. Multiple Commands on One Line
  227.          1.21. What Do I Have?
  228.          1.22. Generalized File Input and Output
  229.            1.22.1. Why Another I/O System?
  230.            1.22.2. The FILE Command
  231.            1.22.3. FILE Command Examples
  232.            1.22.4. Channel Numbers
  233.            1.22.5. FILE Command Error Codes
  234.            1.22.6. File I/O Variables
  235.            1.22.7. File I/O Functions
  236.            1.22.8. File I/O Function Examples
  237.          1.23. The EXEC Command
  238.          1.24. Getting Keyword Lists with '?'
  239.      (2) MAKING AND USING CONNECTIONS
  240.          2.0. SET LINE and SET HOST Command Switches
  241.      2.1. Dialing
  242.           2.1.1. The Dial Result Message
  243.           2.1.2. Long-Distance Dialing Changes
  244.           2.1.3. Forcing Long-Distance Dialing
  245.           2.1.4. Exchange-Specific Dialing Decisions
  246.           2.1.5. Cautions about Cheapest-First Dialing
  247.           2.1.6. Blind Dialing (Dialing with No Dialtone)
  248.               2.1.7. Trimming the Dialing Dialog
  249.               2.1.8. Controlling the Dialing Speed
  250.               2.1.9. Pretesting Phone Number Conversions
  251.               2.1.10. Greater Control over Partial Dialing
  252.               2.1.11. New DIAL-related Variables and Functions
  253.               2.1.12. Increased Flexibility of PBX Dialing
  254.               2.1.13. The DIAL macro - Last-Minute Phone Number Conversions
  255.               2.1.14. Automatic Tone/Pulse Dialing Selection
  256.               2.1.15. Dial-Modifier Variables
  257.               2.1.16. Giving Multiple Numbers to the DIAL Command
  258.      2.2. Modems
  259.           2.2.1. New Modem Types
  260.           2.2.2. New Modem Controls
  261.      2.3. TELNET and RLOGIN
  262.               2.3.0. Bug Fixes
  263.           2.3.1. Telnet Binary Mode Bug Adjustments
  264.           2.3.2. VMS UCX Telnet Port Bug Adjustment
  265.           2.3.3. Telnet New Environment Option
  266.           2.3.4. Telnet Location Option
  267.               2.3.5. Connecting to Raw TCP Sockets
  268.               2.3.6. Incoming TCP Connections
  269.      2.4. The EIGHTBIT Command
  270.      2.5. The Services Directory
  271.          2.6. Closing Connections
  272.      2.7. Using C-Kermit with External Communication Programs
  273.               2.7.0. C-Kermit over tn3270 and tn5250
  274.           2.7.1. C-Kermit over Telnet
  275.           2.7.2. C-Kermit over Rlogin
  276.               2.7.3. C-Kermit over Serial Communication Programs
  277.           2.7.4. C-Kermit over Secure Network Clients
  278.           2.7.4.1. SSH
  279.           2.7.4.2. SSL
  280.           2.7.4.3. SRP
  281.           2.7.4.4. SOCKS
  282.               2.7.4.5. Kerberos and SRP
  283.          2.8. Scripting Local Programs
  284.          2.9. X.25 Networking
  285.               2.9.1. IBM AIXLink/X.25 Network Provider Interface for AIX
  286.               2.9.2. HP-UX X.25
  287.          2.10. Additional Serial Port Controls
  288.          2.11. Getting Access to the Dialout Device
  289.          2.12. The Connection Log
  290.          2.13. Automatic Connection-Specific Flow Control Selection
  291.          2.14. Trapping Connection Establishment and Loss
  292.          2.15. Contacting Web Servers with the HTTP Command
  293.      (3) TERMINAL CONNECTION
  294.          3.1. CONNECT Command Switches
  295.          3.2. Triggers
  296.          3.3. Transparent Printing
  297.          3.4. Binary and Text Session Logs
  298.      (4) FILE TRANSFER AND MANAGEMENT
  299.          4.0. Bug Fixes, Minor Changes, and Clarifications
  300.      4.1. File-Transfer Filename Templates
  301.      4.1.1. Templates in the As-Name
  302.      4.1.2. Templates on the Command Line
  303.      4.1.3. Post-Transfer Renaming
  304.      4.2. File-Transfer Pipes and Filters
  305.          4.2.1. Introduction
  306.      4.2.1.1. Terminology
  307.      4.2.1.2. Notation
  308.      4.2.1.3. Security
  309.      4.2.2. Commands for Transferring from and to Pipes
  310.      4.2.2.1. Sending from a Command
  311.      4.2.2.2. Receiving to a Command
  312.      4.2.3. Using File-Transfer Filters
  313.      4.2.3.1. The SEND Filter
  314.      4.2.3.2. The RECEIVE Filter
  315.      4.2.4. Implicit Use of Pipes
  316.      4.2.5. Success and Failure of Piped Commands
  317.          4.2.6. Cautions about Using Pipes to Transfer Directory Trees
  318.      4.2.7. Pipes and Encryption
  319.          4.2.8. Commands and Functions Related to Pipes
  320.      4.2.8.1. The OPEN !READ and OPEN !WRITE Commands
  321.      4.2.8.2. The REDIRECT Command
  322.          4.2.8.3. Receiving Mail and Print Jobs
  323.      4.2.8.4. Pipe-Related Functions
  324.          4.3. Automatic Per-File Text/Binary Mode Switching
  325.      4.3.1. Exceptions
  326.      4.3.2. Overview
  327.      4.3.3. Commands
  328.      4.3.4. Examples
  329.          4.4. File Permissions
  330.      4.4.1. When ATTRIBUTES PROTECTION is OFF
  331.      4.4.1.1. Unix
  332.      4.4.1.2. VMS
  333.      4.4.2. When ATTRIBUTES PROTECTION is ON
  334.      4.4.2.1. System-Specific Permissions
  335.      4.4.2.1.1. UNIX
  336.      4.4.2.1.2. VMS
  337.      4.4.2.2. System-Independent Permissions
  338.          4.5. File Management Commands
  339.          4.5.1. The DIRECTORY Command
  340.          4.5.2. The CD and BACK Commands
  341.          4.5.2.1. Parsing Improvements
  342.          4.5.2.2. The CDPATH
  343.      4.5.3. Creating and Removing Directories
  344.      4.5.4. The DELETE and PURGE Commands
  345.          4.6. Starting the Remote Kermit Server Automatically
  346.          4.7. File-Transfer Command Switches
  347.          4.7.1. SEND Command Switches
  348.          4.7.2. GET Command Switches
  349.          4.7.3. RECEIVE Command Switches
  350.          4.8. Kermit Protocol Improvements
  351.      4.8.1. Multiple Attribute Packets
  352.      4.8.2. Very Short Packets
  353.          4.9. Wildcard / File Group Expansion
  354.      4.9.1. In UNIX C-Kermit
  355.      4.9.2. In Kermit 95
  356.      4.9.3. In VMS, AOS/VS, OS-9, VOS, etc.
  357.          4.10. Additional Pathname Controls
  358.          4.11. Recursive SEND and GET: Transferring Directory Trees
  359.      4.11.1. Command-Line Options
  360.      4.11.2. The SEND /RECURSIVE Command
  361.      4.11.3. The GET /RECURSIVE Command
  362.      4.11.4. New and Changed Functions
  363.      4.11.5. Moving Directory Trees Between Like Systems
  364.      4.11.6. Moving Directory Trees Between Unlike Systems
  365.          4.12. Where Did My File Go?
  366.          4.13. File Output Buffer Control
  367.          4.14. Improved Responsiveness
  368.          4.15. Doubling and Ignoring Characters for Transparency
  369.          4.16. New File-Transfer Display Formats
  370.          4.17. New Transaction Log Formats
  371.          4.17.1. The BRIEF Format
  372.          4.17.2. The FTP Format
  373.          4.18. Unprefixing NUL
  374.          4.19. Clear-Channel Protocol
  375.          4.20. Streaming Protocol
  376.      4.20.1. Commands for Streaming
  377.      4.20.2. Examples of Streaming
  378.      4.20.2.1. Streaming on Socket-to-Socket Connections
  379.      4.20.2.2. Streaming on Telnet Connections
  380.          4.20.2.3. Streaming with Limited Packet Length
  381.          4.20.2.4. Streaming on Dialup Connections
  382.          4.20.2.5. Streaming on X.25 Connections
  383.          4.20.3. Streaming - Preliminary Conclusions
  384.          4.21. The TRANSMIT Command
  385.      4.22. Coping with Faulty Kermit Implementations
  386.      4.22.1. Failure to Accept Modern Negotiation Strings
  387.      4.22.2. Failure to Negotiate 8th-bit Prefixing
  388.      4.22.3. Corrupt Files
  389.      4.22.4. Spurious Cancellations
  390.      4.22.5. Spurious Refusals
  391.      4.22.6. Failures during the Data Transfer Phase
  392.      4.22.7. Fractured Filenames
  393.      4.22.8. Bad File Dates
  394.          4.23. File Transfer Recovery
  395.          4.24. FILE COLLISION UPDATE Clarification
  396.          4.25. Autodownload Improvements
  397.      (5) CLIENT/SERVER
  398.          5.0. Hints
  399.      5.1. New Command-Line Options
  400.      5.2. New Client Commands
  401.      5.3. New Server Capabilities
  402.          5.3.1. Creating and Removing Directories
  403.          5.3.2. Directory Listings
  404.          5.4. Syntax for Remote Filenames with Embedded Spaces
  405.          5.5. Automatic Orientation Messages upon Directory Change
  406.      5.6. New Server Controls
  407.      5.7. Timeouts during REMOTE HOST Command Execution
  408.      (6) INTERNATIONAL CHARACTER SETS
  409.          6.0. ISO 8859-15 Latin Alphabet 9
  410.          6.1. The HP-Roman8 Character Set
  411.          6.2. Greek Character Sets
  412.          6.3. Additional Latin-2 Character Sets
  413.          6.4. Additional Cyrillic Character Sets
  414.          6.5. Automatic Character-Set Switching
  415.          6.6. Unicode
  416.      6.6.1. Overview of Unicode
  417.      6.6.2. UCS Byte Order
  418.      6.6.2. UCS Transformation Formats
  419.      6.6.3. Conformance Levels
  420.      6.6.4. Relationship of Unicode with Kermit's Other Character Sets
  421.      6.6.5. Kermit's Unicode Features
  422.      6.6.5.1. File Transfer
  423.      6.6.5.2. The TRANSLATE Command
  424.      6.6.5.3. Terminal Connection
  425.      6.6.5.4. The TRANSMIT Command
  426.      6.6.5.5. Summary of Kermit Unicode Commands
  427.          6.7. Client/Server Character-Set Switching
  428.      (7) SCRIPT PROGRAMMING
  429.          7.0. Bug Fixes
  430.          7.1. The INPUT Command
  431.      7.1.1. INPUT Timeouts
  432.      7.1.2. New INPUT Controls
  433.      7.1.3. INPUT with Pattern Matching
  434.      7.1.4. The INPUT Match Result
  435.      7.2. New or Improved Built-In Variables
  436.      7.3. New or Improved Built-In Functions
  437.          7.4. New IF Conditions
  438.          7.5. Using More than Ten Macro Arguments
  439.          7.6. Clarification of Function Call Syntax
  440.          7.7. Autodownload during INPUT Command Execution
  441.          7.8. Built-in Help for Functions.
  442.      7.9. Variable Assignments
  443.      7.9.1. Assignment Operators
  444.      7.9.2. New Assignment Commands
  445.      7.10. Arrays
  446.      7.10.1. Array Initializers
  447.      7.10.2. Turning a String into an Array of Words
  448.      7.10.3. Arrays of Filenames
  449.      7.10.4. Automatic Arrays
  450.      7.10.5. Sorting Arrays
  451.      7.10.6. Displaying Arrays
  452.          7.10.7. Other Array Operations
  453.          7.10.8. Hints for Using Arrays
  454.          7.10.9. Do-It-Yourself Arrays
  455.          7.10.10. Associative Arrays
  456.          7.11. OUTPUT Command Improvements
  457.          7.12. Function and Variable Diagnostics
  458.          7.13. Return Value of Macros
  459.          7.14. The ASSERT, FAIL, and SUCCEED Commands.
  460.          7.15. Using Alarms
  461.          7.16. Passing Arguments to Command Files
  462.          7.17. Dialogs with Timed Responses
  463.          7.18. Increased Flexibility of SWITCH Case Labels
  464.          7.19. "Kerbang" Scripts
  465.          7.20. IF and XIF Statement Syntax
  466.          7.20.1. The IF/XIF Distinction
  467.          7.20.2. Boolean Expressions (The IF/WHILE Condition)
  468.          7.21. Screen Formatting and Cursor Control
  469.          7.22. Evaluating Arithmetic Expressions
  470.          7.23. Floating-Point Arithmetic
  471.          7.24. Tracing Script Execution
  472.          7.25. Compact Substring Notation
  473.          7.26. New WAIT Command Options
  474.          7.26.1. Waiting for Modem Signals
  475.          7.26.2. Waiting for File Events
  476.          7.27. Relaxed FOR and SWITCH Syntax
  477.      (8) USING OTHER FILE TRANSFER PROTOCOLS
  478.      (9) COMMAND-LINE OPTIONS
  479.          9.0. Extended-Format Command-Line Options
  480.      9.1. Command Line Personalities
  481.      9.2. Built-in Help for Command Line Options
  482.      9.3. New Command-Line Options
  483.     (10) C-KERMIT AND G-KERMIT
  484.  
  485. III. APPENDICES
  486.  
  487. III.1. Character Set Tables
  488. III.1.1. The Hewlett Packard Roman8 Character Set
  489. III.1.2. Greek Character Sets
  490. III.1.2.1. The ISO 8859-7 Latin / Greek Alphabet
  491. III.1.2.2. The ELOT 927 Character Set
  492. III.1.2.3. PC Code Page 869
  493. III.2. Updated Country Codes
  494.  
  495. IV. ERRATA & CORRIGENDA: Corrections to "Using C-Kermit" 2nd Edition.
  496. V. ADDITIONAL COPYRIGHT NOTICES
  497.  
  498. ------------------------------
  499. I. C-KERMIT DOCUMENTATION
  500.  
  501. The user manual for C-Kermit is:
  502.  
  503.   Frank da Cruz and Christine M. Gianone, "Using C-Kermit", Second Edition,
  504.   Digital Press /  Butterworth-Heinemann, Woburn, MA, 1997, 622 pages,
  505.   ISBN 1-55558-164-1.
  506.  
  507. The present document is a supplement to "Using C-Kermit" 2nd Ed, not a
  508. replacement for it.
  509.  
  510.   US single-copy price: $44.95; quantity discounts available.  Available in
  511.   bookstores or directly from Columbia University:
  512.  
  513.     The Kermit Project
  514.     Columbia University
  515.     612 West 115th Street
  516.     New York NY  10025-7799
  517.     USA
  518.     Telephone: +1 (212) 854-3703
  519.     Fax:       +1 (212) 663-8202
  520.  
  521.   Domestic and overseas orders accepted.  Price: US $44.95 (US, Canada, and
  522.   Mexico).  Shipping: $4.00 within the USA; $15.00 to all other countries.
  523.   Orders may be paid by MasterCard or Visa, or prepaid by check in US dollars.
  524.   Add $65 bank fee for checks not drawn on a US bank.  Do not include sales
  525.   tax.  Inquire about quantity discounts.
  526.  
  527.   You can also order by phone from the publisher, Digital Press /
  528.   Butterworth-Heinemann, with MasterCard, Visa, or American Express:
  529.  
  530.     +1 800 366-2665   (Woburn, Massachusetts office for USA & Canada)
  531.     +44 1865 314627   (Oxford, England distribution centre for UK & Europe)
  532.     +61 03 9245 7111  (Melbourne, Vic, office for Australia & NZ)
  533.     +65 356-1968      (Singapore office for Asia)
  534.     +27 (31) 2683111  (Durban office for South Africa)
  535.  
  536.   A German-language edition of the First Edition is also available:
  537.  
  538.     Frank da Cruz and Christine M. Gianone, "C-Kermit - Einfuehrung und
  539.     Referenz", Verlag Heinz Heise, Hannover, Germany (1994).
  540.     ISBN 3-88229-023-4.  Deutsch von Gisbert W. Selke.  Price: DM 88,00.
  541.     Verlag Heinz Heise GmbH & Co. KG, Helstorfer Strasse 7, D-30625 Hannover.
  542.     Tel. +49 (05 11) 53 52-0, Fax. +49 (05 11) 53 52-1 29.
  543.  
  544. The Kermit file transfer protocol is specified in:
  545.  
  546.   Frank da Cruz, "Kermit, A File Transfer Protocol", Digital Press,
  547.   Bedford, MA, 1987, 379 pages, ISBN 0-932376-88-6.
  548.   US single-copy price: $39.95.  Availability as above.
  549.  
  550. News and articles about Kermit software and protocol are published
  551. periodically in the journal, Kermit News.  Subscriptions are free; contact
  552. Columbia University at the address above.
  553.  
  554. Online news about Kermit is published in the comp.protocols.kermit.announce
  555. and comp.protocols.kermit.misc newsgroups.
  556.  
  557. ------------------------------
  558. II. NEW FEATURES
  559.  
  560. Support for the Bell Labs Plan 9 operating system was added to version 6.0
  561. too late to be mentioned in the book (although it does appear on the cover).
  562.  
  563. Specific changes and additions are grouped together by major topic, roughly
  564. corresponding to the chapters of "Using C-Kermit".
  565.  
  566. (0) INCOMPATIBILITIES WITH PREVIOUS RELEASES
  567.  
  568. C-Kermit 7.0 uses FAST Kermit protocol settings by default.  This includes
  569. "unprefixing" of certain control characters.  Because of this, file transfers
  570. that worked with previous releases might not work in the new release (but it
  571. is more likely that they will work, and much faster).  If a transfer fails,
  572. you'll get a context-sensitive hint suggesting possible causes and cures.
  573.  
  574. C-Kermit 7.0 transfers files in BINARY mode by default.  To restore the
  575. previous behavior, put SET FILE TYPE TEXT in your C-Kermit initialization
  576. file.
  577.  
  578. No matter whether FILE TYPE is BINARY or TEXT by default, C-Kermit 7.0 now
  579. switches between text and binary mode automatically on a per-file basis
  580. according to various criteria, including (a) which kind of platform is on the
  581. other end of the connection (if known), (b) the version of Kermit on the other
  582. end, and (c) the file's name (see Sections 4 and 4.3).  To disable this
  583. automatic switching and restore the earlier behavior, put SET TRANSFER MODE
  584. MANUAL in your C-Kermit initialization file.  To disable automatic switching
  585. for a particular transfer, include a /TEXT or /BINARY switch with your SEND or
  586. GET command.
  587.  
  588. The RESEND and REGET commands automatically switch to binary mode; previously
  589. if RESEND or REGET were attempted when FILE TYPE was TEXT, these commands
  590. would fail immediately, with a message telling you they work only when the
  591. FILE TYPE is BINARY.  Now they simply do this for you.  See section 4.23 for
  592. additional (important) information.
  593.  
  594. SET PREFIXING CAUTIOUS and MINIMAL now both prefix linefeed (10 and 138)
  595. in case rlogin or cu are "in the middle", since otherwise <LF>~ might appear
  596. in Kermit packets, and this would rlogin or cu to disconnect, suspend,
  597. escape back, or otherwise wreck the file transfer.  Xon and Xoff are now
  598. always prefixed too, even when Xon/Xoff flow control is not in effect, since
  599. unprefixing them has proven dangerous on TCP/IP connections.
  600.  
  601. In UNIX, VMS, Windows, and OS/2, the DIRECTORY command is built into C-Kermit
  602. itself rather than implemented by running an external command or program.
  603. The built-in command might not behave the way the platform-specific external
  604. one did, but many options are available for customization.  Of course the
  605. underlying platform-specific command can still be accessed with "!", "@",
  606. or "RUN" wherever the installation does not forbid.  In UNIX, the "ls"
  607. command can be accessed directly as "ls" in C-Kermit.  See Section 4.5.1 for
  608. details.
  609.  
  610. SEND ? prints a list of switches rather than a list of filenames.  If you want
  611. to see a list of filenames, use a (system-dependent) construction such as
  612. SEND ./? (for UNIX, Windows, or OS/2), SEND []? (VMS), etc.  See Sections 1.5
  613. and 4.7.1.
  614.  
  615. In UNIX, OS-9, and Kermit 95, the wildcard characters in previous versions
  616. were * and ?.  In C-Kermit 7.0 they are *, ?, [, ], {, and }, with dash used
  617. inside []'s to denote ranges and comma used inside {} to separate list
  618. elements.  If you need to include any of these characters literally in a
  619. filename, precede each one with backslash (\).  See Section 4.9.
  620.  
  621. SET QUIET { ON, OFF } is now on the command stack, just like SET INPUT CASE,
  622. SET COUNT, SET MACRO ERROR, etc, as described on p.458 of "Using C-Kermit",
  623. 2nd Edition.  This allows any macro or command file to SET QUIET ON or OFF
  624. without worrying about saving & restoring the global QUIET value.  For example,
  625. this lets you write a script that tries SET LINE on lots of devices until it
  626. finds one free without spewing out loads of error messages, and also without
  627. disturbing the global QUIET setting, whatever it was.
  628.  
  629. Because of the new "." operator (which introduces assignments), macros whose
  630. names begin with "." can not be invoked "by name".  However, they still can
  631. be invoked with DO.
  632.  
  633. The syntax of the EVALUATE command has changed.  See Section 7.9.2.  To
  634. restore the previous syntax, use SET EVALUATE OLD.
  635.  
  636. The \v(directory) variable now includes the trailing directory separator;
  637. in previous releases it did not.  This is to allow constructions such as:
  638.  
  639.   cd \v(dir)tmp
  640.  
  641. to work across platforms that might have different directory notation, such
  642. as UNIX, Windows, and VMS.
  643.  
  644. Prior to C-Kermit 7.0, the FLOW-CONTROL setting was global and sticky.
  645. In C-Kermit 7.0, there is an array of default flow-control values for each
  646. kind of connection, that are applied automatically at SET LINE/PORT/HOST time.
  647. Thus a SET FLOW command given before SET LINE/PORT/HOST is likely to be undone.
  648. Therefore SET FLOW can be guaranteed to have the desired effect only if given
  649. after the SET LINE/PORT/HOST command.
  650.  
  651. Character-set translation works differently in the TRANSMIT command when (a)
  652. the file character-set is not the same as the local end of the terminal
  653. charactger-set, or (b) when the terminal character-set is TRANSPARENT.
  654.  
  655.  
  656. (1) PROGRAM AND FILE MANAGEMENT AND COMMANDS
  657.  
  658. 1.0. Bug Fixes
  659.  
  660. The following patches were issued to correct bugs in C-Kermit 6.0.  These are
  661. described in detail in the 6.0 PATCHES file.  All of these fixes have been
  662. incorporated in C-Kermit 6.1 (never released except as K95 1.1.16-17) and 7.0.
  663.  
  664.  0001   All UNIX         C-Kermit mishandles timestamps on files before 1970
  665.  0002    Solaris 2.5++    Compilation error on Solaris 2.5 with Pro C
  666.  0003    All VMS          CKERMIT.INI Fix for VMS
  667.  0004    VMS/VAX/UCX 2.0  C-Kermit 6.0 can't TELNET on VAX/VMS with UCX 2.0
  668.  0005    All              C-Kermit Might Send Packets Outside Window
  669.  0006    All              MOVE from SEND-LIST does not delete original files
  670.  0007    Solaris 2.5++    Higher serial speeds on Solaris 2.5
  671.  0008   All              C-Kermit application file name can't contain spaces
  672.  0009   AT&T 7300 UNIXPC setuid and hardware flow-control problems
  673.  0010   Linux on Alpha   Patch to make ckutio.c compile on Linux/Alpha
  674.  0011   OS-9/68000 2.4   Patch to make ck9con.c compile on OS-9/68000 2.4
  675.  0012   MW Coherent 4.2  Patches for successful build on Coherent 4.2
  676.  0013   SINIX-Y 5.43     "delay" variable conflicts with <sys/clock.h>
  677.  0014   VMS/VAX/CMU-IP   Subject: Patches for VAX/VMS 5.x + CMU-IP
  678.  0015   All              XECHO doesn't flush its output
  679.  0016   VMS              CD and other directory operations might not work
  680.  0017   Linux 1.2.x++    Use standard POSIX interface for high serial speeds
  681.  0018   UNIX             SET WILDCARD-EXPANSION SHELL dumps core
  682.  0019   All              Hayes V.34 modem init string problem
  683.  0020   All              READ command does not fail if file not open
  684.  0021   All              Problems with long function arguments
  685.  0022   All              Certain \function()s can misbehave
  686.  0023   All              X MOD 0 crashes program
  687.  0024   All              Internal bulletproofing for lower() function
  688.  0025   OpenBSD          Real OpenBSD support for C-Kermit 6.0
  689.  0026   All              Incorrect checks for macro/command-file nesting depth
  690.  0027   All              ANSWER doesn't automatically CONNECT
  691.  0028   All              Overzealous EXIT warning
  692.  0029   All              OUTPUT doesn't echo when DUPLEX is HALF
  693.  0030   All              Minor problems with REMOTE DIRECTORY/DELETE/etc
  694.  0031   All              CHECK command broken
  695.  0032   All              Problem with SET TRANSMIT ECHO
  696.  0033   UNIX, VMS, etc   HELP SET SERVER says too much
  697.  0034   All              READ and !READ too picky about line terminators
  698.  0035   All              END from inside SWITCH doesn't work
  699.  0036   All              Problem telnetting to multihomed hosts
  700.  0037   All              Redirection failures in REMOTE xxx > file
  701.  
  702. REDIRECT was missing in many UNIX C-Kermit implementations; in version 7.0,
  703. it should be available in all of them.
  704.  
  705. 1.1. Command Continuation
  706.  
  707. Comments that start with ";" or "#" can no longer be continued.  In:
  708.  
  709.   ; this is a comment -
  710.   echo blah
  711.  
  712. the ECHO command will execute, rather than being taken as a continuation of
  713. the preceding comment line.  This allows easy "commenting out" of commands
  714. from macro definitions.
  715.  
  716. However, the text of the COMMENT command can still be continued onto
  717. subsequent lines:
  718.  
  719.   comment this is a comment -
  720.   echo blah
  721.  
  722. As of version 6.0, backslash is no longer a valid continuation character.
  723. Only hyphen should be used for command continuation.  This is to make it
  724. possible to issue commands like "cd a:\" on DOS-like systems.
  725.  
  726. As of version 7.0:
  727.  
  728.  . You can quote a final dash to prevent it from being a continuation
  729.    character:
  730.  
  731.       echo foo\-
  732.  
  733.    This prints "foo-".  The command is not continued.
  734.  
  735.  . You can enter commands such as:
  736.  
  737.      echo foo - ; this is a comment
  738.  
  739.    interactively and they will be properly treated as continued commands.
  740.    Previously this worked only in command files.
  741.  
  742. 1.2. Editor Interface
  743.  
  744. SET EDITOR <name> [ <options> ]
  745.   Lets you specify a text-editing program.  The <name> can be a fully
  746.   specified pathname like /usr/local/bin/emacs19/emacs, or it can be the
  747.   name of any program in your PATH, e.g. "set editor emacs".  In VMS, it
  748.   must be a DCL command like "edit", "edit/tpu", "emacs", etc.  If an
  749.   environment variable EDITOR is defined when Kermit starts, its value is
  750.   the default editor.  You can also specify options to be included on the
  751.   editor command line.  Returns to Kermit when the editor exits.
  752.  
  753. EDIT [ <filename> ]
  754.   If the EDIT command is given without a filename, then if a previous filename
  755.   had been given to an EDIT command, it is used; if not, the editor is started
  756.   without a file.  If a filename is given, the editor is started on that file,
  757.   and the filename is remembered for subsequent EDIT commands.
  758.  
  759. SHOW EDITOR
  760.   Displays the full pathname of your text editor, if any, along with any
  761.   command line options, and the file most recently edited (and therefore the
  762.   default filename for your next EDIT command).
  763.  
  764. Related variables: \v(editor), \v(editopts), \v(editfile).
  765.  
  766. 1.3. Web Browser and FTP Interface
  767.  
  768. C-Kermit includes an FTP command, which simply runs the FTP program; C-Kermit
  769. does not include any built-in support for Internet File Transfer Protocol,
  770. nor any method for interacting directly with an FTP server.  In version 7.0,
  771. however, C-Kermit lets you specify your FTP client:
  772.  
  773.   SET FTP-CLIENT [ <name> [ <options ] ]
  774.  
  775. The name is the name of the FTP executable.  In UNIX, Windows, or OS/2, it
  776. can be the filename of any executable program in your PATH (e.g. "ftp.exe" in
  777. Windows, "ftp" in UNIX); elsewhere (or if you do not have a PATH definition),
  778. it must be the fully specified pathname of the FTP program.  If the name
  779. contains any spaces, enclose it braces.  Include any options after the
  780. filename; these depend the particular ftp client.
  781.  
  782. The Web browser interface is covered in the following subsections.
  783.  
  784. 1.3.1. Invoking your Browser from C-Kermit
  785.  
  786. BROWSE [ <url> ]
  787.   Starts your preferred Web browser on the URL, if one is given, otherwise
  788.   on the most recently given URL, if any.  Returns to Kermit when the browser
  789.   exits.
  790.  
  791. SET BROWSER [ <name> [ <options> ] ]
  792.   Use this command to specify the name of your Web browser program, for
  793.   example: "set browser lynx".  The <name> must be in your PATH, or else
  794.   it must be a fully specified filename; in VMS it must be a DCL command.
  795.  
  796. SHOW BROWSER
  797.   Displays the current browser, options, and most recent URL.
  798.  
  799. Related variables: \v(browser), \v(browsopts), \v(browsurl).
  800.  
  801. Also see Section 2.15: Contacting Web Servers with the HTTP Command.
  802.  
  803. 1.3.2. Invoking C-Kermit from your Browser
  804.  
  805. The method for doing this depends, of course, on your browser.  Here are
  806. some examples:
  807.  
  808. Netscape on UNIX (X-based):
  809.   In the Options->Applications section, set your Telnet application to:
  810.  
  811.     xterm -e /usr/local/bin/kermit/kermit -J %h %p
  812.  
  813.   (replace "/usr/local/bin/kermit/kermit" by C-Kermit's actual pathname).
  814.   -J is C-Kermit's command-line option to "be like Telnet"; %h and %p are
  815.   Netscape placeholders for hostname and port.
  816.  
  817. Lynx:
  818.   As far as we know, this can be done only at compile time.  Add the
  819.   following line to the Lynx userdefs.h file before building the Lynx binary:
  820.  
  821. #define TELNET_COMMAND "/opt/bin/kermit -J"
  822.  
  823.   And then add lines like the following to the Lynx.cfg file:
  824.  
  825. DOWNLOADER:Kermit binary download:/opt/bin/kermit -i -V -s %s -a %s:TRUE
  826. DOWNLOADER:Kermit text download:/opt/bin/kermit -s %s -a %s:TRUE
  827.  
  828. UPLOADER:Kermit binary upload:/opt/bin/kermit -i -r -a %s:TRUE
  829. UPLOADER:Kermit text upload:/opt/bin/kermit -r -a %s:TRUE
  830. UPLOADER:Kermit text get:/opt/bin/kermit -g %s:TRUE
  831. UPLOADER:Kermit binary get:/opt/bin/kermit -ig %s:TRUE
  832.  
  833. 1.4. Command Editing
  834.  
  835. Ctrl-W ("Word delete") was changed in 7.0 to delete back to the previous
  836. non-alphanumeric, rather than all the way back to the previous space.
  837.  
  838. 1.5. Command Switches
  839.  
  840. As of 7.0, C-Kermit's command parser supports a new type of field, called
  841. a "switch".  This is an optional command modifier.
  842.  
  843. 1.5.1. General Switch Syntax
  844.  
  845. A switch is a keyword beginning with a slash (/).  If it takes a value, then
  846. the value is appended to it (with no intervening spaces), separated by a colon
  847. (:) or equal sign (=).  Depending on the switch, the value may be a number,
  848. a keyword, a filename, a date/time, etc.  Examples:
  849.  
  850.   send oofa.txt                              ; No switches
  851.   send /binary oofa.zip                      ; A switch without a value
  852.   send /protocol:zmodem oofa.zip             ; A switch with a value (:)
  853.   send /protocol=zmodem oofa.zip             ; A switch with a value (=)
  854.   send /text /delete /as-name:x.x oofa.txt   ; Several switches
  855.  
  856. Like other command fields, switches are separated from other fields, and from
  857. each other, by whitespace, as shown in the examples just above.  You can not
  858. put them together like so:
  859.  
  860.   send/text/delete/as-name:x.x oofa.txt
  861.  
  862. (as you might do in VMS or DOS, or as we might once have done in TOPS-10 or
  863. TOPS0-20, or PIP).  This is primarily due to ambiguity between "/" as switch
  864. introducer versus "/" as UNIX directory separator; e.g. in:
  865.  
  866.   send /delete/as-name:foo/text oofa.txt
  867.  
  868. Does "foo/text" mean the filename is "foo" and the transfer is to be in
  869. text mode, or does it mean the filename is "foo/text"?  Therefore we require
  870. whitespace between switches to resolve the ambiguity.  (That's only one of
  871. several possible ambiguities -- it is also conceivable that a file called
  872. "text" exists in the path "/delete/as-name:foo/").
  873.  
  874. In general, if a switch can take a value, but you omit it, then either a
  875. reasonable default value is supplied, or an error message is printed:
  876.  
  877.   send /print:-Plaserwriter oofa.txt         ; Value included = print options
  878.   send /print oofa.txt                       ; Value omitted, OK
  879.   send /mail:kermit@columbia.edu oofa.txt    ; Value included = address
  880.   send /mail oofa.txt                        ; Not OK - address required
  881.   ?Address required
  882.  
  883. Context-sensitive help (?) and completion (Esc or Tab) are available in the
  884. normal manner:
  885.  
  886.   C-Kermit> send /pr? Switch, one of the following:
  887.     /print /protocol
  888.   C-Kermit> send /pro<ESC>tocol:?  File-transfer protocol,
  889.    one of the following:
  890.     kermit   xmodem   ymodem   ymodem-g   zmodem
  891.   C-Kermit> send /protocol:k<TAB>ermit
  892.  
  893. If a switch takes a value and you use completion on it, a colon (:) is printed
  894. at the end of its name to indicate this.  If it does not take a value, a space
  895. is printed.
  896.  
  897. Also, if you type ? in a switch field, switches that take values are shown
  898. with a trailing colon; those that don't take values are shown without one.
  899.  
  900. 1.5.2. Order and Effect of Switches
  901.  
  902. The order of switches should not matter, except that they are evaluated from
  903. left to right, so if you give two switches with opposite effects, the
  904. rightmost one is used:
  905.  
  906.   send /text /binary oofa.zip                ; Sends oofa.zip in binary mode.
  907.  
  908. Like other command fields, switches have no effect whatsoever until the
  909. command is entered (by pressing the Return or Enter key).  Even then, switches
  910. affect only the command with which they are included; they do not have global
  911. effect or side effects.
  912.  
  913. 1.5.3. Distinguishing Switches from Other Fields
  914.  
  915. All switches are optional.  A command that uses switches lets you give any
  916. number of them, including none at all.  Example:
  917.  
  918.   send /binary oofa.zip
  919.   send /bin /delete oofa.zip
  920.   send /bin /as-name:mupeen.zip oofa.zip
  921.   send oofa.zip
  922.  
  923. But how does Kermit know when the first "non-switch" is given?  It has been
  924. told to look for both a switch and for something else, the data type of the
  925. next field (filename, number, etc).  In most cases, this works well.  But
  926. conflicts are not impossible.  Suppose, for example, in UNIX there was a file
  927. named "text" in the top-level directory.  The command to send it would be:
  928.  
  929.   send /text
  930.  
  931. But C-Kermit would think this was the "/text" switch.  To resolve the
  932. conflict, use braces:
  933.  
  934.   send {/text}
  935.  
  936. or other circumlocutions such as "send //text", "send /./text", etc.
  937.  
  938. The opposite problem can occur if you give an illegal switch that happens
  939. to match a directory name.  For example:
  940.  
  941.   send /f oofa.txt
  942.  
  943. There is no "/f" switch (there are several switches that begin with "/f",
  944. so "/f" is ambiguous).  Now suppose there is an "f" directory in the root
  945. directory; then this command would be interpreted as:
  946.  
  947.   Send all the files in the "/f" directory,
  948.   giving each one an as-name of "oofa.txt".
  949.  
  950. This could be a mistake, or it could be exactly what you intended; C-Kermit
  951. has no way of telling the difference.  To avoid situations like this, spell
  952. switches out in full until you are comfortable enough with them to know the
  953. minimum abbreviation for each one.  Hint: use ? and completion while typing
  954. switches to obtain the necessary feedback.
  955.  
  956. 1.5.4. Standard File Selection Switches
  957.  
  958. The following switches are used on different file-oriented commands (such as
  959. SEND, DIRECTORY, DELETE, PURGE) to refine the selection of files that match
  960. the given specification.
  961.  
  962.   /AFTER:<date-time>
  963.     Select only those files having a date-time later than the one given.
  964.     See Section 1.6 for date-time formats.  Synonym: /SINCE.
  965.  
  966.   /NOT-AFTER:<date-time>
  967.     Select only those files having a date-time not later than (i.e. earlier or
  968.     equal to) the one given.  Synonym: /NOT-SINCE.
  969.  
  970.   /BEFORE:<date-time>
  971.     Select only those files having a date-time earlier than the one given.
  972.  
  973.   /NOT-BEFORE:<date-time>
  974.     Select only those files having a date-time not earlier than (i.e. later or
  975.     equalto) the one given.
  976.  
  977.   /DOTFILES
  978.     UNIX and OS-9 only: The filespec is allowed to match files whose names
  979.     start with (dot) period.  Normally these files are not shown.
  980.  
  981.   /NODOTFILES
  982.     (UNIX and OS-9 only) Don't show files whose names start with dot (period).
  983.     This is the opposite of /DOTFILES, and is the default.  Note that when a
  984.     directory name starts with a period, the directory and (in recursive
  985.     operations) all its subdirectories are skipped.
  986.  
  987.   /LARGER-THAN:<number>
  988.     Only select files larger than the given number of bytes.
  989.  
  990.   /SMALLER-THAN:<number>
  991.     Only select files smaller than the given number of bytes.
  992.  
  993.   /EXCEPT:pattern
  994.     Specifies that any files whose names match the pattern, which can be a
  995.     regular filename, or may contain "*" and/or "?" metacharacters (wildcards),
  996.     are not to be selected.  Example:
  997.  
  998.       send /except:*.log *.*
  999.  
  1000.     sends all files in the current directory except those with a filetype of
  1001.     ".log".  Another:
  1002.  
  1003.       send /except:*.~*~ *.*
  1004.  
  1005.     sends all files except the ones that look like Kermit or EMACS backup
  1006.     files (such as "oofa.txt.~17~") (of course you can also use the /NOBACKUP
  1007.     switch for this).
  1008.  
  1009.     The pattern matcher is the same one used by IF MATCH <string> <pattern>
  1010.     (Section 7.4), so you can test your patterns using IF MATCH.  If you need
  1011.     to match a literal * or ? (etc), precede it by a backslash (\).  If the
  1012.     pattern contains any spaces, it must be enclosed in braces:
  1013.  
  1014.       send /except:{Foo bar} *.*
  1015.  
  1016.     The pattern can also be a list of up to 8 patterns.  In this case, the
  1017.     entire pattern must be enclosed in braces, and each sub-pattern must also
  1018.     be enclosed in braces; this eliminates the need for designating a
  1019.     separator character, which is likely to also be a legal filename character
  1020.     on some platform or other, and therefore a source of confusion.  You may
  1021.     include spaces between the subpatterns but they are not necessary.  The
  1022.     following two commands are equivalent:
  1023.  
  1024.       send /except:{{ck*.o} {ck*.c}} ck*.?
  1025.       send /except:{{ck*.o}{ck*.c}} ck*.?
  1026.  
  1027.     If a pattern is to include a literal brace character, precede it with \.
  1028.     Also note the apparent conflict of this list format and the string-list
  1029.     format described in section 4.9.1.  In case you want to include a wildcard
  1030.     string-list with braces on its outer ends as an /EXCEPT: argument, do it
  1031.     like this:
  1032.  
  1033.       send /except:{{{ckuusr.c,ckuus2.c,ckuus6.c}}} ckuus*.c
  1034.  
  1035. 1.5.5. Setting Preferences for Different Commands
  1036.  
  1037. Certain oft-used commands offer lots of switches because different people
  1038. have different requirements or preferences.  For example, some people want
  1039. to be able to delete files without having to watch a list of the deleted
  1040. files scroll past, while others want to be prompted for permission to delete
  1041. each file.  Different people prefer different directory-listing styles.  And
  1042. so on.  Such commands can be tailored with the SET OPTIONS command:
  1043.  
  1044. SET OPTIONS <command> [ switch [  switch [ ... ] ] ]
  1045.   Sets each switch as the default for the given command, replacing the
  1046.   "factory default".  Of course you can also override any defaults established
  1047.   by the SET OPTIONS command by including the relevant switches in the
  1048.   affected command any time you issue it.
  1049.  
  1050. SHOW OPTIONS
  1051.   Lists the commands that allows option-setting, and the options currently
  1052.   in effect, if any, for each.  Switches that have synonyms are shown under
  1053.   their primary name; for example. /LOG and /VERBOSE are shown as /LIST.
  1054.  
  1055. Commands for which options may be set include DIRECTORY, DELETE, PURGE,
  1056. and TYPE.  Examples:
  1057.  
  1058.   SET OPTIONS DIRECTORY /PAGE /NOBACKUP /HEADING /SORT:DATE /REVERSE
  1059.   SET OPTIONS DELETE /LIST /NOHEADING /NOPAGE /NOASK /NODOTFILES
  1060.   SET OPTIONS TYPE /PAGE
  1061.  
  1062. Not necessarily all of a command's switches can be set as options.  For
  1063. example, file selection switches, since these would normally be different for
  1064. each command.
  1065.  
  1066. Put the desired SET OPTIONS commands in your C-Kermit customization file for
  1067. each command whose default switches you want to change every time you run
  1068. C-Kermit.
  1069.  
  1070. 1.6. Dates and Times
  1071.  
  1072. Some commands and switches take date-time values, such as:
  1073.  
  1074.   send /after:{8-Feb-2000 10:28:01}
  1075.  
  1076. Various date-time formats are acceptable.  The rules for the date are:
  1077.  
  1078.  . The year must have 4 digits.
  1079.  . If the year comes first, the second field is the month.
  1080.  . The day, month, and year may be separated by spaces, /, -, or underscore.
  1081.  . The month may be numeric (1 = January) or spelled out or abbreviated in
  1082.    English.
  1083.  
  1084. If the date-time string contains any spaces, it must be enclosed in braces.
  1085. Examples of legal dates:
  1086.                            Interpretation:
  1087.   2000-Feb-8                8 February 2000
  1088.   {2000 Feb 8}              8 February 2000
  1089.   2000/Feb/8                8 February 2000
  1090.   2000_Feb_8                8 February 2000
  1091.   2000-2-8                  8 February 2000
  1092.   2000-02-08                8 February 2000
  1093.   8-Feb-2000                8 February 2000
  1094.   08-Feb-2000               8 February 2000
  1095.   12/25/2000                25 December 2000
  1096.   25/12/2000                25 December 2000
  1097.  
  1098. The last two examples show that when the year comes last, and the month is
  1099. given numerically, the order of the day and month doesn't matter as long as
  1100. the day is 13 or greater (mm/dd/yyyy is commonly used in the USA, whereas
  1101. dd/mm/yyyy is the norm in Europe).  However:
  1102.  
  1103.   08/02/2000                Is ambiguous and therefore not accepted.
  1104.  
  1105. If a date is given, the time is optional and defaults to 00:00:00.  If the
  1106. time is given with a date, it must follow the date, separated by space, /, -,
  1107. or underscore, and with hours, minutes, and seconds separated by colon (:).
  1108. Example:
  1109.  
  1110.   2000-Feb-8 10:28:01       Represents 8 February 2000, 10:28:01am
  1111.  
  1112. If a date is not given, the current date is used and a time is required.
  1113.  
  1114. Time format is hh:mm:ss or hh:mm or hh in 24-hour format, or followed by "am"
  1115. or "pm" (or "AM" or "PM") to indicate morning or afternoon.  Examples of times
  1116. that are acceptable:
  1117.                            Interpretation:
  1118.   3:23:56                    3:23:56am
  1119.   3:23:56am                  3:23:56am
  1120.   3:23:56pm                  3:23:56pm = 15:23:56
  1121.  15:23:56                    3:23:56pm = 15:23:56
  1122.   3:23pm                     3:23:00pm = 15:23:00
  1123.   3:23PM                     3:23:00pm = 15:23:00
  1124.   3pm                        3:00:00pm = 15:00:00
  1125.  
  1126. Examples of legal date-times:
  1127.  
  1128.   send /after:{8 Feb 2000 10:28:01}
  1129.   send /after:8_Feb_2000_10:28:01
  1130.   send /after:8-Feb-2000/10:28:01
  1131.   send /after:2000/02/08/10:28:01
  1132.   send /after:2000/02/08_10:28:01
  1133.   send /after:2000/02/08_10:28:01am
  1134.   send /after:2000/02/08_10:28:01pm
  1135.   send /after:2000/02/08_10:28pm
  1136.   send /after:2000/02/08_10pm
  1137.   send /after:10:00:00pm
  1138.   send /after:10:00pm
  1139.   send /after:10pm
  1140.   send /after:22
  1141.  
  1142. Finally, there is a special all-numeric format you can use:
  1143.  
  1144.   yyyymmdd hh:mm:ss
  1145.  
  1146. For example:
  1147.  
  1148.   20000208 10:28:01
  1149.  
  1150. This is Kermit's (and ISO 8061) standard date-time format, and is accepted
  1151. (among other formats) by any command or switch that requires a date-time, and
  1152. is output by any function whose result is a calendar date-time.
  1153.  
  1154. There are no optional parts to this format and it must be exactly 17
  1155. characters long, punctuated as shown (except you can substitute underscore
  1156. for space in contexts where a single "word" is required).  The time is in
  1157. 24-hour format (23:00:00 is 11:00pm).  This is the format returned by
  1158. \fdate(filename), so you can also use constructions like this:
  1159.  
  1160.   send /after:\fdate(oofa.txt)
  1161.  
  1162. which means "all files newer than oofa.txt".
  1163.  
  1164. Besides explicit dates, you can also use the any of the following shortcuts:
  1165.  
  1166. TODAY
  1167.   Stands for the current date at 00:00:00.
  1168.  
  1169. TODAY 12:34:56
  1170.   Stands for the current date at the given time.
  1171.  
  1172. YESTERDAY
  1173.   Stands for yesterday's date at 00:00:00.  A time may also be given.
  1174.  
  1175. TOMORROW
  1176.   Stands for tomorrow's date at 00:00:00.  A time may also be given.
  1177.  
  1178. + <number> { DAYS, WEEKS, MONTHS, YEARS } [ time ]
  1179.   Is replaced by the future date indicated, relative to the current date.
  1180.   If the time is omitted, 00:00:00 is used.  Examples: +3days, +2weeks,
  1181.   +1year, +37months.
  1182.  
  1183. - <number> { DAYS, WEEKS, MONTHS, YEARS } [ time ]
  1184.   Is replaced by the past date indicated, relative to the current date.
  1185.   If the time is omitted, 00:00:00 is used.
  1186.  
  1187. The time can be separated from the date shortcut by any of the same separators
  1188. that are allowed for explicit date-times: space, hyphen, slash, period, or
  1189. underscore.  In switches and other space-deliminted fields, use non-spaces
  1190. to separate date/time fields, or enclose the date-time in braces, e.g.:
  1191.  
  1192.   purge /before:-4days_12:00:00
  1193.  
  1194. or:
  1195.  
  1196.   purge /before:{- 4 days 12:00:00}
  1197.  
  1198. Of course you can also use variables:
  1199.  
  1200.   define \%n 43
  1201.   purge /before:-\%ndays_12:00:00
  1202.  
  1203. Shortcut names can be abbreviated to any length that still distintuishes them
  1204. from any other name that can appear in the same context, e.g. "TOD" for today,
  1205. "Y" for yesterday.  Also, the special abbrevation "wks" is accepted for
  1206. WEEKS, and "yrs" for "YEARS".
  1207.  
  1208. (To see how to specify dates relative to a specific date, rather than the
  1209. current one, see the \fmjd() function description below.)
  1210.  
  1211. You can check date formats with the DATE command.  DATE by itself prints the
  1212. current date and time in standard format: yyyymmdd hh:mm:ss.  DATE followed by
  1213. a date and/or time (including shortcuts) converts it to standard format if it
  1214. can understand it, otherwise it prints an error message.
  1215.  
  1216. The following variables and functions deal with dates and times; any function
  1217. argument designated as "date-time" can be in any of the formats described
  1218. above.
  1219.  
  1220. \v(day)
  1221.   The first three letters of the English word for the current day of the
  1222.   week, e.g. "Wed".
  1223.  
  1224. \fday(date-time)
  1225.   The first three letters of the English word for day of the week of
  1226.   the given date.  If a time is included, it is ignored.  Example:
  1227.   \fday(8 Feb 1988) = "Mon".
  1228.  
  1229. \v(nday)
  1230.   The numeric day of the week: 0 = Sunday, 1 = Monday, ..., 6 = Saturday.
  1231.  
  1232. \fnday(date-time)
  1233.   The numeric day of the week for the given date.  If a time is included, it
  1234.   is ignored.  Example: \fnday(8 Feb 1988) = "1".
  1235.  
  1236. \v(date)
  1237.   The current date as dd mmm yyyy, e.g. "08 Feb 2000" (as in this example,
  1238.   a leading zero is supplied for day-of-month less than 10).
  1239.  
  1240. \v(ndate)
  1241.   The current date in numeric format: yyyymmdd, e.g. "20000208".
  1242.  
  1243. \v(time)
  1244.   The current time as hh:mm:ss, e.g. "15:27:14".
  1245.  
  1246. \ftime(time)
  1247.   The given free-format date and/or time (e.g. "3pm") returns the time
  1248.   (without the date) converted to hh:mm:ss 24-hour format, e.g. "15:00:00"
  1249.   (the date, if given, is ignored).
  1250.  
  1251. \v(ntime)
  1252.   The current time as seconds since midnight, e.g. "55634".
  1253.  
  1254. \v(tftime)
  1255.   The elapsed time of the most recent file-transfer operation in seconds.
  1256.  
  1257. \v(intime)
  1258.   The elapsed time for the most recent INPUT command to complete, in
  1259.   milliseconds.
  1260.  
  1261. \fntime(time)
  1262.   The given free-format date and/or time is converted to seconds since
  1263.   midnight (the date, if given, is ignored).  This function replaces
  1264.   \ftod2secs(), which is now a synonym for \fntime().  Unlike \ftod2secs(),
  1265.   \fntime() allows a date to be included, and it allows the time to be in
  1266.   free format (like 3pm), and it allows the amount of time to be more than
  1267.   24 hours.  E.g. \fntime(48:00:00) = 172800.  Example of use:
  1268.     set alarm \fntime(48:00:00) ; set alarm 48 hours from now.
  1269.  
  1270. \fn2time(seconds)
  1271.   The given number of seconds is converted to hh:mm:ss format.
  1272.  
  1273. \fdate(filename)
  1274.   Returns the modification date-time of the given file in standard format:
  1275.   yyyymmdd hh:mm:ss.
  1276.  
  1277. \fcvtdate(date-time)
  1278.   Converts a free-format date and/or time to Kermit standard format: yyyymmdd
  1279.   hh:mm:ss.  If no argument is given, returns the current date-time in
  1280.   standard format.  If a date is given but no time, the converted date is
  1281.   returned without a time.  If a time is given with no date, the current
  1282.   date is supplied.  Examples:
  1283.     \fcvtdate(4 Jul 2000 2:21:17pm) = 20000704 14:21:17
  1284.     \fcvtdate() = 20000704 14:21:17 (on 4 Jul 2000 at 2:21:17pm).
  1285.     \fcvtd(4 Jul 2000) = 20000704
  1286.     \fcvtd(6pm) = 20000704 18:00:00 (on 4 Jul 2000 at 6:00pm).
  1287.  
  1288. \fdayofyear(date-time)
  1289. \fdoy(date-time)
  1290.   Converts a free-format date and/or time to yyyyddd, where ddd is the 3-digit
  1291.   day of the year, where 1 January is Day 1.  If a time is included with the
  1292.   date, it is returned in standard format.  If a date is included but no time,
  1293.   the date is returned without a time.  If a time is given with no date, the
  1294.   time is converted and the current date is supplied.  If no argument is
  1295.   given, the current date-time is returned.  Synonym: \fdoy().  Examples:
  1296.     \fddayofyear(4 Jul 2000 2:21:17pm) = 2000185 14:21:17
  1297.     \fdoy() = 2000185 14:21:17 (on 4 Jul 2000 at 2:21:17pm).
  1298.     \fdoy(4 Jul 2000) = 2000185
  1299.     \fdoy(6pm) = 2000185 18:00:00 (on 4 Jul 2000 at 6:00pm).
  1300.  
  1301. Note: The yyyyddd day-of-year format is often erroneously referred to as a
  1302. Julian date.  However, a true Julian date is a simple counting number, the
  1303. number of days since a certain fixed day in the past.  See \fmjd() below.
  1304.  
  1305. \fdoy2date(date-time)
  1306.   Converts a date or date-time in day-of-year format to a standard format
  1307.   date.  A yyyyddd-format date must be supplied; time is optional.  The
  1308.   given date is converted to yyyymmdd format.  If a time is given, it is
  1309.   converted to 24-hour format.  Examples:
  1310.     \fdoy2date(2000185) = 20000704
  1311.     \fdoy2(2000185 3pm) = 20000704 15:00:00
  1312.  
  1313. \fmjd(date-time)
  1314.   Converts free-format date and/or time to a Modified Julian Date (MJD),
  1315.   the number of days since 17 Nov 1858 00:00:00.  If a time is given, it is
  1316.   ignored.  Examples:
  1317.      \fmjd(4 Jul 2000) = 50998
  1318.      \fmjd(17 Nov 1858) = 0
  1319.      \fmjd(16 Nov 1858) = -1
  1320.  
  1321. \fmjd2date(mjd)
  1322.   Converts an MJD (integer) to standard date format, yyyymmdd:
  1323.      \fmjd2(50998) = 4 Jul 1998
  1324.      \fmjd2(0) = 17 Nov 1858
  1325.      \fmjd2(-1) = 16 Nov 1858
  1326.      \fmjd2(-365) = 17 Nov 1857
  1327.  
  1328. MJDs are normal integers and, unlike DOYs, may be added, subtracted, etc, with
  1329. each other or with other integers, to obtain meaningful results.  For example,
  1330. to find out the date 212 days ago:
  1331.  
  1332.   echo \fmjd2date(\fmjd()-212)
  1333.  
  1334. Constructions such as this can be used in any command where a date-time
  1335. is required, e.g.:
  1336.  
  1337.   send /after:\fmjd2date(\fmjd()-212)
  1338.  
  1339. to send all files that are not older than 212 days (this is equivalent to
  1340. "send /after:-212days").
  1341.  
  1342. MJDs also have other regularities not exhibited by other date formats.  For
  1343. example, \fmodulus(\fmjd(any-date),7) gives the day of the week for any date
  1344. (where 4=Sun, 5=Mon, ..., 3=Sat).  (However, it is easier to use \fnday() for
  1345. this purpose, and it gives the more conventional result of 0=Sun, 1=Mon, ...,
  1346. 6=Sat).
  1347.  
  1348. Note that if MJDs are to be compared, they must be compared numerically
  1349. (IF <, =, >) and not lexically (IF LLT, EQUAL, LGT), whereas DOYs must be
  1350. compared lexically if they include a time (which contains ":" characters);
  1351. however, if DOYs do not include a time, they may also be compared numerically.
  1352.  
  1353. In any case, lexical comparison of DOYs always produces the appropriate
  1354. result, as does numeric comparison of MJDs.
  1355.  
  1356. The same comments apply to sorting.  Also note that DOYs are fixed length, but
  1357. MJDs can vary in length.  However, all MJDs between 3 April 1886 and 30 Aug
  1358. 2132 are 5 decimal digits long.  (MJDs become 6 digits long on 31 Aug 2132,
  1359. and 7 digits long on 13 Oct 4596).
  1360.  
  1361. 1.7. Partial Completion of Keywords
  1362.  
  1363. Partial completion of keywords was added in C-Kermit 7.0.  In prior versions,
  1364. if completion was attempted (by pressing the Esc or Tab key) on a string that
  1365. matched different keywords, you'd just get a beep.  Now Kermit completes up to
  1366. the first character where the possibly matching keywords differ and then
  1367. beeps.  For example:
  1368.  
  1369.   send /n<Tab>
  1370.  
  1371. which matches /NOT-BEFORE and /NOT-AFTER, now completes up to the dash:
  1372.  
  1373.   send /n<Tab>ot-<Beep>
  1374.  
  1375. Partial completion works for filenames too (as it has for some years).
  1376.  
  1377. 1.8. Command Recall
  1378.  
  1379. C-Kermit has had a command history buffer for some time, which could be
  1380. scrolled interactively using control characters or (in Kermit 95 only) arrow
  1381. keys.  Version 7.0 adds a REDO command that allows the most recent command
  1382. matching a given pattern to be re-executed:
  1383.  
  1384. { REDO, RR, ^ } [ <pattern> ]
  1385.   Search the command history list for the most recent command that matches
  1386.   the given pattern, and if one is found, execute it again.
  1387.  
  1388. The pattern can be a simple string (like "send"), in which case the last SEND
  1389. command is re-executed.  Or it can contain wildcard characters "*" and/or "?",
  1390. which match any string and any single character, respectively (note that "?"
  1391. must be preceded by backslash to override its normal function of giving help),
  1392. and in most C-Kermit versions may also include [] character lists and {}
  1393. string lists (see Section 4.9).
  1394.  
  1395. The match works by appending "*" to the end of the given pattern (if you
  1396. didn't put one there yourself).  Thus "redo *oofa" becomes "redo *oofa*" and
  1397. therefore matches the most recent command that contains "oofa" anywhere within
  1398. the command.  If you want to inhibit the application of the trailing "*",
  1399. e.g. to force matching a string at the end of a command, enclose the pattern
  1400. in braces:
  1401.  
  1402.   redo {*oofa}
  1403.  
  1404. matches the most recent command that ends with "oofa".
  1405.  
  1406. REDO commands themselves are not entered into the command history list.  If no
  1407. pattern is given, the previous (non-REDO) command is re-executed.  The REDOne
  1408. command is reinserted at the end of the command history buffer, so the command
  1409. scrollback character (Ctrl-P, Ctrl-B, or Uparrow) can retrieve it.
  1410.  
  1411. Examples:
  1412.  
  1413.   C-Kermit>echo foo
  1414.   foo
  1415.   C-Kermit>show alarm
  1416.   (no alarm set)
  1417.   C-Kermit>echo blah
  1418.   blah
  1419.   C-Kermit>redo          ; Most recent command
  1420.   blah
  1421.   C-Kermit>redo s        ; Most recent command starting with "s"
  1422.   (no alarm set)
  1423.   C-Kermit>redo echo f   ; Most recent command starting with "echo f"
  1424.   foo
  1425.   C-Kermit>redo *foo     ; Most recent command that has "foo" in it
  1426.   foo
  1427.   C-Kermit><Ctrl-P>      ; Scroll back
  1428.   C-Kermit>echo foo      ; The REDOne command is there
  1429.   C-Kermit>redo {*foo}   ; Most recent command that ends with "foo"
  1430.   foo
  1431.   C-Kermit>
  1432.  
  1433. Since REDO, REDIAL, and REDIRECT all start the same way, and RED is the
  1434. designated non-unique abbreviation for REDIAL, REDO must be spelled out in
  1435. full.  For convenience, RR is included as an invisible easy-to-type synonym
  1436. for REDO.  You can also use the "^" character for this:
  1437.  
  1438.   C-Kermit>^             ; Most recent command
  1439.   C-Kermit>^ s           ; Most recent command starting with "s"
  1440.   C-Kermit>^s            ; Ditto (space not required after "^").
  1441.   C-Kermit>^*foo         ; Most recent command that has "foo" in it.
  1442.   C-Kermit>^{*foo}       ; Most recent command ends with "foo".
  1443.  
  1444. Unlike the manual command-history-scrolling keys, the REDO command can be
  1445. used in a script, but it's not recommended (since the command to be REDOne
  1446. might not be found, so if the REDO command fails, you can't tell whether it
  1447. was because REDO failed to find the requested command, or because the command
  1448. was found but it failed).
  1449.  
  1450. 1.9. EXIT Messages
  1451.  
  1452. The EXIT and QUIT commands now accept an optional message to be printed.
  1453. This makes the syntax of EXIT and QUIT just like END and STOP:
  1454.  
  1455.   { EXIT, QUIT, END, STOP } [ <status-code> [ <message> ] ]
  1456.  
  1457. where <status-code> is a number (0 indicating success, nonzero indicating
  1458. failure).  This is handy in scripts that are never supposed to enter
  1459. interactive mode:
  1460.  
  1461.   dial 7654321
  1462.   if fail exit 1 Can't make connection - try again later.
  1463.  
  1464. Previously this could only be done in two steps:
  1465.  
  1466.   dial 7654321
  1467.   xif fail { echo Can't make connection - try again later, exit 1 }
  1468.  
  1469. A status code must be included in order to specify a message.  In the case
  1470. of EXIT and QUIT, the default status code is contained in the variable
  1471. \v(exitstatus), and is set automatically by various events (file transfer
  1472. failures, etc; it can also be set explicitly with the SET EXIT STATUS
  1473. command).  If you want to give an EXIT or QUIT command with a message, but
  1474. without changing the exit status from what it normally would have been, use
  1475. the \v(exitstatus) variable, e.g.:
  1476.  
  1477.    exit \v(existatus) Goodbye from \v(cmdfile).
  1478.  
  1479. The EXIT status is returned to the system shell or whatever other process
  1480. invoked C-Kermit, e.g. in UNIX:
  1481.  
  1482.   C-Kermit> exit 97 bye bye
  1483.   bye bye
  1484.   $ echo $?
  1485.   97
  1486.   $
  1487.  
  1488. 1.10. Managing Keyboard Interruptions
  1489.  
  1490. When C-Kermit is in command or file-transfer mode (as opposed to CONNECT
  1491. mode), it can be interrupted with Ctrl-C.  Version 7.0 adds the ability to
  1492. disarm the Ctrl-C interrupt:
  1493.  
  1494. SET COMMAND INTERRUPT { ON, OFF }
  1495.   COMMAND INTERRUPT is ON by default, meaning the Ctrl-C can be used to
  1496.   interrupt a command or a file transfer in progress.  Use OFF to disable
  1497.   these interruptions, and use it with great caution for obvious reasons.
  1498.  
  1499. SET TRANSFER INTERRUPT { ON, OFF }
  1500.   This can be used to disable keyboard interruption of file transfer when
  1501.   C-Kermit is in local mode, or to re-enable it after it has been disabled.
  1502.   This applies to the X, Z, E, and similar keys as well as to the system
  1503.   interrupt character, usually Ctrl-C.  This is distinct from SET TRANSFER
  1504.   CANCELLATION, which tells whether packet mode can be exited by sending a
  1505.   special sequence of characters.
  1506.  
  1507. Several other commands can be interrupted by pressing any key while they are
  1508. active.  Version 7.0 adds the ability to disable this form of interruption
  1509. also:
  1510.  
  1511. SET INPUT CANCELLATION { ON, OFF }
  1512.   Whether an INPUT command in progress can be interrupted by pressing a key.
  1513.   Normally ON.  Setting INPUT CANCELLATION OFF makes INPUT commands
  1514.   uninterruptible except by Ctrl-C (unless COMMAND INTERRUPTION is also OFF).
  1515.  
  1516. SET SLEEP CANCELLATION { ON, OFF }
  1517.   Whether a SLEEP, PAUSE, or WAIT command in progress can be interrupted by
  1518.   pressing a key.  Normally ON.  Setting SLEEP CANCELLATION OFF makes these
  1519.   commands uninterruptible except by Ctrl-C (unless COMMAND INTERRUPTION is
  1520.   also OFF).  Synonyms: SET PAUSE CANCELLATION, SET WAIT CANCELLATION.
  1521.  
  1522. So to make certain a script is not interruptible by the user, include these
  1523. commands:
  1524.  
  1525.   SET TRANSFER INTERRUPT OFF
  1526.   SET SLEEP CANCELLATION OFF
  1527.   SET INPUT CANCELLATION OFF
  1528.   SET COMMAND INTERRUPTION OFF
  1529.  
  1530. Make sure to turn them back on afterwards.
  1531.  
  1532. When a PAUSE, SLEEP, WAIT, or INPUT command is interrupted from the keyboard,
  1533. the new variable \v(kbchar) contains a copy of the (first) character that was
  1534. typed and caused the interruption, provided it was not the command interrupt
  1535. character (usually Ctrl-C).  If these commands complete successfully or time
  1536. out without a keyboard interruption, the \v(kbchar) variable is empty.
  1537.  
  1538. The \v(kbchar) variable (like any other variable) can be tested with:
  1539.  
  1540.   if defined \v(kbchar) <command>
  1541.  
  1542. The <command> is executed if the variable is not empty.
  1543.  
  1544. The \v(kbchar) variable can be reset with WAIT 0 (PAUSE 0, SLEEP 0, etc).
  1545.  
  1546. 1.11. Taming The Wild Backslash -- Part Deux
  1547.  
  1548. "Using C-Kermit", 2nd Edition, contains a brief section, "Taming the Wild
  1549. Backslash", on page 48, which subsequent experience has shown to be inadequate
  1550. for Kermit users intent on writing scripts that deal with Windows, DOS, and
  1551. OS/2 filenames, in which backslash (\) is used as the directory separator.
  1552. This section fills in the blanks.
  1553.  
  1554. 1.11.1. Background
  1555.  
  1556. The Kermit command language shares a certain unavoidable but annoying
  1557. characteristic with most other command languages that are capable of string
  1558. replacement, namely the necessity to "quote" certain characters when you want
  1559. them to be taken literally.  This is a consequence of the facts that:
  1560.  
  1561.  a. One or more characters must be set aside to denote replacement, rather
  1562.     than acting as literal text.
  1563.  
  1564.  b. We have only 96 printable characters to work with in ASCII, which is
  1565.     still the only universally portable character set.
  1566.  
  1567.  c. There is no single printable character that is unused everywhere.
  1568.  
  1569.  d. Variables are not restricted to certain contexts, as they are
  1570.     in formal programming languages like C and Fortran, but can appear
  1571.     anywhere at all within a command, and therefore require special syntax.
  1572.  
  1573. Thus there can be conflicts.  To illustrate, the standard UNIX shell uses
  1574. dollar sign ($) to introduce variables.  So the shell command:
  1575.  
  1576.   echo $TERM
  1577.  
  1578. displays the value of the TERM variable, e.g. vt320.  But suppose you want to
  1579. display a real dollar sign:
  1580.  
  1581.   echo The price is $10.20
  1582.  
  1583. This causes the shell to evaluate the variable "$1", which might or might not
  1584. exist, and substitute its value, e.g.:
  1585.  
  1586.   The price is 0.20
  1587.  
  1588. (in this case the $1 variable had no value.)  This is probably not what you
  1589. wanted.  To force the dollar sign to be taken literally, you must apply a
  1590. "quoting rule", such as "precede a character by backslash (\) to force the
  1591. shell to take the character literally":
  1592.  
  1593.   echo The price is \$10.20
  1594.   The price is $10.20
  1595.  
  1596. But now suppose you want the backslash AND the dollar sign to be taken
  1597. literally:
  1598.  
  1599.   echo The price is \\$10.20
  1600.  
  1601. This doesn't work, since the first backslash quotes the second one, thereby
  1602. leaving the dollar sign unquoted again:
  1603.  
  1604.   The price is \0.20
  1605.  
  1606. Quoting the dollar sign requires addition of a third backslash:
  1607.  
  1608.   echo The price is \\\$10.20
  1609.   The price is \$10.20
  1610.  
  1611. The first backslash quotes the second one, and the third backslash quotes
  1612. the dollar sign.
  1613.  
  1614. Every command language -- all UNIX shells, VMS DCL, DOS Batch, AOS/VS CLI, etc
  1615. etc -- has similar rules.  UNIX shell rules are probably the most complicated,
  1616. since many printable characters -- not just one -- are special there: dollar
  1617. sign, single quote, double quote, backslash, asterisk, accent grave, number
  1618. sign, ampersand, question mark, parentheses, brackets, braces, etc --
  1619. practically every non-alphanumeric character needs some form of quoting if it
  1620. is to be taken literally.  And to add to the confusion, the UNIX shell offers
  1621. many forms of quoting, and many alternative UNIX shells are available, each
  1622. using slightly different syntax.
  1623.  
  1624. 1.11.2. Kermit's Quoting Rules
  1625.  
  1626. Kermit's basic quoting rules are simple by comparison (there are, of course,
  1627. additional syntax requirements for macro definitions, command blocks, function
  1628. calls, etc, but they are not relevant here).
  1629.  
  1630. The following characters are special in Kermit commands:
  1631.  
  1632. Backslash (\)
  1633.   Introduces a variable, or the numeric representation of a special character,
  1634.   or a function, or other item for substitution.  If the backslash is followed
  1635.   by a digit or by any of the following characters:
  1636.  
  1637.     x, o, d, m, f, v, $, %, &, {
  1638.  
  1639.   this indicates a special substitution item; otherwise the following
  1640.   character is to be taken literally (exceptions: \ at end of line is taken
  1641.   literally; \n, \b, and \n are special items in the OUTPUT command only).
  1642.  
  1643. Semicolon (;)
  1644.   (Only when at the beginning of a line or preceded by at least one space
  1645.   or tab)  Introduces a comment.
  1646.  
  1647. Number sign (#)
  1648.   (Only when at the beginning of a line or preceded by at least one space
  1649.   or tab)  Just like semicolon; introduces a comment.
  1650.  
  1651. Question mark (?)
  1652.   (Only at the command prompt - not in command files or macros)  Requests
  1653.   context-sensitive help.
  1654.  
  1655. To force Kermit to take any of these characters literally, simply precede it
  1656. by a backslash (\).
  1657.  
  1658. Sounds easy!  And it is, except when backslash also has a special meaning to
  1659. the underlying operating system, as it does in DOS, Windows, and OS/2, where
  1660. it serves as the directory separator in filenames such as:
  1661.  
  1662.   D:\K95\KEYMAPS\READ.ME
  1663.  
  1664. Using our rule, we would need to refer to this file in Kermit commands as
  1665. follows:
  1666.  
  1667.   D:\\K95\\KEYMAPS\\READ.ME
  1668.  
  1669. But this would not be obvious to new users of Kermit software on DOS, Windows,
  1670. or OS/2, and it would be annoying to seasoned ones.  Thus MS-DOS Kermit and
  1671. Kermit 95 go to rather extreme lengths to allow the more natural notation, as
  1672. in:
  1673.  
  1674.   send d:\k95\keymaps\read.me
  1675.  
  1676. The reason this is tricky is that we also need to allow for variables and
  1677. other expressions introduced by backslash in the same command.  For example,
  1678. suppose \%a is a variable whose value is "oofa" (without the quotes).  What
  1679. does the following command do?
  1680.  
  1681.   send d:\%a
  1682.  
  1683. Does it send the file named "oofa" in the current directory of the D: disk, or
  1684. does it send a file named "%a" in the root directory of the D: disk?  This is
  1685. the kind of trouble we get into when we attempt to bend the rules in the
  1686. interest of user friendliness.  (The answer is: if the variable \%a has
  1687. definition that is the name of an existing file, that file is sent; if a file
  1688. d:\%a exists, it is sent; otherwise if both conditions are true, the variable
  1689. takes precedence, and the literal filename can be forced by quoting: \\%a.)
  1690.  
  1691. In Kermit 95 (but not MS-DOS Kermit), we also bend the rules another way by
  1692. allowing you to use forward slash (/) rather than backslash (\) as the
  1693. directory separator:
  1694.  
  1695.   send d:/k95/keymaps/read.me
  1696.  
  1697. This looks more natural to UNIX users, and in fact is perfectly acceptable to
  1698. the Windows 95/98/NT and OS/2 operating systems on the API level.  BUT (there
  1699. is always a "but") the Microsoft shell, COMMAND.COM, for Windows 95/98 and NT
  1700. does not allow this notation, and therefore it can not be used in any Kermit
  1701. command -- such as RUN -- that invokes the Windows command shell AND your
  1702. command shell is COMMAND.COM or any other shell that does not allow forward
  1703. slash as directory separator (some alternative shells do allow this).
  1704.  
  1705.   NOTE: There exists a wide variety of alternative shells from third
  1706.   parties that do not have this restriction.  If you are using a shell
  1707.   that accepts forward slash as a directory separator, you can stop
  1708.   reading right now -- UNLESS (there is always an "unless") you want your
  1709.   scripts to be portable to systems that have other shells.  Also note
  1710.   that some Windows shells might actually REQUIRE forward slashes
  1711.   (instead of backslashes) as directory separators; we do not treat this
  1712.   situation below, but the treatment is obvious -- use slash rather
  1713.   backslash as the directory separator.
  1714.  
  1715. 1.11.3. Passing DOS Filenames from Kermit to Shell Commands
  1716.  
  1717. The following Kermit commands invoke the system command shell:
  1718.  
  1719.   RUN (and its synonyms ! and @)
  1720.   REDIRECT
  1721.   PIPE
  1722.  
  1723. Each of these commands takes a shell command as an operand.  These shell
  1724. commands are not, and can not be, parsed by Kermit since Kermit does not know
  1725. the syntax of shell commands, and so can't tell the difference between a
  1726. keyword, a filename, a variable, a switch, or other item.  Therefore the rules
  1727. can not be bent since Kermit doesn't know where or how to bend them.  To
  1728. illustrate (using the regular Windows shell):
  1729.  
  1730.   run c:\\windows\\command\\chkdsk.exe
  1731.  
  1732. works OK, but:
  1733.  
  1734.   run c:/windows/command/chkdsk.exe
  1735.  
  1736. is not accepted by COMMAND.COM.  But:
  1737.  
  1738.   run c:\windows\command\chkdsk.exe
  1739.  
  1740. results in Kermit applying its quoting rules before sending the text to the
  1741. shell.  Since "w" and "c" are not in the list of backslash-item codes, the
  1742. backslash means "take the following character literally".  Thus, by the
  1743. time this filename gets to the Windows shell, it has become:
  1744.  
  1745.   c:windowscommandchkdsk.exe
  1746.  
  1747. which is probably not what you wanted.  (If "w" and "c" were in the list,
  1748. the results could be even stranger.)  Even more confusing is the case where
  1749. a directory or filename starts with one or more digits:
  1750.  
  1751.   run c:\123\lotus.exe
  1752.  
  1753. in which "\123" is the Kermit notation for ASCII character 123, which happens
  1754. to be left brace ({), resulting in "c:{lotus.exe".
  1755.  
  1756. So when passing filenames to a Windows shell, always use double backslashes as
  1757. directory separators, to ensure that the shell gets single backslashes:
  1758.  
  1759.   run c:\\windows\\command\\chkdsk.exe
  1760.   run c:\\123\\lotus.exe
  1761.  
  1762. Similar problems might occur with the built-in EDIT, BROWSE, and FTP commands.
  1763. These commands result in Kermit building a shell command internally to invoke
  1764. the associated helper program; the form of this command might conflict with
  1765. the form demanded by certain alternative shells.
  1766.  
  1767. 1.11.4. Using Variables to Hold DOS Filenames
  1768.  
  1769. Now to the next level.  Suppose you want to write a script in which filenames
  1770. are parameters, and therefore are stored in variables.  Example:
  1771.  
  1772.   define \%f c:\windows\command\chkdsk.exe
  1773.   ...
  1774.   run \%f
  1775.  
  1776. Obviously this won't work for the reasons just noted; the RUN command requires
  1777. directory separators be coded as double backslashes:
  1778.  
  1779.   define \%f c:\\windows\\command\\chkdsk.exe
  1780.   ...
  1781.   run \%f
  1782.  
  1783. This will work; no surprises here.  However, if you had used ASSIGN rather
  1784. than DEFINE, you might have been surprised after all; review pages 348-349 of
  1785. "Using C-Kermit" (2nd Ed) for the difference between DEFINE and ASSIGN.
  1786.  
  1787. We have said that any Kermit 95 or MS-DOS Kermit command that parses filenames
  1788. itself -- SEND, for example -- does not require double backslashes since it
  1789. knows it is parsing a filename.  So since the following works:
  1790.  
  1791.   send c:\windows\command\chkdsk.exe
  1792.  
  1793. Should the following also work?
  1794.  
  1795.   define \%f c:\windows\command\chkdsk.exe
  1796.   ...
  1797.   send \%f
  1798.  
  1799. Answer: No.  Why?  Because \%f is evaluated "recursively", to allow for the
  1800. possibility that its definition contains further variable references.  This is
  1801. true of all "backslash-percent-letter" (or -digit) variables, and also for
  1802. array references.  So \%f becomes c:\windows\command\chkdsk.exe, which
  1803. becomes c:windowscommandchkdsk.exe.
  1804.  
  1805. The trick here is to use the "other" kind of variable, that is evaluated
  1806. only "one level deep" rather than recursively:
  1807.  
  1808.   define filename c:\windows\command\chkdsk.exe
  1809.   ...
  1810.   send \m(filename)
  1811.  
  1812. Similarly if you want to prompt the user for a filename:
  1813.  
  1814.   ask filename { Please type a filename: }
  1815.    Please type a filename: c:\windows\command\chkdsk.exe
  1816.   send \m(filename)
  1817.  
  1818. 1.11.5. Passing DOS Filenames as Parameters to Macros
  1819.  
  1820. Suppose you want to pass a DOS filename containing backslashes as a parameter
  1821. to a Kermit macro.  This raises two issues:
  1822.  
  1823.  1. Parameters to macros are "just text" and so are fully evaluated before
  1824.     they are passed to the macro.
  1825.  
  1826.  2. Once inside the macro, the formal parameters \%1, \%2, ... \%9 are the
  1827.     type of variable that is evaluated recursively.
  1828.  
  1829. Thus a DOS filename is ruined once in the act of parsing the macro invocation,
  1830. and again when referring to it from within the macro.  To illustrate, suppose
  1831. "test" is a macro.  Then in the invocation:
  1832.  
  1833.   test c:\mydir\blah.txt
  1834.  
  1835. "c:mydirblah.txt" is assigned to \%1.  However, if we double the backslashes:
  1836.  
  1837.   test c:\\mydir\\blah.txt
  1838.  
  1839. "c:\mydir\blah.txt" is assigned to \%1.  But then when you refer to \%1 in
  1840. the macro, it is evaluated recursively, resulting in "c:mydirblah.txt".
  1841. To illustrate:
  1842.  
  1843.   define test echo \%1
  1844.   test c:\mydir\blah.txt
  1845.   c:mydirblah.txt
  1846.   test c:\\mydir\\blah.txt
  1847.   c:mydirblah.txt
  1848.   test c:\\\\mydir\\\\blah.txt
  1849.   c:\mydir\blah.txt
  1850.  
  1851. Let's address each part of the problem separately.  First, inside the macro.
  1852. You can use the \fcontents() function to force a backslash-percent variable
  1853. (such as a macro argument) to be evaluated one level deep instead of
  1854. recursively, for example:
  1855.  
  1856.   define test echo { The filename is "\fcontents(\%1)"}
  1857.  
  1858.   test c:\mydir\blah.txt               ; We don't expect this to work
  1859.    The filename is "c:mydirblah.txt"   ; and it doesn't.
  1860.   test c:\\mydir\\blah.txt             ; But this does...
  1861.    The filename is "c:\mydir\blah.txt"
  1862.  
  1863. Thus if the filename arrives inside the macro with single backslashes, the
  1864. backslashes are preserved if you always refer to the parameter through the
  1865. \fcontents() function.
  1866.  
  1867. Now how to ensure that backslashes are not stripped or misinterpreted when
  1868. passing a filename to a macro?  This brings us back to what we learned in
  1869. earlier sections:
  1870.  
  1871.  1. If it is a literal filename, either double the backslashes, or (if the
  1872.     filename is to be used only within Kermit itself and not passed to a
  1873.     DOS shell, or it is to be passed to an alternative shell that accepts
  1874.     forward slash as a directory separator), use forward slash instead of
  1875.     backslash as the directory separator.
  1876.  
  1877.  2. If it is a variable that contains a filename, make sure you use a
  1878.     macro-style variable name, rather than a backslash-percent-character
  1879.     name.
  1880.  
  1881. Examples:
  1882.  
  1883.   define test echo \fcontents(\%1)
  1884.   define filename c:\mydir\blah.txt
  1885.  
  1886.   test c:\\mydir\\blah.txt  ; Literal filename with double backslashes
  1887.   c:\mydir\blah.txt
  1888.  
  1889.   test c:/mydir/blah.txt    ; Literal filename with forward slashes
  1890.   c:/mydir/blah.txt
  1891.  
  1892.   test \m(filename)         ; Variable
  1893.   c:\mydir\blah.txt
  1894.  
  1895. But what if you don't like these rules and you still want to pass a literal
  1896. filename containing single backslashes to a macro?  This is possible too, but
  1897. a bit tricky: turn command quoting off before invoking the macro, and then
  1898. turn it back on inside the macro.  Example:
  1899.  
  1900.   define test set command quoting on, echo \fcontents(\%1)
  1901.  
  1902.   set command quoting off
  1903.   test c:\mydir\blah.txt
  1904.   c:\mydir\blah.txt
  1905.  
  1906. Upon return from the macro, command quoting is back on (since the macro
  1907. turned it on).
  1908.  
  1909. Obviously this trick can not be used if the filename is stored in a variable,
  1910. since it prevents the variable from being evaluated.
  1911.  
  1912. 1.11.6. Passing DOS File Names from Macro Parameters to the DOS Shell
  1913.  
  1914. Now suppose you need to pass a DOS filename to a macro, and the macro needs
  1915. to pass it, in turn, to the Windows shell via (say) Kermit's RUN command.
  1916. This works too:
  1917.  
  1918.   define xrun run \fcontents(\%1)
  1919.   xrun c:\\windows\\command\\chkdsk.exe
  1920.  
  1921. (or you can use the SET COMMAND QUOTING OFF / ON technique described above
  1922. to avoid the double backslashes.)  But..
  1923.  
  1924.   xrun c:/windows/command/chkdsk.exe
  1925.  
  1926. does not work if the Windows shell does not recognize "/" as a directory
  1927. separator.  If there is a chance that a filename might be passed to the macro
  1928. in this form, the macro will need to convert it to a form acceptable to the
  1929. shell:
  1930.  
  1931.   define xrun run \freplace(\fcontents(\%1),/,\\)
  1932.  
  1933. Here we replace all occurrences (if any) of "/" in the argument with "\" prior
  1934. to issuing the RUN command.  Of course, in order to specify "\" as a literal
  1935. character in the \freplace() argument list, we have to double it.
  1936.  
  1937. 1.11.7. Passing DOS Filenames to Kermit from the Shell
  1938.  
  1939. As noted in the manual, the \&@[] array contains Kermit's command-line
  1940. arguments.  Suppose one of these arguments, say \&@[3], is a DOS filename
  1941. such as C:\FOO\BAR\BAZ\OOFA.TXT.  (Note: In C-Kermit 7.0 and K95 1.1.18
  1942. and later, command-line arguments after "=" or "--" are also available in
  1943. the top-level \%1..9 variables; see Section 7.5.)
  1944.  
  1945. Of course you can eliminate any problems by using forward slashes rather
  1946. than backlashes in the filename, but sometimes this is not possible, as when
  1947. the Kermit command line is being generated by another program than can only
  1948. generate "native" format DOS filenames.
  1949.  
  1950. As noted in the manual, "\%x" variables and \&x[] arrays are always evaluated
  1951. "all the way" (recursively).  If the contents of one of these variables
  1952. contains backslashes, this causes another level of evaluation.
  1953.  
  1954. There is another kind of variable, which is evaluated only "one level deep".
  1955. You can use this to prevent interpretation of the backslashes in the
  1956. filenames.
  1957.  
  1958. Example:
  1959.  
  1960.   assign filename \fcontents(\&@[3])  ; Transfer contents
  1961.   ...
  1962.   send \m(filename)
  1963.  
  1964. Or, more simply:
  1965.  
  1966.   send \fcontents(\&@[3])
  1967.  
  1968. 1.12. Debugging
  1969.  
  1970. The debug log is produced when you give a "log debug" command.  This is
  1971. normally done at the request of the Kermit help desk, for forwarding to the
  1972. Kermit developers for analysis as a last resort in troubleshooting problems.
  1973. (Last resort because it can grow quite huge in a very short time.)  In cases
  1974. where timing information is critical to understanding a problem, you can
  1975. tell C-Kermit to put a timestamp on each debug log line by giving the command:
  1976.  
  1977.   SET DEBUG TIMESTAMP ON
  1978.  
  1979. At any time before or after activating the debug log (SET DEBUG TIMESTAMP OFF
  1980. turns off timestamping).  Timestamps can be turned off and on as desired while
  1981. logging.  Obviously, they increase the size and growth rate of the log
  1982. significantly, and so should be used sparingly.  Timestamps are of the form
  1983. hh:mm:ss.xxx, where .xxx is thousands of a second (but is included only on
  1984. platforms that include this feature).
  1985.  
  1986. 1.13. Logs
  1987.  
  1988. In UNIX C-Kermit and in K-95, you can now direct any log to a pipe.  This
  1989. not only lets you send your logs to places other than disk files, but also
  1990. lets you customize them to any desired degree.
  1991.  
  1992. LOG { DEBUG, PACKETS, SESSION, TRANSACTION, CONNECTION } { file, pipe } ...
  1993.   A "pipe" is the name of a command, preceded by a vertical bar.  If the
  1994.   pipe contains any spaces, it must be enclosed in braces.
  1995.  
  1996. Here are some examples for UNIX (always remember the importance of getting
  1997. the UNIX shell quoting rules right):
  1998.  
  1999. LOG TRANSACTIONS |lpr
  2000.   This sends the transaction log to the default UNIX printer, rather than
  2001.   to a file (use "lp" rather than "lpr" if necessary).
  2002.  
  2003. LOG TRANSACTIONS {| myfilter > t.log}
  2004.   For those who don't like the format of the transaction log, or want to
  2005.   extract certain information from it; write your own output filter.
  2006.  
  2007. LOG SESSION {| lpr -Plaserwriter}
  2008.   This sends the session log to a specific UNIX printer, rather than to a
  2009.   file.  Note the braces around the pipeline.  These are required because
  2010.   it contains spaces.
  2011.  
  2012. LOG DEBUG {| tail -100 > debug.log}
  2013.   This causes the debug log file to contain only the final 100 lines.
  2014.   Suppose C-Kermit crashes under some unpredictable circumstances, and
  2015.   you need a debug log to catch it in the act.  But the debug log can grow
  2016.   to huge proportions very quickly, possibly filling up the disk.  Piping
  2017.   the debug log through "tail" results in keeping only the last 100 lines
  2018.   (or other number of your choice).
  2019.  
  2020. LOG DEBUG {| grep "^TELNET" > debug.log}
  2021.   This one shows how to log only Telnet negotiations.  Piping the debug log
  2022.   through grep or egrep lets you log only specific information, rather than
  2023.   everything.  "man grep" for further info.
  2024.  
  2025. LOG DEBUG {| gzip -c > debug.log.gz}
  2026.   Creates a full debug log, but compressed by gzip to save space.
  2027.  
  2028. LOG PACKETS {| tr "\\01" "X" | cut -c9- > packet.log}
  2029.   This one writes the regular packet log, but translates the Ctrl-A that
  2030.   starts each packet to the letter "X" and removes the s-nn-nn- notation
  2031.   from the beginning of each line.  Note the double backslash (normal Kermit
  2032.   quoting rules).  "man tr" and "man cut" for further info.
  2033.  
  2034. See Section 2.12 for information about the new connection log.
  2035.  
  2036. 1.14. Automatic File-Transfer Packet Recognition at the Command Prompt
  2037.  
  2038. Beginning in version 7.0, C-Kermit can recognize Kermit (and in some cases
  2039. also Zmodem) file-transfer packets while at its command prompt.  This is
  2040. convenient (for example), if you escaped back from a remote Kermit program
  2041. and told the local Kermit program to send a file, but forgot to tell the
  2042. remote Kermit program to receive it (and the local Kermit did not have the
  2043. "send a Kermit receive command" feature available).  This feature is
  2044. controlled by the following command:
  2045.  
  2046. SET COMMAND AUTODOWNLOAD { ON, OFF }
  2047.   When ON, which is the default, the command parser recognizes Kermit
  2048.   packets when Kermit is in remote mode.  An S packet makes it go into
  2049.   receive mode, an I packet makes it go into server mode.  When OFF, packet
  2050.   recognition is disabled and the behavior when a packet is received at the
  2051.   command prompt is as it was in C-Kermit 6.1 and earlier (namely to print
  2052.   an error message).
  2053.  
  2054. COMMAND AUTODOWNLOAD is the command-mode equivalent of TERMINAL AUTODOWNLOAD,
  2055. which is effective during CONNECT mode.
  2056.  
  2057. 1.15. The TYPE Command
  2058.  
  2059. The TYPE command now accepts a selection of optional switches (Section 1.5),
  2060. and also sets several variables.
  2061.  
  2062. Syntax: TYPE [ switches... ] filename
  2063.  
  2064. Variables:
  2065.  
  2066.   \v(ty_ln)  Line number of current line (during TYPE command; see /PREFIX)
  2067.   \v(ty_lc)  Line count of file most recently TYPEd.
  2068.   \v(ty_mc)  Match count of file most recently TYPEd (see /MATCH).
  2069.  
  2070. Switches:
  2071.  
  2072. /PAGE
  2073.   If /PAGE is included, Kermit pauses at the end of each screenful and issues
  2074.   a "more?" prompt.  You may press the space bar to view the next page
  2075.   (screenful), or press "q" or "n" to return to the C-Kermit prompt.  If this
  2076.   switch is given, it overrides the COMMAND MORE-PROMPTING setting for this
  2077.   command only.  If it is not given, paging is according to COMMAND
  2078.   MORE-PROMPTING.
  2079.  
  2080. /NOPAGE
  2081.   Do not pause at the end of each screenful; show the whole file (or all
  2082.   selected lines) at once.  If this switch is given, it overrides the COMMAND
  2083.   MORE-PROMPTING setting for this command only.  If it is not given, paging is
  2084.   according to COMMAND MORE-PROMPTING.
  2085.  
  2086. /HEAD[:n]
  2087.   Only show the first "n" lines of the file (where n is a number).
  2088.   If n is omitted, 10 is used.
  2089.  
  2090. /TAIL[:n]
  2091.   Only show the last "n" lines of the file (where n is a number).  If n is
  2092.   omitted, 10 is used.  Note: /HEAD and /TAIL can't be combined; if you give
  2093.   both switches, only the most recent one is used.
  2094.  
  2095. /MATCH:pattern
  2096.   Only type lines from the file that match the given pattern (see Section
  2097.   4.9.1 for pattern notation).  UNIX users familiar with grep should note
  2098.   a significant difference: there is no implied "*" at the beginning and end
  2099.   of the pattern.  Thus:
  2100.  
  2101.     TYPE /MATCH:foo    Lists lines whose entire contents are "foo".
  2102.     TYPE /MATCH:foo*   Lists lines that start with "foo".
  2103.     TYPE /MATCH:*foo   Lists lines that end with "foo".
  2104.     TYPE /MATCH:*foo*  Lists lines that have "foo" anywhere in them.
  2105.  
  2106.   /HEAD and /TAIL apply after /MATCH, so "type /tail:20 /match:x*" shows the
  2107.   last 20 lines in the file that start with "x".
  2108.  
  2109. /PREFIX:string
  2110.   Print the given string at the beginning of each line.  The string may be a
  2111.   constant, a variable, or a quoted variable.  If it's an unquoted variable,
  2112.   its value at the time the TYPE command was given is used as a constant.
  2113.   If it is a quoted variable, it is re-evaluated for each line; a useful
  2114.   variable for this context is \v(ty_ln) (the line number of the current line
  2115.   being typed).  If the prefix is to include spaces, it must be enclosed in
  2116.   braces.  Examples:
  2117.  
  2118.   type /prefix:{oofa.txt: } /match:*thing* oofa.txt
  2119.     Prints all lines in oofa.txt that contain "thing" with the filename
  2120.     itself as the prefix (similar to UNIX grep).
  2121.  
  2122.   type /prefix:{\v(time). } oofa.txt
  2123.     Prefixes each line of oofa.txt with the time at which the TYPE command
  2124.     was given (one backslash)
  2125.  
  2126.   type /prefix:{\\v(time). } oofa.txt
  2127.     Prefixes each line of oofa.txt with the time at which that line is
  2128.     being typed (two backslashes).
  2129.  
  2130.   type /prefix:{\\v(ty_ln). } oofa.txt
  2131.     Prefixes each line of oofa.txt with its line number.
  2132.  
  2133.   type /prefix:{\\flpad(\\v(ty_ln),4). } oofa.txt
  2134.     Same as the previous example, except the line number is right-adjusted
  2135.     in a 4-column field.
  2136.  
  2137. /WIDTH[:n]
  2138.   Truncates each line at column "n" (which must be a number) prior to printing
  2139.   it.  This option can be used for long lines when you don't want them to wrap.
  2140.   If n is omitted, your current screen width is used.
  2141.  
  2142. /COUNT
  2143.   Counts lines and -- if /MATCH was included, matches -- but does not print
  2144.   any lines from the file.  The line and match count is shown at the end,
  2145.   and the variables \v(ty_lc) and \v(ty_lm) are set accordingly.
  2146.  
  2147. SET OPTIONS TYPE { /PAGE, /NOPAGE, /WIDTH:n }
  2148.   Sets the paging default for TYPE commands, which can be overridden in any
  2149.   particular TYPE command by including the desired switch.
  2150.  
  2151. If a TYPE command is given with no switch, and no SET OPTIONS TYPE selection
  2152. is in effect, paging is according to your COMMAND MORE-PROMPTING setting
  2153. (SHOW COMMAND).
  2154.  
  2155. 1.16. The RESET Command
  2156.  
  2157. The RESET command, added in 7.0, closes all open files and logs, but does not
  2158. affect the open connection (if any).
  2159.  
  2160. 1.17. The COPY and RENAME Commands
  2161.  
  2162. As of C-Kermit 7.0, in the UNIX version only, the COPY and RENAME commands are
  2163. built in and do not call the underlying platform's COPY or RENAME command.
  2164. This allows them to work in "NOPUSH" versions and other circumstances where it
  2165. can't access system commands, and it allows file copying and renaming to be
  2166. done portably in scripts.  The characteristics of the built-in COPY or RENAME
  2167. include:
  2168.  
  2169.  . It fails if the source file is a directory or is wild or lacks read access.
  2170.  . It fails if the source file is the destination file.
  2171.  . It allows the destination file to be a directory, in which case the source
  2172.    file is copied (or renamed) into it with the same name.
  2173.  . It overwrites an existing destination file if its permission allows.
  2174.  . It sets the new file's permission according to umask but also carries
  2175.    forward the source file's execute permission bits if the destination file
  2176.    did not already exist.
  2177.  . It fails if interrupted by Ctrl-C.
  2178.  . Upon error, it prints an appropriate message.
  2179.  . It returns standardized error codes that can be tested by IF SUCCESS / FAIL.
  2180.  
  2181. These commands now also accept the following switches:
  2182.  
  2183.   /LIST (/LOG, /VERBOSE)    = Print "file1 => file2 (OK)" (or error message).
  2184.   /NOLIST (/NOLOG, /QUIET)  = Don't print anything (except error messages).
  2185.  
  2186. /NOLIST is the default.
  2187.  
  2188. The same built-in code is used by the UNIX C-Kermit server to execute REMOTE
  2189. COPY commands (except in this case no switches are available).
  2190.  
  2191. The COPY command also accepts the following additional switches.  When any of
  2192. these are given (and they can be used in any combination except /SWAP and
  2193. /APPEND), some of the checks listed above are relaxed, and thus it might be
  2194. possible to get into trouble in certain cases, e.g. when the source and target
  2195. files are the same file:
  2196.  
  2197.   /APPEND                   = Append source file to destination file.
  2198.   /SWAP-BYTES               = Swap bytes (see Section 6.6.5).
  2199.   /FROMB64                  = Decode the source file from Base64 encoding.
  2200.   /TOB64                    = Encode the target file in Base64.
  2201.  
  2202. Base64 is the encoding commonly used for enclosures in Internet email.
  2203.  
  2204. 1.18. The MANUAL Command
  2205.  
  2206. The MANUAL command can be used to access the appropriate Kermit manual or
  2207. other manual.  The general syntax is:
  2208.  
  2209. MANUAL [ string ]
  2210.   If the string is omitted, C-Kermit asks the underlying system to access the
  2211.   C-Kermit manual using whatever method is appropriate for the system.
  2212.  
  2213. The specific action depends on the system.  In UNIX, a "man" command is
  2214. issued; "kermit" is the default argument but other manual topics may be
  2215. specified.  If the "man" command allows index or string searching, the
  2216. appropriate syntax may be included.
  2217.  
  2218. In Kermit 95, the MANUAL command brings up the HTML online K95 manual.
  2219.  
  2220. In VMS and elsewhere, "man" is simply translated to "help", with a default
  2221. argument of "kermit"; other and/or additional arguments may be included
  2222. according to the definition of the system's "help" command.
  2223.  
  2224. Correct operation of the "man" command in C-Kermit depends on the appropriate
  2225. man page or help topic having been installed in the right place with the
  2226. right permissions and format.
  2227.  
  2228. 1.19. String and Filename Matching Patterns
  2229.  
  2230. A pattern is a string that includes special notation for matching classes or
  2231. sequences of characters.  C-Kermit 7.0 / K95 1.1.18 supports patterns in
  2232. several places:
  2233.  
  2234.  . Filenames (Section 4.9)
  2235.  . SWITCH case labels (Section 7.18)
  2236.  . The new IF MATCH statement (Section 7.4)
  2237.  . TYPE /MATCH (Section 1.15)
  2238.  . SET FILE TEXT-PATTERNS and BINARY-PATTERNS (Section 4.3)
  2239.  . The \fsearch() and \farraylook() functions (Sections 7.3 and 7.10.7)
  2240.  . The \fpattern() function used with [M,RE]INPUT (Section 7.1)
  2241.  
  2242. Patterns are also called wildcards, especially when used for filename
  2243. matching.  C-Kermit's pattern syntax is explained in Section 4.9.1, and also
  2244. by the HELP WILDCARDS command.
  2245.  
  2246. 1.20. Multiple Commands on One Line
  2247.  
  2248. As of C-Kermit 7.0, commands can be grouped together on one line by separating
  2249. the commands with commas and enclosing the list in braces.  For example:
  2250.  
  2251.   { echo One, echo Two, echo Three }
  2252.  
  2253. or:
  2254.  
  2255.   do { echo One, echo Two, echo Three }
  2256.  
  2257. Command lists can be nested:
  2258.  
  2259.   [ do ] { echo One, echo Two, if true { echo A, echo B}, echo Three }
  2260.  
  2261. and the END command works as it does in macros:
  2262.  
  2263.   [ do ] { echo One, echo Two, if true end, echo Three }
  2264.  
  2265. The "one line" stricture is, of course, pliant to line-continuation
  2266. conventions, namely that lines ending in hyphen (-) or left brace ({) are
  2267. to be continued.  Thus the first example can also be rendered:
  2268.  
  2269.   [ do ] {
  2270.       echo One
  2271.       echo Two
  2272.       echo Three
  2273.   }
  2274.  
  2275. (the "do" is optional).
  2276.  
  2277. 1.21. What Do I Have?
  2278.  
  2279. C-Kermit can be built for hundreds of different platforms with practically
  2280. countless configuration options.  Certain commands might not be available in
  2281. certain configurations, etc.  Even on the same platform, different builds are
  2282. possible: "maximum functionality", "minimum size", "maximum performance", and
  2283. so on.  You can find out a lot about the configuration of your C-Kermit
  2284. program with the SHOW FEATURES command.  Of course, a lot of what it says,
  2285. especially in the bottom part, might seem like gibberish, but can be
  2286. deciphered with a Rosetta Stone (such as the C-Kermit source or the ckccfg.txt
  2287. file).  In any case, the output from SHOW FEATURES might easily explain why
  2288. some expected feature is missing, or some buffer is smaller than expected.
  2289. Here's a sample of the bottom section for the SunOS version:
  2290.  
  2291. C-Kermit 7.0.196, 1 Jan 2000
  2292.  
  2293. Major optional features included:
  2294.  Network support (type SHOW NET for further info)
  2295.  Telnet Kermit Option
  2296.  Hardware flow control
  2297.  External XYZMODEM protocol support
  2298.  Latin-1 (West European) character-set translation
  2299.  Latin-2 (East European) character-set translation
  2300.  Cyrillic (Russian, Ukrainian, etc) character-set translation
  2301.  Greek character-set translation
  2302.  Hebrew character-set translation
  2303.  Japanese character-set translation
  2304.  Unicode character-set translation
  2305.  Pseudoterminal control
  2306.  REDIRECT command
  2307.  RESEND command
  2308.  Fullscreen file transfer display
  2309.  Control-character unprefixing
  2310.  Streaming
  2311.  Autodownload
  2312.  
  2313. Major optional features not included:
  2314.  No Kerberos(TM) authentication
  2315.  No SRP(TM) (Secure Remote Password) protocol
  2316.  No Secure Sockets Layer (SSL) protocol
  2317.  No Transport Layer Security (TLS) protocol
  2318.  No encryption
  2319.  No X Windows forwarding
  2320.  
  2321. Host info:
  2322.  Machine:    sun4m
  2323.  Model:      (unknown)
  2324.  OS:         SunOS
  2325.  OS Release: 4.1.3_U1
  2326.  OS Version: 4
  2327.  
  2328. Target: sunos41gsc
  2329. GCC version: 2.7.2
  2330. Compiled Dec 31 1999 10:38:54, options:
  2331.  __GNUC__ __STDC__ _POSIX_JOB_CONTROL _SC_JOB_CONTROL ARRAYREFLEN=1024 BIGBUFOK
  2332.  BROWSER BSD4 CK_ANSIC CK_APC CK_AUTODL CK_CURSES CK_DNS_SRV CK_ENVIRONMENT
  2333.  CK_FAST CK_LOGIN CK_MKDIR CK_NAWS CK_PCT_BAR CK_PERMS CK_RECALL CK_RTSCTS
  2334.  CK_SPEED CK_TIMERS CK_TMPDIR CK_TTGWSIZ CK_TTYFD CK_WREFRESH CKEXEC
  2335.  CKFLOAT=double CKGHNLHOST ckmaxfiles=64 CKMAXOPEN=64 CKMAXPATH=1023 CKREALPATH
  2336.  CKREGEX CKSYSLOG CKTUNING CMDBL=32763 CMDDEP=64 CONGSPD DCMDBUF DIRENT DYNAMIC
  2337.  FNFLOAT FORDEPTH=32 GFTIMER HADDRLIST HDBUUCP IFDEBUG IKS_OPTION IKSDB
  2338.  IKSDCONF INBUFSIZE=32768 INPBUFSIZ=4096 MAC_MAX=16384 MACLEVEL=128 MAXDDIR=32
  2339.  MAXDNUMS=4095 MAXGETPATH=128 MAXTAKE=54 MAXWLD=102400 MSENDMAX=1024 NETCMD
  2340.  NETCONN NETPTY NOKVERBS NOSETBUF OBUFSIZE=32768 PARSENSE PATTERNS PIPESEND
  2341.  RENAME RLOGCODE SAVEDUID SELECT SIG_V SOL_SOCKET sparc STREAMING sun SUNOS4
  2342.  SYSTIMEH TCPSOCKET TIMEH TLOG TNCODE TTLEBUF TTSPDLIST UIDBUFLEN=256 UNIX
  2343.  UNPREFIXZERO USE_LSTAT USE_MEMCPY VNAML=4096 WHATAMI XFRCAN Z_MAXCHAN=46
  2344.  z_maxchan=46 ZXREWIND
  2345.  
  2346.  byte order: big endian
  2347.  
  2348.  sizeofs: int=4 long=4 short=2 char=1 char*=4 float=4 double=8
  2349.  
  2350.  floating-point: precision=16 rounding=1
  2351.  
  2352. Without going into detail about what all the notation means, notice a couple
  2353. things:
  2354.  
  2355.  . The Options section shows symbols ("macros") in effect during compilation,
  2356.    together with their values (for those that have values).  The options are
  2357.    listed in alphabetical order to make any particular option easier to find.
  2358.  
  2359.  . MAXWLD is the maximum number of files that a wildcard can expand to.
  2360.  
  2361.  . Anything starting with "NO" is a feature (or something other than a
  2362.    feature) that has been deliberately "compiled out", or omitted.
  2363.  
  2364.  . Important items for script writers include: CMDBL=32763 (the size of the
  2365.    command buffer and therefore the maximum length for a macro or variable
  2366.    definition; CMDDEP=64 (the limit on recursion depth); FORDEPTH=32 (the
  2367.    nesting limit on FOR loops); INBUFSIZE=32768 (the size of the INPUT command
  2368.    circular buffer); MAC_MAX=16384 (the maximum number of macros), etc.
  2369.  
  2370. See the ckccfg.txt file for details.
  2371.  
  2372. 1.22. Generalized File Input and Output
  2373.  
  2374. C-Kermit 7.0 adds a new generalized I/O system for stream files, augmenting
  2375. (and to some extent, overlapping with) the older OPEN, READ, WRITE, and CLOSE
  2376. commands.  In the new file i/o system, which can be used simultaneously with
  2377. the old one, all commands are grouped together under the new FILE keyword,
  2378. and some related functions and variables are added.
  2379.  
  2380. 1.22.1. Why Another I/O System?
  2381.  
  2382. The well-known LOG, OPEN, READ, WRITE, and CLOSE commands have the following
  2383. restrictions:
  2384.  
  2385.  a. Only one READ file and one WRITE file can be open at a time.
  2386.  b. The READ and WRITE commands are strictly line oriented.
  2387.  c. These commands can not be used with binary files.
  2388.  d. They do not support read/write access or random access.
  2389.  e. The syntax is a bit counterintuitive for programmers.
  2390.  
  2391. The new file i/o system allows multiple files to be open at once, in any
  2392. desired combination of modes (read/write/append) supported by the operating
  2393. system, for line, block (record), or character i/o, for sequential or random
  2394. access, using consistent syntax and conventions.
  2395.  
  2396. The new system, however, does not replace the old one, since the old system
  2397. still must be used for:
  2398.  
  2399.  a. The session, packet, debug, transaction, and connection logs.
  2400.  b. Reading and writing commands rather than files.
  2401.  c. Existing scripts.
  2402.  
  2403. The new system works only with regular files, not with commands or pipes or
  2404. mailboxes or pseudoterminals.  No special provisions are made in the FILE
  2405. commands for handling devices or network connections, nor for preventing you
  2406. from trying to open them; if the underlying operating system treats them
  2407. like regular stream disk files, the FILE commands (except, of course SEEK,
  2408. REWIND, and COUNT) might work with them.  (In C programming terms, the FILE
  2409. commands are, at present, nothing more than a front end to fopen() / fread()
  2410. / fwrite() / fclose() and friends, which are a portable API to sequential
  2411. files, but this might change in the future for platforms like VMS and VOS
  2412. that have more complicated file systems.)
  2413.  
  2414. Definitions:
  2415.  
  2416. Channel
  2417.   A number assigned to a file when it is opened, by which it must be referred
  2418.   to in all input/output operations.
  2419.  
  2420. Read/Write Pointer
  2421.   The current position in an open file, expressed as the 0-based byte count
  2422.   from the beginning.
  2423.  
  2424. 1.22.2. The FILE Command
  2425.  
  2426. The FILE command has the following syntax:
  2427.  
  2428.   FILE <keyword> [ <switches> ] <channel> [ <data> ]
  2429.  
  2430. The <keyword> specifies the function: FILE OPEN, FILE READ, FILE WRITE, FILE
  2431. CLOSE, etc.  For convenience (and for familiarity to C programmers), the
  2432. two-word FILE commands can be shortened to the single words FOPEN, FREAD,
  2433. FWRITE, FCLOSE, and so on.  Switches are optional, and modify or amplify the
  2434. requested file function.
  2435.  
  2436. As in C, Fortran, and other programming languages, open files are referred to
  2437. by "channels", integers such as 0, 1, 2, 3, and so on.  A channel number is
  2438. assigned when you open a file.  The number of available channels depends on
  2439. the underlying operating system, and can be seen in the variable:
  2440.  
  2441.   \v(f_max)
  2442.  
  2443. or by giving the FILE LIST (FLIST) command.  Channels are discussed in
  2444. greater detail in Section 1.22.4.
  2445.  
  2446. FILE command errors can be caught with IF FAIL after the FILE command.  In
  2447. addition, the \v(f_error) variable is set to the completion code of the
  2448. command: 0 if no error, or a negative number if there was an error.  The error
  2449. codes are listed in Section 1.22.5.
  2450.  
  2451. The command to open a file is:
  2452.  
  2453. FILE OPEN [ switches ] <variable> <filename>
  2454.   Opens a file for the type of access specified by the switches, or for
  2455.   read-only access if no switches are given.  Upon success, a channel number
  2456.   is assigned to this file and stored in the given variable so you can refer
  2457.   to the open file in subsequent i/o commands.  If the file can not be opened,
  2458.   the FILE OPEN command fails.  Synonym: FOPEN.
  2459.  
  2460. The FILE OPEN switches are:
  2461.  
  2462. /READ
  2463.   Open the file for read access.  If no switches are given, /READ is assumed.
  2464.   If the file does not exist or can't be opened for read access, the FILE OPEN
  2465.   command fails.
  2466.  
  2467. /WRITE
  2468.   Allow writing.  If a file of the same name already exists, it is
  2469.   overwritten unless /READ or /APPEND is also included.  If a file of the
  2470.   given name does not exist, it is created.
  2471.  
  2472. /APPEND
  2473.   Equivalent to /WRITE, except that if the file exists, it is not destroyed.
  2474.   The read/write pointer is set to the end of the file, so unless you change
  2475.   it with FILE SEEK or REWIND (see below), the first FILE WRITE command adds
  2476.   to the end of the file, preserving what was there already.  If /WRITE is
  2477.   also given, it is ignored.
  2478.  
  2479. /BINARY
  2480.   Open the file in "binary" mode, rather than text mode.  This switch is
  2481.   meaningless (but still can be used) in UNIX.  In VMS, Windows, and OS/2,
  2482.   it inhibits end-of-line processing and conversion, and so should be used
  2483.   for binary files and/or files that are to be accessed in record or
  2484.   character mode rather than line by line.
  2485.  
  2486. The variable for the channel number can be any kind of variable: the \%x kind,
  2487. a macro name, or an array element.  But it must be a variable, not a number --
  2488. C-Kermit assigns the channel number; you can't tell it what number to use.
  2489.  
  2490. Example:
  2491.  
  2492.   FILE OPEN \%c oofa.txt                  ; Open oofa.txt for reading.
  2493.   IF FAIL exit 1 Can't open oofa.txt      ; Always check to see if it worked.
  2494.   ECHO oofa.txt: channel = \%c
  2495.  
  2496. If the file oofa.txt is opened successfully, a channel number is assigned
  2497. to the variable \%c.  Here's another example using a macro name for the
  2498. channel number:
  2499.  
  2500.   FILE OPEN channel oofa.txt              ; Open oofa.txt for reading.
  2501.   IF SUCCESS ECHO oofa.txt: channel = \m(channel)
  2502.  
  2503. Switches can be combined when it makes sense and the underlying operating
  2504. system allows it.  For example, to open a file in binary mode for reading and
  2505. writing (sometimes called "update"):
  2506.  
  2507.   FILE OPEN /READ /WRITE /BINARY \%c budget.db
  2508.  
  2509. Some combinations might be allowed, others not.  For example /READ /APPEND
  2510. will usually not be allowed.  /WRITE /APPEND is treated as /APPEND.
  2511.  
  2512. A major advantage of the new system over the older one is that you can have
  2513. multiple files open at once.  Suppose, for example, that you want to open all
  2514. the files in a certain directory at once:
  2515.  
  2516.   .\%n := \ffiles(/usr/olga*,&f)          ; Get file list into array.
  2517.   if ( > \%n \v(f_max) ) {                ; Make sure there aren't too many.
  2518.       exit 1 {\v(dir): \%n = Too many files}
  2519.   }
  2520.   declare \&c[\%n]                        ; Make array for channel numbers.
  2521.   for \%i 1 \%n 1 {                       ; Loop to open every file...
  2522.       file open \&c[\%i] \&f[\%i]         ; Try to open this one
  2523.       if fail exit 1 Open error: \&f[\%i] ; Check for failure
  2524.   }
  2525.  
  2526. If this loop completes successfully, the \&c[] array will contain \%n
  2527. channel numbers of open files in elements 1 through \%n.
  2528.  
  2529. Any file that you open with FILE OPEN stays open until you close it.  The
  2530. command to close a file is:
  2531.  
  2532. FILE CLOSE { ALL, <channel> }
  2533.   If a channel number is given and the channel refers to an open file, the
  2534.   file is closed and the channel is freed for reuse; if the channel does not
  2535.   refer to an open file, an error message is printed and the command fails.
  2536.   If ALL is specified instead of a specific channel, all files opened with
  2537.   FILE OPEN are closed and if all open files were closed successfully (even
  2538.   if no files were open), the command succeeds; if any open file could not be
  2539.   closed, the command fails; however, all open files that could be closed are
  2540.   still closed.  Synonym: FCLOSE.
  2541.  
  2542. FILE CLOSE might fail because, for example, the disk filled up or a quota
  2543. was exceeded.
  2544.  
  2545. Example:
  2546.   fopen /write \%c new.txt                ; Open new.txt for writing.
  2547.   if fail exit 1                          ; Check for error.
  2548.   fclose \%c                              ; Close the file we just opened.
  2549.  
  2550. This creates a 0-length file called new.txt.
  2551.  
  2552. Note that FILE OPEN /WRITE (without /READ or /APPEND) always creates a new
  2553. file, and therefore destroys any file with the same name that might already
  2554. exist (assuming you have permission to delete it).  To avoid overwriting
  2555. existing files, simply check first:
  2556.  
  2557.   if exist new.txt exit 1 {Fatal - new.txt already exists}
  2558.   fopen /write \%c new.txt
  2559.   if fail ...
  2560.  
  2561. The next two commands give information about open files:
  2562.  
  2563. FILE STATUS <channel>
  2564.   Tells the name of the file, if any, open on the given channel and the
  2565.   switches it was opened with.  The read/write pointer is also shown; this is
  2566.   where the next read or write will occur; "[EOF]" is shown if the current
  2567.   position in the open file is the end -- i.e. the next read will fail if the
  2568.   file was opened in /READ mode; the next write will add material to the end.
  2569.   The current line number (0-based) is also shown if known.  The FILE STATUS
  2570.   command succeeds if the <channel> is open, and fails if there is no open
  2571.   file on the given channel, or if the channel number is invalid or out of
  2572.   range.  Synonym FSTATUS.
  2573.  
  2574. FILE LIST
  2575.   Lists the channel number and name of each open file, along with its OPEN
  2576.   modes (R, W, A, B, RW, etc) and its current read/write pointer or "[EOF]" if
  2577.   it is at the end.  Also tells the number of files currently opened with FILE
  2578.   OPEN, plus the maximum number of open files allowed by the system and the
  2579.   maximum number allowed for FILE OPEN.  Synonym: FLIST.
  2580.  
  2581. Next come the commands for reading and writing files:
  2582.  
  2583. FILE READ [ switches ] <channel> [ <variable> ]
  2584.   Reads data from the file on the given channel number into the <variable>,
  2585.   if one was given; if no variable was given, the result is printed on the
  2586.   screen.  IMPORTANT: The variable should normally be a macro name rather
  2587.   than a \%x or \&x[] variable if you want backslash characters in the file
  2588.   to be taken literally (see pp.408-412 of "Using C-Kermit" for an
  2589.   explanation; you can also read into a \%x or \&x[] variable, but then you
  2590.   must remember to protect future references to it by \fcontents() if you
  2591.   don't want C-Kermit to process any backslashes it might contain).  The
  2592.   desired amount of data (according to the switches) is read from the file at
  2593.   the current read/write pointer, and upon completion the read/write position
  2594.   is updated to first byte after the data that was read, no matter what
  2595.   switches were given.  Synonym: FREAD.
  2596.  
  2597. FILE WRITE [ switches ] <channel> <text>
  2598.   Writes the given text to the file on the given channel number.  The <text>,
  2599.   of course, can be literal text or a variable, or any combination.  If the
  2600.   text might contain leading or trailing spaces, it must be enclosed in braces
  2601.   if you want to preserve them.  Synonym: FWRITE.
  2602.  
  2603. Before proceeding, a caution about the NUL character.  C-Kermit is so named
  2604. because it is a Kermit program written in the C language.  In C, character
  2605. strings are represented as a sequence of non-NUL bytes terminated by a NUL
  2606. byte (a byte in which all bits are 0).  Thus a C string can not contain NUL
  2607. bytes; it always ends with the first NUL byte.  C-Kermit variables are
  2608. implemented as C strings and therefore can't contain NUL bytes either, so the
  2609. FILE READ and FILE WRITE commands do not handle files or strings that contain
  2610. NUL bytes, except when the /CHARACTER switch is included with the FILE READ or
  2611. WRITE command, or when /LPAD:0 or /RPAD:0 is given with the FILE WRITE command;
  2612. these switches are explained below.
  2613.  
  2614. Also note that Kermit can not be used read or write binary numbers in the
  2615. machine's internal format (integer or floating-point); in general, numbers can
  2616. be processed only when represented as numeric or floating-point strings.
  2617.  
  2618. FILE READ switches are:
  2619.  
  2620. /LINE
  2621.   Specifies that a line of text is to be read.  A line is defined according
  2622.   to the underlying operating system's text-file format.  For example, in
  2623.   UNIX a line is a sequence of characters up to and including a linefeed,
  2624.   or the end of the file, which ever comes first.  The line terminator (if
  2625.   any) is removed before assigning the text to the variable.  If no switches
  2626.   are included with the FILE READ command, /LINE is assumed.  Normally this
  2627.   switch should not be used with files opened in /BINARY mode (but nothing
  2628.   prevents it either).
  2629.  
  2630. /SIZE:number
  2631.   Specifies that the given number of bytes (characters) is to be read.  The
  2632.   actual number of bytes returned will be less if the end of file is reached
  2633.   (or a NUL byte is encountered).  For example, if a file is 514 bytes long,
  2634.   FILE READ /SIZE:512 returns 512 bytes the first time and 2 bytes the second
  2635.   time.  FILE READ /SIZE provides a kind of "record i/o" for files that do not
  2636.   necessarily contain lines.  The resulting block of characters is assigned to
  2637.   the variable without any editing.  Synonym: /BLOCK.
  2638.  
  2639. /CHARACTER
  2640.   Equivalent to /SIZE:1.  If FILE READ /CHAR succeeds but the <variable> is
  2641.   empty, this indicates a NUL byte was read.  Synonym: BYTE.
  2642.  
  2643. FILE WRITE switches are:
  2644.  
  2645. /LINE
  2646.   Specifies that an appropriate line terminator is to be added to the
  2647.   end of the <text>.  If no switches are included, /LINE is assumed.
  2648.  
  2649. /SIZE:number
  2650.   Specifies that the given number of bytes (characters) is to be written.
  2651.   If the given <text> is longer than the requested size, it is truncated;
  2652.   if is shorter, it is padded according /LPAD and /RPAD switches.  Synonym:
  2653.   /BLOCK.
  2654.  
  2655. /LPAD[:value]
  2656.   If /SIZE was given, but the <text> is shorter than the requested size, the
  2657.   text is padded on the left with sufficient copies of the character whose
  2658.   ASCII value is given to write the given length.  If no value is specified,
  2659.   32 (the code for Space) is used.  The value can also be 0 to write the
  2660.   indicated number of NUL bytes.  If /SIZE was not given, this switch is
  2661.   ignored.
  2662.  
  2663. /RPAD[:value]
  2664.   Like LPAD, but pads on the right.
  2665.  
  2666. /CHARACTER
  2667.   Specifies that one character should be written.  If the <text> is empty or
  2668.   not given, a NUL character is written; otherwise the first character of
  2669.   <text> is given.  Synonym: /BYTE.
  2670.  
  2671. /STRING
  2672.   Specifies that the <text> is to be written as-is, with no terminator added.
  2673.  
  2674. Here's an example in which we copy a text file line by line:
  2675.  
  2676.   file open /read \%c oofa.txt            ; Open input file
  2677.   if fail exit 1 Can't open input file    ; Check that it's open
  2678.   file open /write \%d new.txt            ; Open output file
  2679.   if fail exit 1 Can't open output file   ; Check
  2680.   while true {                            ; Loop to copy lines
  2681.       file read /line \%c line            ; Read a line
  2682.       if fail break                       ; Assume failure = end of file
  2683.       file write /line \%d {\m(line)}     ; Write the line to output file
  2684.       if fail exit 1 Write failure        ; Failure here is fatal
  2685.   }
  2686.   file close \%c                          ; Close the two files
  2687.   file close \%d
  2688.  
  2689. Note that since /LINE is the default for both FILE READ and FILE WRITE, it can
  2690. be omitted as in the following example, where we also use the short names for
  2691. the FILE commands.
  2692.  
  2693.   fopen /read \%c oofa.txt                ; Open input file
  2694.   if fail exit 1 Can't open input file    ; Check that it's open
  2695.   fopen /write \%d new.txt                ; Open output file
  2696.   if fail exit 1 Can't open output file   ; Check
  2697.   while true {                            ; Loop to copy lines
  2698.       fread \%c line                      ; Read a line
  2699.       if fail break                       ; Assume failure = end of file
  2700.       fwrite \%d {\m(line)}               ; Write the line to output file
  2701.       if fail exit 1 Write failure        ; Failure here is fatal
  2702.   }
  2703.   fclose \%c                              ; Close the two files
  2704.   fclose \%d
  2705.  
  2706. Here's the same example using "record i/o" (the open and close sequences are
  2707. are omitted since they are the same as above).  The result is the same, but
  2708. execution is much faster:
  2709.  
  2710.   while true {                            ; Loop to copy blocks
  2711.       fread /size:512 \%c block           ; Read a block into \%a
  2712.       if fail break                       ; Assume failure = end of file
  2713.       fwrite /string \%d {\m(block)}      ; Write the block to output file
  2714.       if fail exit 1 Write failure        ; Failure here is fatal
  2715.   }
  2716.  
  2717. Although record i/o is faster, it should not be used in line-oriented
  2718. applications, since it returns arbitrary chunks of the file to your script,
  2719. rather than lines.  In this example, FWRITE /STRING is used rather than FWRITE
  2720. /SIZE:512 to avoid the last output block being padded beyond the original
  2721. file's length.
  2722.  
  2723. A file can also be copied character by character, but this is much slower than
  2724. line i/o and VERY much slower than block i/o:
  2725.  
  2726.   while true {                            ; Loop to copy blocks
  2727.       fread /char \%c c                   ; Read a character into c
  2728.       if fail break                       ; Assume failure = end of file
  2729.       fwrite /char \%d {\m(c)}            ; Write character to output file
  2730.       if fail exit 1 Write failure        ; Failure is fatal
  2731.   }
  2732.  
  2733. Although character i/o is slow, it is the only way to process files that
  2734. contain NUL characters (i.e. bytes composed of only zero bits).  In the
  2735. example above, when "fread /char \%c c" returns a NUL, the c variable is
  2736. empty.  But since the FREAD /CHAR command did not fail, we know the result was
  2737. really a NUL.  FWRITE /CHAR, when given an empty variable (or no variable at
  2738. all) writes a NUL.  Thus the loop above will copy any file at all (very
  2739. slowly).  In non-copying applications, NULs are detected like this:
  2740.  
  2741.   fread /char \%c c
  2742.   if fail (do something)
  2743.   if not def c (a NUL byte was read)
  2744.  
  2745. Finally some advanced file operations:
  2746.  
  2747. FILE FLUSH <channel>
  2748.   For output files only: commits all previous writes to disk,
  2749.   in case the computer was buffering them.  Synonym: FFLUSH.
  2750.  
  2751. FILE COUNT [ { /BYTES, /LINES, /LIST, /NOLIST } ] <channel>
  2752.   By default, or if the /BYTES switch is given, counts the bytes in the
  2753.   file, if any, open on the given channel.  If the /LINES switch is given,
  2754.   counts lines in the file.  If the /LIST switch is given, the result is
  2755.   printed.  If the /NOLIST switch is given, the result is not printed.
  2756.   /QUIET is a synonym for /NOLIST.  If neither /LIST nor /NOLIST is given,
  2757.   the result is printed if the command is given at top level, i.e. not from
  2758.   a command file or macro.  In all cases, the result of the most recent FILE
  2759.   COUNT command is stored in the variable \v(f_count).  Note that FILE COUNT
  2760.   /LINE works (and can only work) by reading the entire file; expect it to
  2761.   take some time if the file is large.  Synonym: FCOUNT.
  2762.  
  2763. FILE REWIND <channel>
  2764.   Moves the read/write pointer to the beginning of the file.  Equivalent to
  2765.   FILE SEEK <channel> 0.  Synonym: FREWIND.
  2766.  
  2767. FILE SEEK [ switches ] <channel> { [{+,-}]<number>, LAST, EOF }
  2768.   Moves the read/write pointer for the file on this channel to the given
  2769.   position, which may be a byte (character) number or a line number,
  2770.   expressed in either absolute or relative terms.  Switches:
  2771.  
  2772.    /BYTE     - The number given is a byte number.  Synonym: /CHARACTER.
  2773.    /LINE     - The number given is a line number.
  2774.    /ABSOLUTE - The number given is absolute.
  2775.    /RELATIVE - The number given is relative to the current position.
  2776.  
  2777.   By default, or if the /BYTE switch is given, the <number> is a
  2778.   byte number (0 = first byte).  If /LINE is given, the <number> is a line
  2779.   number (0 = first line).  EOF means to move to the end of the file.
  2780.   LAST means to move to the last line or character of the file, depending
  2781.   on whether it's a line or character seek.
  2782.  
  2783.   If neither the /RELATIVE nor the /ABSOLUTE switch is given, then if a
  2784.   signed number is given, the motion is relative to the current position.
  2785.   An expression that evaluates to a negative number is not considered signed
  2786.   for this purpose; that is, a sign (+ or -) must be included as the first
  2787.   character of the <number> in the command itself to force a relative seek
  2788.   (in the absence of /RELATIVE or /ABSOLUTE).
  2789.  
  2790.   If the number has no sign, or if the /ABSOLUTE switch is given, the number
  2791.   represents an absolute position (relative to the beginning of the file).
  2792.   Subsequent FILE READs or WRITEs will take place at the new position.
  2793.  
  2794.   If the read/write pointer is placed after the end of the file, a
  2795.   subsequent FILE READ will fail, but a FILE WRITE will succeed (possibly
  2796.   creating a file with "holes").  If a FILE SEEK /BYTE command is given, the
  2797.   current line becomes unknown (unless the position is 0) and subsequent
  2798.   FILE SEEK /RELATIVE /LINE commands will fail until the next non-relative
  2799.   FILE SEEK /LINE command is given.  Synonym: FSEEK.
  2800.  
  2801. An absolute FILE SEEK to a negative position fails silently, as does a
  2802. relative seek to a position before the beginning of the file.
  2803.  
  2804. A caution about relative SEEKs: remember that the number is relative to the
  2805. current position.  Whenever you read or write, this changes the position.
  2806. In each of the following examples, assume the file open on channel \%c is
  2807. positioned at line "n" (the FREAD target variable is omitted for lack of
  2808. space):
  2809.  
  2810.   { FREAD \%c, FSEEK /LINE \%c -1, FREAD \%c }  <-- Reads line n twice
  2811.   { FREAD \%c, FSEEK /LINE \%c +0, FREAD \%c }  <-- Reads lines n and n+1
  2812.   { FREAD \%c, FSEEK /LINE \%c +1, FREAD \%c }  <-- Reads lines n and n+2
  2813.   { FREAD \%c, FSEEK /LINE \%c -2, FREAD \%c }  <-- Reads lines n and n-1
  2814.   { FREAD \%c, FSEEK /LINE \%c -3, FREAD \%c }  <-- Reads lines n and n-2
  2815.  
  2816. Another caution: Using FSEEK and FREAD /SIZE to repeatedly read the same disk
  2817. block (e.g. when sampling a database record that is frequently updated) might
  2818. not give you updated disk blocks due to the internal buffering and caching of
  2819. the C library (this probably varies from one platform/compiler combination to
  2820. another).  If necessary you can force a fresh disk read with a close/open
  2821. sequence:
  2822.  
  2823.   FCLOS \%c
  2824.   FOPEN \%c <samefilename>
  2825.   FSEEK \%c <samespot>
  2826.   FREAD /SIZE:<howmanybytes> \%c <variable>
  2827.  
  2828. 1.22.3. FILE Command Examples
  2829.  
  2830. To read the last 10 lines of a text file into an array:
  2831.  
  2832.   fopen /read \%c oofa.txt                ; Open the file
  2833.   if fail exit 1 Can't open oofa.txt      ; Always check for failure
  2834.   dcl \&a[10]                             ; Declare a 10-element array
  2835.   fcount /line \%c                        ; Count lines in the file
  2836.   fseek /line \%c \v(f_count)-10          ; Seek to 10 lines from the end
  2837.   if fail exit 1 Can't seek               ; Check for failure
  2838.   for \%i 1 10 1 { fread \%c \&a[\%i] }   ; Read the last 10 lines
  2839.   fclose \%c                              ; Close the file
  2840.  
  2841. Note that blank lines show up as empty (undefined) array elements, for example
  2842. if you give a "show array a" command at this point.  This is normal.  You
  2843. can still use these elements; e.g.:
  2844.  
  2845.   for \%i 1 10 1 { echo \%i. \&a[\%i] }   ; Display the 10 lines
  2846.  
  2847. Here is how to read the last line of a file (already open on channel \%c):
  2848.  
  2849.   fseek /line \%c last                    ; Seek directly to last line
  2850.  
  2851. Alternatively:
  2852.  
  2853.   fseek /line \%c eof                     ; Seek to end of file
  2854.   fseek /line \%c -1                      ; Seek to beginning of last line
  2855.  
  2856. Alternatively:
  2857.  
  2858.   fcount /line \%c                        ; Count the file's lines
  2859.   fseek /line \%c \v(f_count)-1           ; Seek to last line
  2860.   fread \%c                               ; Read it
  2861.  
  2862. To read every other line from the file (using relative SEEK), skipping
  2863. the first line:
  2864.  
  2865.   fopen /read \%c oofa.txt                ; Open the file
  2866.   while ( success ) {                     ; Loop through lines
  2867.       fseek /line \%c +1                  ; Skip a line
  2868.       if success fread \%c                ; Read & display a line
  2869.   }
  2870.   fclose \%c                              ; Close the file
  2871.  
  2872. Here is how to read the lines of a file in reverse order:
  2873.  
  2874.   fopen /read \%c oofa.txt                ; Open
  2875.   if fail exit 1                          ; Check
  2876.   fseek /line \%c last                    ; Seek to last line
  2877.   while success {                         ; Loop
  2878.       fread \%c                           ; Read line
  2879.       fseek /line \%c -2                  ; Seek backwards two lines
  2880.   }
  2881.   fclose \%c                              ; Close the file
  2882.  
  2883. The loop works because a relative SEEK outside the file fails.
  2884.  
  2885. It is also possible to use block i/o to manage random-access files with
  2886. fixed-length records (as long as they don't contain NUL characters).  Suppose,
  2887. for example, you have a file of "card image" records with fixed-field
  2888. information about customers, such as:
  2889.  
  2890.   Name:     Columns  1-32  (column numbers are 1-based)
  2891.   Address:  Columns 33-72
  2892.   Balance:  Columns 73-80
  2893.  
  2894. The records are indexed by customer number, starting with 0.  There are no
  2895. line terminators separating them.  Therefore the record for customer number
  2896. n starts at position n x 80 (\%n*80).
  2897.  
  2898. Now suppose we received a payment from customer number 173 and want to update
  2899. the balance:
  2900.  
  2901.   .\%n = 173                               ; Customer (record) number
  2902.   .\%a = 12.72                             ; Amount
  2903.   fopen /read /write \%c customer.db       ; Open the file
  2904.   if fail stop 1 OPEN FAILED: \f_errmsg()  ; Check
  2905.   fseek /byte \%c 80*\%n                   ; Seek to record
  2906.   fread /size:80 \%c r                     ; Read the record
  2907.   if fail stop 1 READ FAILED: \f_errmsg()  ; Check (IMPORTANT)
  2908.   .\%b := \fright(\m(r),8)                 ; Extract the balance
  2909.   .\%b := \ffpadd(\%b,\%a,2)               ; Add the new payment
  2910.   if fail stop 1 ARITHMETIC ERROR: \%b/\%a ; Catch bad records
  2911.   .r := {\fleft(\m(r),72)\flpad(\%b,8)}    ; Update the record
  2912.   fseek /byte \%c 80*\%n                   ; Reposition to same spot
  2913.   fwrite /size:80 \%c {\m(r)}              ; Replace the record
  2914.   if fail stop 1 WRITE FAILED: \f_errmsg() ; Check
  2915.   fclose \%c                               ; Close the file
  2916.  
  2917. REMEMBER: Using FILE SEEK to move beyond the end of file can result in a file
  2918. with holes when writing; when reading, an end-of-file error will occur --
  2919. be sure to check for it.
  2920.  
  2921. 1.22.4. Channel Numbers
  2922.  
  2923. C-Kermit's channel numbers are integers from 0 to some platform-dependent
  2924. limit, such as 46 or 1985 (the value of \v(f_max)).  This is the limit placed
  2925. by the operating system on the number of files that may be opened by one
  2926. process or user or job, minus the standard input, output, and error files, and
  2927. minus the number of files reserved by C-Kermit for logs, OPEN READ and WRITE,
  2928. and file transfer (and maybe some command files -- the \v(f_max) number can't
  2929. be exact).
  2930.  
  2931. Although you must include a variable in the FILE OPEN command, to which the
  2932. channel number is assigned, you don't have to use a variable in the other FILE
  2933. commands if you know what the number is -- you can just put the number.  This
  2934. saves you a few keystrokes when typing commands at the prompt:
  2935.  
  2936.   fopen \%c oofa.txt
  2937.   flist
  2938.   0. /usr/olga.oofa.txt (R) 0
  2939.  
  2940. This tells the channel number is 0 (the number on the left is the channel
  2941. file's channel number).  Of course you can also find it by echoing the
  2942. variable:
  2943.  
  2944.   echo \%c
  2945.   0
  2946.  
  2947. Or with "fstatus \%c".  Now you can type commands like:
  2948.  
  2949.   fread 0
  2950.  
  2951. to read a line from the file.  Obviously, however, using digits rather than
  2952. a variable for the channel number  would be poor practice in a script.
  2953.  
  2954. If in commands like:
  2955.  
  2956.   fread \%c \%a
  2957.  
  2958. you have trouble remembering which variable is which, note that the channel
  2959. number is, indeed, a number.  Anywhere C-Kermit accepts a number it can also
  2960. accept an expression, so you can put parentheses around the channel number to
  2961. remind you it's the channel number and not the variable into which data is to
  2962. be read:
  2963.  
  2964.   fread (\%c) \%a
  2965.  
  2966. Normally channel numbers are assigned sequentially as 0, 1, 2, ... up to the
  2967. limit.  However, once you start closing files, there can be holes in the
  2968. sequence.  New channels are assigned to fill in the holes.  Thus you can't
  2969. depend on channel numbers being in any particular sequence.
  2970.  
  2971. 1.22.5. FILE Command Errors
  2972.  
  2973. Each FILE command sets the variable \v(f_error) to one of the following values:
  2974.  
  2975.     0 = No error
  2976.    -1 = System error
  2977.    -2 = Attempt to read after end of file
  2978.    -3 = Channel not open
  2979.    -4 = Channel number out of range (negative or too large)
  2980.    -5 = Numeric argument (size, ...) out of range
  2981.    -6 = File not found
  2982.    -7 = Bad or missing filename
  2983.    -8 = Too many files are already open (FILE OPEN only)
  2984.    -9 = Forbidden operation (e.g. write to a read-only file)
  2985.   -10 = Access denied
  2986.   -11 = Illegal combination of OPEN modes (FILE OPEN only)
  2987.   -12 = Buffer overflow
  2988.   -13 = Current line number unknown (for relative line seeks)
  2989.   -14 through -98: Reserved.
  2990.   -99 = Requested operation not implemented in this version of C-Kermit
  2991.  -999 = Unknown error
  2992.  
  2993. When \v(f_error) is -1, this means the FILE command failed because because
  2994. of a system error, in which case you can examine the following variables:
  2995.  
  2996.   \v(errno)     = System error number.
  2997.   \v(errstring) = Error message corresponding to \v(errno).
  2998.  
  2999. A special function is available for translating the \v(f_error) code to an
  3000. error message string:
  3001.  
  3002. \f_errmsg([code])
  3003.   If the code is -1, returns error message of the most recent system
  3004.   error; otherwise if the code is a valid \v(f_error) value, the associated
  3005.   message is returned.  If the code is omitted, the status message
  3006.   corresponding to the current \v(f_error) value is returned.
  3007.  
  3008. A FILE command that fails prints the appropriate error message automatically,
  3009. except when the command is READ or SEEK and the error is -2 (end of file); in
  3010. that case, the command still fails, but does not print a message.  This allows
  3011. constructions such as:
  3012.  
  3013.   fopen \%c oofa.txt
  3014.   while success { fread \%c }
  3015.   fclose \%c
  3016.  
  3017. to work as expected, i.e. without an annoying message when the end of file
  3018. is reached.
  3019.  
  3020. 1.22.6. File I/O Variables
  3021.  
  3022. The variables associated with the file i/o package are:
  3023.  
  3024.   \v(f_count) - Result of the most recent FILE COUNT (FCOUNT) command.
  3025.   \v(f_error) - Numeric error code of most recent FILE command (0 = no error).
  3026.   \v(f_max)   - Maximum number of files open simultaneously.
  3027.  
  3028. 1.22.7. File I/O Functions
  3029.  
  3030. Some of the FILE commands can also be issued as function calls, which makes
  3031. script writing a bit more convenient, especially for C programmers.  Also,
  3032. several functions are provided that do not have command equivalents.  Each of
  3033. these functions takes a channel number as the first argument.  These functions
  3034. do not work for OPEN { READ, !READ, WRITE, !WRITE, and APPEND } files.
  3035.  
  3036. \f_status(channel)
  3037.   Returns 0 if the channel is not open, otherwise a number between 1 and 15
  3038.   which is the sum of the OPEN modes:
  3039.     1 = /READ
  3040.     2 = /WRITE
  3041.     4 = /APPEND
  3042.     8 = /BINARY
  3043.  
  3044. The remaining functions work only for open channels.  Each of these functions
  3045. can fail for the applicable reasons listed in Section 1.22.5.  For instructions
  3046. on handling function errors, see Section 7.12.
  3047.  
  3048. \f_pos(channel)
  3049.   Returns the file's current read/write pointer (0-based).  There is no FILE
  3050.   command equivalent.
  3051.  
  3052. \f_line(channel)
  3053.   Returns the file's current line number (0-based), if known, otherwise -1.
  3054.   There is no FILE command equivalent.  The line number is known as long as
  3055.   no character or block i/o has been done on the channel.
  3056.  
  3057. \f_handle(channel)
  3058.   Returns the "file handle" of the file.  That is, it translates the portable
  3059.   C-Kermit channel number into a system-specific file handle or number that
  3060.   can be passed to other programs on the same platform.  In UNIX this is a
  3061.   file descriptor.  There is no FILE command equivalent.
  3062.  
  3063. \f_eof(channel)
  3064.   Returns 1 if the read/write pointer of the file on the given channel is at
  3065.   the end of the file, 0 otherwise.  Convenient in WHILE statements, e.g.:
  3066.  
  3067.     while not \f_eof(\%c) { fread \%c }
  3068.  
  3069. \f_getchar(channel)
  3070.   Equivalent to FREAD /CHAR.  Returns the character actually read.
  3071.   If \f_getchar() does not fail but the return value is empty, this means
  3072.   a NULL character was read.
  3073.  
  3074. \f_getline(channel)
  3075.   Equivalent to FREAD /LINE.  Returns the line actually read, but with the line
  3076.   terminator stripped.  If \f_getline() does not fail but the return value is
  3077.   empty, this normally means an empty line was read.
  3078.  
  3079. \f_getblock(channel,n)
  3080.   Equivalent to FREAD /SIZE:n.  Returns the block of characters actually read.
  3081.   If the returned block is smaller than n, it indicates either that the end
  3082.   of file was reached or a NUL character is in the block.
  3083.  
  3084. \f_putchar(channel,c)
  3085.   Equivalent to FWRITE /CHARACTER.  Writes the character c.  If c contains
  3086.   more than one character, only the first is written.  If c is empty a NUL
  3087.   is written.  Returns the number of characters written on success, or a
  3088.   negative error code upon failure.
  3089.  
  3090. \f_putline(channel,string)
  3091.   Equivalent to FWRITE /LINE.  Writes the string and adds the appropriate line
  3092.   termination character or sequence.  If the string is empty or omitted, an
  3093.   empty line is written.  Returns the number of characters written on success,
  3094.   or a negative error code upon failure.
  3095.  
  3096. \f_putblock(channel,string)
  3097.   Equivalent to FWRITE /STRING.  Writes the string as given.  If the string is
  3098.   empty or omitted, nothing is written.  Returns the number of characters
  3099.   written on success, or a negative error code upon failure.
  3100.  
  3101. 1.22.8. File I/O Function Examples
  3102.  
  3103.   fopen /read \%c oofa.txt            ; Open our favorite file for reading
  3104.   if failure exit 1                   ; Check that it's open
  3105.   while not \f_eof(\%c) {             ; Loop until EOF
  3106.       .line := \f_getline(\%c)        ; Get a line
  3107.       if success echo {\m(line)}      ; Echo it
  3108.   }
  3109.   if not \f_eof(\%c) {                ; Check reason for loop exit
  3110.       exit 1 File Error: \f_errmsg()  ; If not EOF say so.
  3111.   }
  3112.  
  3113.   frewind \%c                         ; Rewind the file
  3114.   while not \f_eof(\%c) {             ; Same thing but with block i/o
  3115.       .block := \f_getblock(\%c,256)  ; (much faster than line i/o)
  3116.       if success xecho {\m(block)}
  3117.   }
  3118.  
  3119.   frewind \%c                         ; Rewind again
  3120.   while not \f_eof(\%c) {             ; Same deal but with character i/o
  3121.       .c := \f_getchar(\%c)           ; (much slower than line i/o)
  3122.       if success xecho {\m(c)}
  3123.   }
  3124.   close \%c
  3125.  
  3126. To close all open files (equivalent to FCLOSE ALL):
  3127.  
  3128.   for \%i 0 \v(f_max)-1 1 {
  3129.       if \f_status(\%i) fclose \%i
  3130.   }
  3131.  
  3132. 1.23. The EXEC Command
  3133.  
  3134. The EXEC command is available only in UNIX.
  3135.  
  3136. EXEC [ /REDIRECT ] <command> [ <arg1> [ <arg2> [ ... ] ]
  3137.   Runs the given command with the arguments in such a way that the <command>
  3138.   replaces C-Kermit in memory, and C-Kermit ceases to execute.  EXEC is like
  3139.   RUN, except instead of returning to C-Kermit when finished, the <command>
  3140.   returns to whatever process invoked Kermit.
  3141.  
  3142. In the normal case, no files are closed, so the EXEC'd command inherits the
  3143. open files, read/write pointers, working directory, process ID, user ID
  3144. (unless <command> is SUID), group ID (unless command is SGID), groups, etc.
  3145. (In UNIX, the EXEC command is simply a front end for execvp().)
  3146.  
  3147. If the /REDIRECT switch is included, then if a connection is open (SET LINE
  3148. or SET HOST), it becomes the standard input and output of the EXEC'd program.
  3149. If no connection is open, the /REDIRECT switch has no effect.  For example
  3150. to use C-Kermit for PPP dialing in Linux:
  3151.  
  3152.   set modem type usr          ; Specify the kind of modem you have
  3153.   set line /dev/ttyS1         ; Specify the device it's connected to
  3154.   set speed 57600             ; and the speed
  3155.   set flow rts/cts            ; and flow control.
  3156.   set dial retries 100        ; Try the dial sequence up to 100 times.
  3157.   dial {{9-212-555-1212}{9-212-555-1213}{9-212-555-1214}{9-212-555-1215}}
  3158.   if fail exit 1
  3159.   for \%i 1 16 1 {            ; Try up to 16 times to get login prompt
  3160.       input 10 Login:         ; Wait 10 sec for it to appear
  3161.       if success break        ; Got it - proceed...
  3162.       output \13              ; Send a carriage return and try again
  3163.   }
  3164.   if ( > \%i 16 ) stop 1 NO LOGIN PROMPT
  3165.   lineout \(myuserid)         ; Send user ID
  3166.   input 30 assword:           ; Wait for Password prompt
  3167.   if fail stop 1 NO PASSWORD PROMPT
  3168.   lineout \m(mypassword)      ; Send the password.
  3169.   exec /redirect pppd         ; Replace ourselves with pppd.
  3170.  
  3171. In this example we assume that the script has already set up the myuserid and
  3172. mypassword variables -- normally the password should be prompted for, rather
  3173. than stored on disk.  Notice the advantages over the well-known "chat script":
  3174.  
  3175.  . You don't have to control the modem itself with AT commands; Kermit's
  3176.    DIAL command does this for you.
  3177.  . You can have Kermit automatically redial as many times as you want
  3178.    until it gets a connection (if this is legal in your country).
  3179.  . You can have Kermit fetch the number or numbers from a dialing directory.
  3180.  . You can have Kermit cycle through a list of phone numbers (this is new
  3181.    to C-Kermit 7.0; see Section 2.1.15) without having to enter the numbers
  3182.    in a dialing directory.
  3183.  . Dialing is location-independent; you can use the same script to dial from
  3184.    different areas or countries.
  3185.  . Once the connection is made, the full power of Kermit's script language
  3186.    is available to manage the dialog with the terminal server or other
  3187.    device that answers the phone call.
  3188.  
  3189. 1.24. Getting Keyword Lists with '?'
  3190.  
  3191. Suppose you type "te" at the C-Kermit> prompt and then Esc or Tab to request
  3192. keyword completion.  Kermit beeps, indicating that more than one command
  3193. starts with "te".  But if you type '?'  to see what they are, Kermit shows
  3194. only "telnet".  So why the beep?  Because of invisible keywords like "telopt",
  3195. "terminal", and "text".  Lots of keywords are invisible because they are
  3196. either synonyms for other keywords or else esoteric options to be used only
  3197. in special circumstances, so we don't want them cluttering up the menus.
  3198.  
  3199. But then there is no way for you to discover them.  So in C-Kermit 7.0, if you
  3200. type '?' AFTER the beginning of a keyword field, then invisible keywords are
  3201. shown too:
  3202.  
  3203.   C-Kermit>te<Esc><BEEP>
  3204.   C-Kermit>te? Command, one of the following:
  3205.    telnet    telopt    terminal  text
  3206.   C-Kermit>te
  3207.  
  3208. But if '?' is typed at the beginning of a field, only visible keywords are
  3209. shown, as before (so, in this example, if '?' is typed at the C-Kermit>
  3210. prompt, "telnet" is the only command shown that starts with "te").
  3211.  
  3212.  
  3213. (2) MAKING AND USING CONNECTIONS
  3214.  
  3215. The SET LINE, SET HOST, and SET PORT (a synonym for SET LINE) commands have
  3216. new synonyms, in which the word SET is replaced by the word OPEN: OPEN LINE,
  3217. etc.  There is no new functionality here, but OPEN is a better verb, since SET
  3218. generally takes no action, whereas these commands actually try to open a
  3219. connection.  Furthermore, there is the symmetry with CLOSE.
  3220.  
  3221. 2.0. SET LINE and SET HOST Command Switches
  3222.  
  3223. The SET LINE (SET PORT) and SET HOST commands now allow switches before the
  3224. device or host name, in most cases, and under certain circumstances, also at
  3225. the end.  The new syntax is backwards compatible with the previous syntax;
  3226. thus SET LINE, SET PORT, and SET HOST commands in command files written for
  3227. C-Kermit 6.0 or earlier still work.  The expanded syntax is:
  3228.  
  3229.  { OPEN,SET } { LINE,PORT,HOST } [ switches ] <device-or-address> [ switches ]
  3230.  
  3231. The first group of switches is:
  3232.  
  3233. /NETWORK-TYPE:{TCP/IP,X.25,PIPE,PTY...}
  3234.   When more than one network type is available, this lets you specify the
  3235.   type of network to use for this connection without affecting your global
  3236.   SET NETWORK TYPE.  See Section 2.7 about pipes and ptys.
  3237.  
  3238. /USERID:[string]
  3239.   This switch is equivalent to SET LOGIN USERID.  If a string is given, it
  3240.   sent to host during Telnet negotiations; if this switch is given but the
  3241.   string is omitted, no user ID is sent to the host.  If this switch is not
  3242.   given, your current LOGIN USERID (\v(userid) value), if any, is sent.
  3243.   Unlike most other switches, this one is "sticky", since the value must
  3244.   persist throughout the session in case the server requests the ID string
  3245.   at a later time.
  3246.  
  3247. /CONNECT
  3248.   Enter CONNECT mode immediately and automatically after the device or
  3249.   connection is open.  On serial devices, however, when CARRIER-WATCH is
  3250.   not OFF, wait up to 1 second for the Carrier Detect signal to appear
  3251.   before trying to connect, to give the device time to react DTR, which
  3252.   might have been off prior to opening the device.
  3253.  
  3254. /SERVER
  3255.   Enter server mode immediately and automatically after the device or
  3256.   connection is open.  Treatment of carrier is the same as for /CONNECT.
  3257.  
  3258. /WAIT
  3259. /NOWAIT
  3260.   For Telnet connections only: Like SET TELNET WAIT { ON, OFF }, but applies
  3261.   only to this connection, and in fact applies only when OPENing this
  3262.   connection (which is usually the only place it matters).  Typically you
  3263.   would use TELNET /NOWAIT to make a connection to a misbehaving Telnet
  3264.   server that does not reply to negotiations as required by the Telnet
  3265.   protocol definition.
  3266.  
  3267. Note: /CONNECT and /SERVER switches are not available in the RLOGIN and TELNET
  3268. commands, since these commands already include an implicit /CONNECT and
  3269. preclude automatic entry into server mode.
  3270.  
  3271. The /CONNECT and /SERVER switches are especially useful with "set host *"
  3272. connections.  For example, suppose you want to start a Kermit server on socket
  3273. 3000 of your TCP host.  Normally you would have to give the command:
  3274.  
  3275.   set host * 3000
  3276.  
  3277. and then wait for a connection to come in, and only then could you give the
  3278. SERVER command (or else define a macro to do this, and then execute the macro).
  3279. Now you can do it in one step:
  3280.  
  3281.   set host /server * 3000
  3282.  
  3283. This tells C-Kermit to wait for the connection and then enter server mode
  3284. once it comes in, no matter how long it takes.  Similarly, "set host /conn *"
  3285. can be used to wait for a "chat" connection to come in.
  3286.  
  3287. Another set of switches is available in VMS only, for use only with SET LINE:
  3288.  
  3289. /SHARE
  3290.   Allows the SET LINE device to be opened in shared mode.  Normally it makes
  3291.   no sense to open a serial device in shared mode, but it's necessary when
  3292.   C-Kermit is running in an environment such as DECIntact, that opens your
  3293.   job's controlling terminal in such a way that C-Kermit can't open it too,
  3294.   unless it enables SHARE privilege.  Note: SHARE privilege is required.
  3295.  
  3296. /NOSHARE
  3297.   Requires that the SET LINE device not be in use by any other process in
  3298.   order for it to be successfully opened by C-Kermit.  If neither /SHARE nor
  3299.   /NOSHARE is specified, /NOSHARE is used.
  3300.  
  3301. The second group of switches is:
  3302.  
  3303. /NO-TELNET-INIT
  3304.   Do not send initial Telnet negotiations even if this is a Telnet port.
  3305.  
  3306. /RAW-SOCKET
  3307.   This is a connection to a raw TCP socket (Section 2.3.5).
  3308.  
  3309. /RLOGIN
  3310.   Use Rlogin protocol even if this is not an Rlogin port.
  3311.  
  3312. /TELNET
  3313.   Send initial Telnet negotiations even if this is not a Telnet port.
  3314.  
  3315. As of C-Kermit 7.0 and K95 1.1.18, the TELNET command includes an implicit
  3316. /TELNET switch.  So if you TELNET to a non-TELNET port, Kermit sends initial
  3317. Telnet negotiations.  This makes sense, since that's what "telnet" means.
  3318.  
  3319. If you want to make a connection to a non-Telnet port without sending initial
  3320. Telnet negotiations, use:
  3321.  
  3322.   set host [ /connect ] <name-or-address> <port>
  3323.  
  3324. or:
  3325.  
  3326.   telnet <name-or-address> <port> /no-telnet-init
  3327.  
  3328. Additional switches might be added in the future; type "set host ?" or "set
  3329. line ?" to see a current list.
  3330.  
  3331. 2.1. Dialing
  3332.  
  3333. Automatic redialing is illegal or restricted in many countries, so until
  3334. C-Kermit 7.0, it was disabled by default, i.e. until a SET DIAL RETRIES
  3335. command was given.  In C-Kermit 7.0, if no SET DIAL RETRIES command has been
  3336. given, a default is picked dynamically at DIAL time based on the calling
  3337. country code, if known.  At this writing, the only country code known to have
  3338. no restrictions on automatic redialing is 1.  So in this case a limit of 10
  3339. is chosen; otherwise 1.  If you have not given an explicit SET DIAL RETRIES
  3340. command, SHOW DIAL shows the value as "(auto)", and then the value actually
  3341. used is shown when you give the DIAL command.
  3342.  
  3343. As of C-Kermit 7.0, automatic redialing is automatically canceled if the
  3344. call could not be placed because no dialtone was detected.
  3345.  
  3346. 2.1.1. The Dial Result Message
  3347.  
  3348. If DIAL DISPLAY is not ON, the "Call complete" message now shows the modem's
  3349. call result message, for example:
  3350.  
  3351.   Dialing: ...
  3352.   Call complete: "CONNECT 31200/ARQ/V32/LAPM/V42BIS"
  3353.  
  3354. The exact format and contents of this message, of course, depends on the
  3355. make, model, and configuration of your modem, so use your modem manual to
  3356. interpret it.  The call result message is also available in C-Kermit's
  3357. \v(dialresult) variable.
  3358.  
  3359.   C-Kermit> echo \v(dialresult)
  3360.   CONNECT 31200/ARQ/V32/LAPM/V42BIS
  3361.   C-Kermit> echo Speed = \fword(\v(dialresult),2)
  3362.   Speed = 31200
  3363.   C-Kermit>
  3364.  
  3365. Suppose your modem reports the modulation speed as shown above and you want to
  3366. ensure your call is completed at (say) 24000 bps or more.  You can use a
  3367. little macro to do the job:
  3368.  
  3369. define HSDIAL {                ; High Speed DIAL
  3370.     local \%s
  3371.     if < \v(argc) 1 if not def \v(dialnumber) end 1 Usage: \%0 number
  3372.     set dial retries 100
  3373.     set dial interval 1
  3374.     while true {
  3375.     dial \%*
  3376.     if fail end 1 DIAL failed.
  3377.     asg \%s \fword(\v(dialresult),2)
  3378.     if def \%s if numeric \%s if not < \%s 24000 break
  3379.     }
  3380. }
  3381.  
  3382. (See section 7.5 about the \%* variable.)
  3383.  
  3384. 2.1.2. Long-Distance Dialing Changes
  3385.  
  3386. Due to the glut of cell phones, pagers, fax machines, ISPs, etc, area codes
  3387. and dialing rules are changing all the time.  In the North American Numbering
  3388. Plan (NANP) countries (USA, Canada, etc), area codes are split or overlayed
  3389. with increasing frequency, and 10- and 11-digit dialing is gradually becoming
  3390. the norm for local calls.  Changes are occurring In Europe, too, partly for
  3391. these reasons and partly because of some new EC rules.
  3392.  
  3393. In France, effective 18 October 1996, all calls, even local ones, must be
  3394. dialed with an area code.  French area codes are presently 1-digit numbers,
  3395. 1-6, and the long-distance dialing prefix is 0.  All calls within France are
  3396. considered long distance and begin with 01, 02, ..., 06.
  3397.  
  3398. Effective 1 May 1997, all calls within the US state of Maryland, even local
  3399. ones, must be dialed with an area code but WITHOUT the long-distance prefix --
  3400. this is the now widely-known North American phenomenon of "ten digit dialing".
  3401. The same is happening elsewhere -- many cities in Florida adopted 10-digit
  3402. dialing in 1998.
  3403.  
  3404. In Italy beginning 19 June 1998, all calls to fixed (as opposed to mobile)
  3405. numbers must be prefixed by 0.  When calling into Italy from outside, the 0
  3406. must follow the country code (39).  Calls to cell phones, however, must be
  3407. placed without the 0.  Then on 29 December 2000, the 0 will become a 4 (for
  3408. calling fixed numbers) and a prefix of 3 must used for calling mobile phones.
  3409. More info at: http://www.telecomitalia.it/npnn/.
  3410.  
  3411. In Spain, effective 4 April 1998, with hard cutover on 18 July 1998, all
  3412. calls within the country must be dialed with 9 digits, and all calls from
  3413. outside Spain must also be dialed with 9 digits (after the country code, 34).
  3414. The new 9-digit numbers all begin with "9".  More info at:
  3415. http://www.telefonica.es/cambiodenumeracion/
  3416.  
  3417. Several new dialing features and commands have been added in version 6.1 and
  3418. 7.0 to address these changes.
  3419.  
  3420. C-Kermit 6.0 and Kermit 95 1.1.11 and earlier handle the French situation
  3421. via a reasonable subterfuge (setting the local area code to a nonexistent
  3422. one), but did not handle "ten-digit dialing" well at all; the recommended
  3423. technique was to change the long-distance dialing prefix to nothing, but this
  3424. defeated Kermit's "list numbers for one name" feature when the numbers were in
  3425. different locations.  For example:
  3426.  
  3427.   set dial ld-prefix
  3428.   dial onlineservice
  3429.  
  3430. where "onlineservice" is a dialing directory entry name corresponding to
  3431. entries that are in (say) Maryland as well as other states, would not
  3432. correctly dial the numbers not in Maryland.
  3433.  
  3434. A new command lets you specify a list of area codes to be considered local,
  3435. except that the area code must be dialed:
  3436.  
  3437.   SET DIAL LC-AREA-CODES [ areacode [ areacode [ areacode [ ... ] ] ] ]
  3438.  
  3439. The list may include up to 32 area codes.  If a number is called whose area
  3440. code is in this list, it is dialed WITHOUT the long-distance prefix, but WITH
  3441. the area code.  So in Maryland, which (last time we looked) has two area
  3442. codes, 410 and 301, the setup would be:
  3443.  
  3444.   SET DIAL LC-AREA-CODES 410 301
  3445.  
  3446. Example:
  3447.  
  3448.   SET DIAL LD-PREFIX 1
  3449.   SET DIAL AREA-CODE 301
  3450.   SET DIAL LC-AREA-CODES 410 301 <-- Area codes in 10-digit dialing region
  3451.   DIAL +1 (301) 765-4321         <-- Dials 3017654321  (local with area code)
  3452.   DIAL +1 (410) 765-4321         <-- Dials 4107654321  (local with area code)
  3453.   DIAL +1 (212) 765-4321         <-- Dials 12127654321 (long distance)
  3454.  
  3455. The SET DIAL LC-AREA-CODES command does not replace the SET DIAL AREA-CODE
  3456. command.  The latter specifies the area code you are dialing from.  If the
  3457. called number is in the same area code, then the area code is dialed if it is
  3458. also in the LC-AREA-CODES list, and it is not dialed otherwise.  So if "301"
  3459. had not appeared in the LC-AREA-CODES list in the previous example:
  3460.  
  3461.   SET DIAL LD-PREFIX 1
  3462.   SET DIAL AREA-CODE 301
  3463.   SET DIAL LC-AREA-CODES 410     <-- Area codes in 10-digit dialing region
  3464.   DIAL +1 (301) 765-4321         <-- Dials 7654321     (local)
  3465.   DIAL +1 (410) 765-4321         <-- Dials 4107654321  (local with area code)
  3466.   DIAL +1 (212) 765-4321         <-- Dials 12127654321 (long distance)
  3467.  
  3468. The new Kermit versions also add a Local Call Prefix and Local Call Suffix, in
  3469. case you have any need for it.  These are added to the beginning and of local
  3470. phone numbers (i.e. numbers that are not long-distance or international).
  3471. Examples:
  3472.  
  3473.   SET DIAL LD-PREFIX 1
  3474.   SET DIAL LC-PREFIX 9
  3475.   SET DIAL LC-SUFFIX *
  3476.   SET DIAL LC-AREA-CODES 410     <-- Area codes in 10-digit dialing region
  3477.   SET DIAL AREA-CODE 301
  3478.   DIAL +1 (301) 765-4321         <-- Dials 97654321*     (local)
  3479.   DIAL +1 (410) 765-4321         <-- Dials 94107654321*  (local with area code)
  3480.   DIAL +1 (212) 765-4321         <-- Dials 12127654321   (long distance)
  3481.  
  3482. 2.1.3. Forcing Long-Distance Dialing
  3483.  
  3484. Suppose a number is in your country and area, but for some reason you need to
  3485. dial it long-distance anyway (as is always the case in France).  There have
  3486. always been various ways to handle this:
  3487.  
  3488.  1. Temporarily set your area code to a different (or nonexistent or
  3489.     impossible) one (but this required knowledge of which area codes were
  3490.     nonexistent or impossible in each country).
  3491.  
  3492.  2. Dial the number literally instead of using the portable format, but this
  3493.     defeats the purpose of the portable dialing directory.
  3494.  
  3495. Now there is also a new command that, very simply, can force long-distance
  3496. dialing:
  3497.  
  3498. SET DIAL FORCE-LONG-DISTANCE { ON, OFF }
  3499.   If a call is placed to a portable phone number within the same country
  3500.   code as the calling number, it is dialed with the long-distance prefix
  3501.   and the area code if FORCE-LONG-DISTANCE is ON.  If OFF, the regular
  3502.   rules and procedures apply.
  3503.  
  3504. Example (France):
  3505.  
  3506.   SET DIAL COUNTRY-CODE 33
  3507.   SET DIAL AREA-CODE 6
  3508.   SET DIAL FORCE-LONG-DISTANCE ON
  3509.  
  3510. (In fact, SET DIAL COUNTRY-CODE 33 automatically sets DIAL FORCE-LONG-DISTANCE
  3511. ON...)
  3512.  
  3513. Example (USA, for a certain type of reverse-charge calling in which the
  3514. called number must always be fully specified):
  3515.  
  3516.   SET DIAL PREFIX 18002666328$     ; 1-800-COLLECT
  3517.   SET DIAL COUNTRY-CODE 1
  3518.   SET DIAL AREA-CODE 212
  3519.   SET DIAL FORCE-LONG-DISTANCE ON
  3520.  
  3521. Example (Toronto, where calls to exchange 976 within area code 416 must be
  3522. dialed as long distance, even when you are dialing from area code 416):
  3523.  
  3524.   SET DIAL COUNTRY-CODE 1
  3525.   SET DIAL AREA-CODE 416
  3526.   SET DIAL FORCE-LONG-DISTANCE ON
  3527.   DIAL +1 (416) 976-xxxx
  3528.  
  3529. If dialing methods were consistent and sensible, of course it would be
  3530. possible to always dial every domestic call as if it were long distance.  But
  3531. in many locations this doesn't work or if it does, it costs extra.  The
  3532. following macro can be used for dialing any given number with forced
  3533. long-distance format:
  3534.  
  3535.   define LDIAL {
  3536.       local \%x
  3537.       set dial force-long-distance on
  3538.       dial \%*
  3539.       asg \%x \v(success)
  3540.       set dial force-long-distance off
  3541.       end \%x
  3542.   }
  3543.  
  3544. (See section 7.5 about the \%* variable.)
  3545.  
  3546. 2.1.4. Exchange-Specific Dialing Decisions
  3547.  
  3548. This applies mainly to the North American Numbering Plan (NANP).  Refer to the
  3549. section "Alternative notations" in "Using C-Kermit" 2nd Edition, pages
  3550. 106-107, and the story about Toronto on page 110.  Using the new LC-AREA-CODES
  3551. list, we can address the problem by treating the exchange as part of the area
  3552. code:
  3553.  
  3554.   SET DIAL LD-PREFIX 1
  3555.   SET DIAL AREA-CODE 416
  3556.   SET DIAL LC-AREA-CODES 905276
  3557.   DIAL +1 416 765 4321               <-- 7654321      (local)
  3558.   DIAL +1 905 276 4321               <-- 9052764321   (local with area code)
  3559.   DIAL +1 905 528 4321               <-- 19055284321  (long distance)
  3560.  
  3561. The same technique can be used in Massachusetts (story at top of page 111)
  3562. and in any other place where dialing to some exchanges within a particular
  3563. area code is local, but to others in the same area code is long distance.
  3564.  
  3565. 2.1.5. Cautions about Cheapest-First Dialing
  3566.  
  3567. Kermit does not maintain a knowledge base of telephony information; it only
  3568. provides the tools to let you enter a phone number in a standard format and
  3569. dial it correctly from any location in most cases.
  3570.  
  3571. In particular, Kermit does not differentiate the charging method from the
  3572. dialing method.  If a call that is DIALED as long-distance (e.g. from 212 to
  3573. 718 in country code 1) is not CHARGED as long distance, we have no way of
  3574. knowing that without keeping a matrix of charging information for every
  3575. area-code combination within every country, and any such matrix would be
  3576. obsolete five minutes after it was constructed.  Thus, "cheapest-first"
  3577. sorting is only as reliable as our assumption that the charging method follows
  3578. the dialing method.  A good illustration would be certain online services that
  3579. have toll-free dialup numbers which they charge you a premium (in your online
  3580. service bill) for using.
  3581.  
  3582. 2.1.6. Blind Dialing (Dialing with No Dialtone)
  3583.  
  3584. C-Kermit's init string for Hayes-like modems generally includes an X4 command
  3585. to enable as many result codes as possible, so that Kermit can react
  3586. appropriately to different failure reasons.  One of the result codes that X4
  3587. enables is "NO DIALTONE".  A perhaps not obvious side effect of enabling this
  3588. result code that the modem must hear dialtone before it will dial.
  3589.  
  3590. It is becoming increasingly necessary to force a modem to dial even though it
  3591. does not hear a dialtone on the phone line; for example, with PBXs that have
  3592. strange dialtones, or with phone systems in different countries, or with ISDN
  3593. phones, etc.  This is called "blind dialing".
  3594.  
  3595. C-Kermit 7.0 has two new commands to cope with this situation:
  3596.  
  3597. SET DIAL IGNORE-DIALTONE { ON, OFF }
  3598.   OFF (the default) means to tell the modem to wait for dialtone before
  3599.   dialing.  ON means to enable "blind dialing", i.e. tell the modem NOT
  3600.   to wait for dialtone before dialing.  Generally this is accomplished by
  3601.   sending ATX3 to the modem just prior to dialing.  SET MODEM TYPE xxx
  3602.   and then SHOW MODEM displays Kermit's built-in "ignore dialtone" command.
  3603.  
  3604. SET DIAL COMMAND IGNORE-DIALTONE <text>
  3605.   This lets you change the built-in ignore-dialtone command (such as ATX3)
  3606.   to whatever you choose, in case the built-in one does not work, or another
  3607.   command works better.
  3608.  
  3609. Notes:
  3610.  
  3611.  1. The ignore-dialtone command is not sent unless SET DIAL IGNORE-DIALTONE
  3612.     is ON.
  3613.  
  3614.  2. The ATX3 command generally disables not only NO DIALTONE, but also BUSY.
  3615.     So this will prevent Kermit from detecting when the line is busy.  This
  3616.     is a property of the modem, not of Kermit.
  3617.  
  3618. 2.1.7. Trimming the Dialing Dialog
  3619.  
  3620. The command:
  3621.  
  3622.   SET MODEM COMMAND <action> [ <command> ]
  3623.  
  3624. is used to override Kermit's built-in modem commands for each action, for
  3625. each kind of modem in its internal database.  If you include a <command>,
  3626. this is used instead of the built-in one.  If you omit the <command>, this
  3627. restores the original built-in command.
  3628.  
  3629. If you want to omit the command altogether, so Kermit doesn't send the command
  3630. at all, or wait for a response, use:
  3631.  
  3632.   SET MODEM COMMAND <action> {}
  3633.  
  3634. That is, specify a pair of empty braces as the command, for example:
  3635.  
  3636.   SET MODEM COMMAND ERROR-CORRECTION ON {}
  3637.  
  3638. 2.1.8. Controlling the Dialing Speed
  3639.  
  3640. The rate at which characters are sent to the modem during dialing is normally
  3641. controlled by the built-in modem database.  You might want to override this
  3642. if Kermit seems to be dialing too slowly, or it is sending characters to the
  3643. modem faster than the modem handle them.  A new command was added for this
  3644. in C-Kermit 7.0:
  3645.  
  3646. SET DIAL PACING <number>
  3647.   Specifies the number of milliseconds (thousandths of seconds) to pause
  3648.   between each character when sending commands to the modem during DIAL or
  3649.   ANSWER command execution.  0 means no pause at all, -1 (the default) or any
  3650.   other negative number means to use the value from the database.  Any number
  3651.   greater than 0 is the number of milliseconds to pause.
  3652.  
  3653. HINT: You might also need to control the rate at which the modem generates
  3654. Touch Tones during dialing, for example when sending a numeric page.  There
  3655. are two ways to do this.  One way is to insert pause characters into the
  3656. dialing string.  For modems that use the AT command set, the pause character
  3657. is comma (,) and causes a 2-second pause.  On most modems, you can use the S8
  3658. register to change the pause interval caused by comma in the dialing string.
  3659. The other way is to set your modem's tone generation interval, if it has a
  3660. command for that.  Most AT-command-set modems use S11 for this; the value is
  3661. in milliseconds.  For example on USR modems:
  3662.  
  3663.   ATS11=200
  3664.  
  3665. selects an interval of 200 milliseconds to separate each dialing tone.
  3666.  
  3667. Hint: To add S-Register settings or other commands to your dialing procedure,
  3668. use the new SET MODEM COMMAND PREDIAL-INIT command (Section 2.2.2).
  3669.  
  3670. 2.1.9. Pretesting Phone Number Conversions
  3671.  
  3672. The LOOKUP command now accepts telephone numbers as well as directory-entry
  3673. names, for example:
  3674.  
  3675.   LOOKUP +1 (212) 7654321
  3676.  
  3677. When given a phone number, LOOKUP prints the result of converting the phone
  3678. number for dialing under the current dialing rules.  For example, if my
  3679. country code is 1 and my area code is 212, and I am dialing out from a PBX
  3680. whose outside-line prefix is "93,":
  3681.  
  3682.   C-Kermit> lookup +1 (212) 7654321
  3683.   +1 (212) 7654321 => 93,7654321
  3684.   C-Kermit>
  3685.  
  3686. You can also use the \fdialconvert(phone-number) function (Section 2.1.11)
  3687. to do this programmatically:
  3688.  
  3689.   C-Kermit> echo "\fdialconvert(+1 (212) 7654321)"
  3690.   "93,7654321"
  3691.   C-Kermit>
  3692.  
  3693. So the new LOOKUP behaves as follows:
  3694.  
  3695. LOOKUP <portable-format-phone-number>
  3696.   Displays how the number would actually be dialed
  3697.   Sets FAILURE if there was a conversion error, otherwise SUCCESS.
  3698.  
  3699. LOOKUP <literal-format-phone-number>
  3700.   Displays the same <literal-format-phone-number>
  3701.   Always sets SUCCESS.
  3702.  
  3703. LOOKUP <dialing-directory-name>
  3704.   Displays all matching entries and converts portable phone numbers.
  3705.   Sets SUCCESS if at least one entry was found, otherwise FAILURE.
  3706.  
  3707. LOOKUP =anything
  3708.   Displays "=anything" and sets SUCCESS.
  3709.  
  3710. There is, at present, no programmatic way to fetch numbers from the dialing
  3711. directory.  This will be considered for a future release.
  3712.  
  3713. 2.1.10. Greater Control over Partial Dialing
  3714.  
  3715. The following rules now apply to partial dialing:
  3716.  
  3717.  . Phone number transformations based on country and area code,
  3718.    application of prefixes, etc, are performed only on the first PDIAL.
  3719.  
  3720.  . Each PDIAL argument is looked up in the dialing directory, so it is
  3721.    possible have directory entries for pieces of phone numbers or other
  3722.    information.
  3723.  
  3724.  . Suffixes are not applied automatically, since there is no way for C-Kermit
  3725.    to know in which PDIAL segment you want them to be applied.
  3726.  
  3727. However, the suffix that *would* have been applied, based on the dialing rules
  3728. that were invoked when processing the first PDIAL command, is stored in the
  3729. variable:
  3730.  
  3731.   \v(dialsuffix)
  3732.  
  3733. which you can include in any subsequent PDIAL or DIAL commands.
  3734.  
  3735. Example:
  3736.  
  3737.   pdial {\m(my_long_distance_pager_number_part_1)}
  3738.   pdial {\m(my_long_distance_pager_number_part_2)}
  3739.   pdial {\v(dialsuffix)}
  3740.   pdial {\m(my_long_distance_pager_number_part_3)}
  3741.   pdial {@\m(numeric_pager_code)#}
  3742.  
  3743. 2.1.11. New DIAL-related Variables and Functions
  3744.  
  3745. \fdialconvert(s)
  3746.   s is a phone number in either literal or portable format (not a dialing
  3747.   directory entry name).  The function returns the dial string that would
  3748.   actually be used by the DIAL command when dialing from the current location,
  3749.   after processing country code, area code, and other SET DIAL values, and
  3750.   should be the same as the result of LOOKUP when given a telephone number.
  3751.  
  3752. \v(dialsuffix)
  3753.   Contains the suffix, if any, that was applied in the most recent DIAL
  3754.   command, or the suffix that would have been applied in the most recent PDIAL
  3755.   command.  Use this variable to send the dial suffix at any desired point in
  3756.   a PDIAL sequence.
  3757.  
  3758. \v(dialtype)
  3759.   A number indicating the type of call that was most recently placed.  Can
  3760.   be used after a normal DIAL command, or after the first PDIAL command in
  3761.   a PDIAL sequence.  Values are:
  3762.  
  3763.     -2: Unknown because TAPI handled the phone number translation.
  3764.     -1: Unknown because some kind of error occured.
  3765.      0: Internal within PBX.
  3766.      1: Toll-free.
  3767.      2: Local within calling area.
  3768.      3: Unknown (e.g. because a literal-format phone number was given).
  3769.      4: Long distance within country.
  3770.      5: International
  3771.  
  3772. \v(dialcount)
  3773.   The current value of the DIAL retry counter, for use in a DIAL macro
  3774.   (Section 2.1.13).
  3775.  
  3776. \v(d$px)
  3777.   PBX Exchange (see Section 2.1.12).
  3778.  
  3779. Other dial-related variables, already documented in "Using C-Kermit" (or
  3780. other sections of this document, e.g. 2.1.1), include \v(dialnumber),
  3781. \v(dialstatus), etc.  A convenient way to display all of them is:
  3782.  
  3783.   show variable dial  ; hint: abbreviate "sho var dial"
  3784.  
  3785. This shows the values of all the variables whose names start with "dial".
  3786. Also "show variable d$" (to show the \v(d$...) variables).
  3787.  
  3788. 2.1.12. Increased Flexibility of PBX Dialing
  3789.  
  3790. Refer to "Using C-Kermit", 2nd Edition, pages 107-108.  Recall that three
  3791. commands are needed to configure C-Kermit for dialing from a PBX:
  3792.  
  3793.   SET DIAL PBX-EXCHANGE <number>
  3794.   SET DIAL PBX-INSIDE-PREFIX <number>
  3795.   SET DIAL PBX-OUTSIDE-PREFIX <number>
  3796.  
  3797. Unfortunately, this model does not accommodate PBXs that have more than one
  3798. exchange.  For example our PBX at Columbia University (which must handle more
  3799. than 10,000 phones) has 853-xxxx and 854-xxxx exchanges.
  3800.  
  3801. Beginning in C-Kermit 7.0, the SET DIAL PBX-EXCHANGE command accepts a list of
  3802. exchanges, e.g.:
  3803.  
  3804.   SET DIAL PBX-EXCHANGE 853 854
  3805.  
  3806. (multiple exchanges are separated by spaces, not commas).
  3807.  
  3808. So now when dialing a portable-format number that has the same country and
  3809. area codes as those of your dialing location, C-Kermit compares the exchange
  3810. of the dialed number with each number in the PBX Exchange list (rather than
  3811. with a single PBX Exchange number, as it did formerly) to determine whether
  3812. this is an internal PBX number or an external call.  If it is an external
  3813. call, then the PBX Outside Prefix is applied, and then the normal dialing
  3814. rules for local or long-distance calls.
  3815.  
  3816. If it is an inside call, the exchange is replaced by the PBX Inside Prefix.
  3817. But if the PBX has more than one exchange, a single fixed PBX Inside Prefix is
  3818. probably not sufficient.  For example, at Columbia University, we must dial
  3819. 3-xxxx for an internal call to 853-xxxx, but 4-xxxx for a call to 854-xxxx.
  3820. That is, the inside prefix is the final digit of the exchange we are dialing.
  3821. For this reason, C-Kermit 7.0 provides a method to determine the inside prefix
  3822. dynamically at dialing time, consisting of a new variable and new syntax for
  3823. the SET DIAL PBX-INSIDE-PREFIX command:
  3824.  
  3825. \v(d$px)
  3826.   This variable contains the exchange that was matched when a PBX internal
  3827.   call was detected.  For example, if the PBX exchange list is "853 854"
  3828.   and a call is placed to +1 (212) 854-9999, \v(d$px) is set to 854.
  3829.  
  3830. SET DIAL PBX-INSIDE-PREFIX \fxxx(...)
  3831.   If the PBX Inside Prefix is defined to be a function, its evaluation is
  3832.   deferred until dialing time.  Normally, this would be a string function
  3833.   having \v(d$px) as an operand.  Of course, you can still specify a constant
  3834.   string, as before.
  3835.  
  3836. So given the following setup:
  3837.  
  3838.   SET DIAL COUNTRY-CODE 1
  3839.   SET DIAL AREA-CODE 212
  3840.   SET DIAL PBX-OUTSIDE-PREFIX 93,
  3841.   SET DIAL PBX-EXCHANGE 853 854
  3842.   SET DIAL PBX-INSIDE-PREFIX \fright(\v(d$px),1)
  3843.  
  3844. The following numbers give the results indicated:
  3845.  
  3846.  Number                   Result
  3847.   +1 (212) 854-9876        4-9876
  3848.   +1 (212) 853-1234        3-1234
  3849.   +1 (212) 765-4321        93,765-4321
  3850.   +1 (333) 765-4321        93,1333765-4321
  3851.  
  3852. Furthermore, the K_PBX_XCH environment variable may now be set to a list of
  3853. exchanges to automatically initialize C-Kermit's PBX exchange list, for
  3854. example (in UNIX ksh or bash):
  3855.  
  3856.   export K_PBX_XCH="853 854"
  3857.  
  3858. (Quotes required because of the space.)  Of course, this variable can also be
  3859. set to a single exchange, as before:
  3860.  
  3861.   export K_PBX_XCH=853
  3862.  
  3863. 2.1.13. The DIAL macro - Last-Minute Phone Number Conversions
  3864.  
  3865. After a DIAL or LOOKUP command is given, a list of phone numbers is assembled
  3866. fromt the dialing directory (if any), with all location-dependent conversion
  3867. rules applied as described in Chapter 5 of "Using C-Kermit".
  3868.  
  3869. However, additional conversions might still be required at the last minute
  3870. based on local or ephemeral conditions.  So that you can have the final word
  3871. on the exact format of the dial string, C-Kermit 7.0 lets you pass the
  3872. converted string through a macro of your own design for final processing
  3873. before dialing.  The relevant command is:
  3874.  
  3875. SET DIAL MACRO [ name ]
  3876.   Specifies the name of a macro to be run on each phone number after all
  3877.   built-in conversions have been applied, just before the number is dialed.
  3878.   If no name is given, no macro is run.  The phone number, as it would have
  3879.   been dialed if there were no dial macro, is passed to the macro.
  3880.  
  3881. The dial macro can do anything at all (except start a file transfer).
  3882. However, the normal use for the macro would be to modify the phone number.
  3883. For this reason the phone number is passed to the macro as argument number 1
  3884. (\%1).  To cause a modified number to be dialed, the macro should terminate
  3885. with a RETURN statement specifying a return value.  To leave the number alone,
  3886. the macro should simply end.  Example:
  3887.  
  3888.   define xxx return 10108889999$\%1
  3889.   set dial macro xxx
  3890.   dial xyzcorp
  3891.  
  3892. This defines a DIAL MACRO called xxx, which puts an access code on the
  3893. front of the number.  Another example might be:
  3894.  
  3895.   def xxx if equal "\v(modem)" "hayes-1200" return \freplace(\%1,$,{,,,,,})
  3896.   set dial macro xxx
  3897.   dial xyzcorp
  3898.  
  3899. which replaces any dollar-sign in the dial string by a series of five commas,
  3900. e.g. because this particular modem does not support the "wait for bong"
  3901. feature (remember that commas that are to be included literally in function
  3902. arguments must be enclosed in braces to distinguish them from the commas that
  3903. separate the arguments) and when the IF condition is not satisfied, the macro
  3904. does not return a value, and so the number is not modified.  Then when a DIAL
  3905. command is given referencing a dialing directory entry, "xyzcorp".  The macro
  3906. is automatically applied to each matching number.
  3907.  
  3908. Numerous dial-, modem-, communications-, and time-related variables are
  3909. available for decision making your dial macro.  Type SHOW VARIABLES for a
  3910. list.  Of particular interest is the \v(dialcount) variable, which tells how
  3911. many times the DIAL command gone through its retry loop: 1 on the first try,
  3912. 2 on the second, 3 on the third, and so on, and the \v(dialresult) and
  3913. \v(dialstatus) variables.
  3914.  
  3915. Here are some other applications for the DIAL MACRO (from users):
  3916.  
  3917.  . Phone numbers in the dialing directory are formatted with '-'
  3918.    for readability, but some modems don't like the hyphens, so the DIAL
  3919.    macro is used to remove them before dialing; e.g 0090-123-456-78-99
  3920.    becomes 00901234567899: "def xxx return \freplace(\%1,-)".
  3921.  
  3922.  . To set some specific modem (or other) options depending on the called
  3923.    customer or telephone number.
  3924.  
  3925.  . Choosing the most appropriate provider based on (e.g.) time of day,
  3926.    or cycling through a list of providers in case some providers might
  3927.    be busy.
  3928.  
  3929. To illustrate the final item, suppose you have a choice among many phone
  3930. service providers; the provider is chosen by dialing an access code before the
  3931. number.  Different providers might be better (e.g. cheaper) for certain times
  3932. of day or days of the week, or for dialing certain locations; you can use the
  3933. DIAL macro to add the access for the most desirable provider.
  3934.  
  3935. Similarly, when the same number might be reached through multiple providers,
  3936. it's possible that one provider might not be able to complete the call, but
  3937. another one can.  In that case, you can use the DIAL macro to switch providers
  3938. each time through the DIAL loop -- that's where the \v(dialcount) variable
  3939. comes in handy.
  3940.  
  3941. The following command can be used to debug the DIAL macro:
  3942.  
  3943. SET DIAL TEST { ON, OFF }
  3944.   Normally OFF, so the DIAL command actually dials.  When ON, the DIAL
  3945.   command performs all lookups and number conversions, and then goes through
  3946.   the number list and retry loop, but instead of actually dialing, lists
  3947.   the numbers it would have called if none of the DIAL attempts succeeded
  3948.   (or more precisely, every number was always busy).
  3949.  
  3950. 2.1.14. Automatic Tone/Pulse Dialing Selection
  3951.  
  3952. SET DIAL METHOD { AUTO, DEFAULT, PULSE, TONE }
  3953.   Chooses the dialing method for subsequent calls.
  3954.  
  3955. Prior to verion 7.0, C-Kermit's DIAL METHOD was DEFAULT by default, meaning
  3956. it does not specify a dialing method to the modem, but relies on the modem
  3957. to have an appropriate default dialing method set.  So, for example, when
  3958. using Hayes compatible modems, the dial string would be something like
  3959. ATD7654321, rather than ATDT7654321 or ATDP7654321.
  3960.  
  3961. In C-Kermit 7.0 and K95 1.1.18, the dial method can be set from the
  3962. environment variable:
  3963.  
  3964.   K_DIAL_METHOD
  3965.  
  3966. when Kermit starts.  The values can be TONE, PULSE, or DEFAULT, e.g. (UNIX):
  3967.  
  3968.   set K_DIAL_METHOD=TONE; export K_DIAL_METHOD
  3969.  
  3970. In the absence of a K_DIAL_METHOD definition, the new default SET DIAL METHOD
  3971. is AUTO rather than DEFAULT.  When DIAL METHOD is AUTO and the local country
  3972. code is known, then if tone dialing is universally available in the
  3973. corresponding area, tone dialing is used; if dialing from a location where
  3974. pulse dialing is mandatory, pulse dialing is used.
  3975.  
  3976. The "tone country" and "pulse country" lists are preloaded according to our
  3977. knowledge at the time of release.  You can see their contents in the SHOW
  3978. DIAL listing.  You can change the lists with:
  3979.  
  3980. SET DIAL TONE-COUNTRIES [ cc [ cc [ ... ] ] ]
  3981.   Replaces the current TONE-COUNTRIES list with the one given.  Each cc is
  3982.   a country code; separate them with spaces (not commas).  Example:
  3983.  
  3984.     set dial tone-countries 1 358 44 46 49
  3985.  
  3986.   If no country codes are given, the current list, if any, is removed, in
  3987.   which case SET DIAL METHOD AUTO is equivalent to SET DIAL METHOD DEFAULT.
  3988.  
  3989. SET DIAL PULSE-COUNTRIES [ cc [ cc [ ... ] ] ]
  3990.   Replaces the current PULSE-COUNTRIES list with the one give.  Syntax and
  3991.   operation is like SET DIAL TONE-COUNTRIES.
  3992.  
  3993. If the same country code appears in both lists, Pulse takes precedence.
  3994.  
  3995. The SET DIAL TONE- and PULSE-COUNTRIES commands perform no verification
  3996. whatsoever on the cc's, since almost any syntax might be legal in some
  3997. settings.  Furthermore, there is no facility to edit the lists; you can only
  3998. replace the whole list.  However, since the only purpose of these lists is to
  3999. establish a basis for picking tone or pulse dialing automatically, all you
  4000. need to override the effect of the list is to set a specific dialing method
  4001. with SET DIAL METHOD TONE or SET DIAL METHOD PULSE.
  4002.  
  4003. 2.1.15. Dial-Modifier Variables
  4004.  
  4005. As of C-Kermit 7.0, dial modifiers are available in the following variables:
  4006.  
  4007.  \v(dm_lp) Long pause
  4008.  \v(dm_sp) Short pause
  4009.  \v(dm_pd) Pulse dial
  4010.  \v(dm_td) Tone dial
  4011.  \v(dm_wa) Wait for answer
  4012.  \v(dm_wd) Wait for dialtone
  4013.  \v(dm_rc) Return to command mode
  4014.  
  4015. You can use these in your dial strings in place of hardwired modifiers like
  4016. "@", ",", etc, for increased portability of scripts.  Example:
  4017.  
  4018.   C-Kermit>set modem type usrobotics
  4019.   C-Kermit>sho variables dm
  4020.    \v(dm_lp) = ,
  4021.    \v(dm_sp) = /
  4022.    \v(dm_pd) = P
  4023.    \v(dm_td) = T
  4024.    \v(dm_wa) = @
  4025.    \v(dm_wd) = W
  4026.    \v(dm_rc) = ;
  4027.   C-Kermit>exit
  4028.  
  4029. 2.1.15. Giving Multiple Numbers to the DIAL Command
  4030.  
  4031. Prior to C-Kermit 7.0, the only way to give a DIAL command a list of phone
  4032. numbers to try until one answers was to create a dialing directory that had
  4033. multiple entries under the same name, and then use that entry name in the DIAL
  4034. command.  Now a list of numbers can be given to the DIAL command directly in
  4035. the following format:
  4036.  
  4037.   dial {{number1}{number2}{number3}...}
  4038.  
  4039. This is the same list format used by SEND /EXCEPT: and other commands that
  4040. allow a list where normally a single item is given.  Restrictions on this
  4041. form of the DIAL command are:
  4042.  
  4043.  . The first two braces must be adjacent; spacing is optional thereafter.
  4044.  . Each number must be an actual number to dial, not a dialing directory entry.
  4045.  . Dialing directory entries may not contain number lists in this format.
  4046.  
  4047. In all other respects, the numbers are treated as if they had been fetched
  4048. from the dialing directory; they can be in literal or portable format, etc.
  4049. Example:
  4050.  
  4051.   dial {{7654321} {+1 (212) 5551212} { 1-212-5556789 }}
  4052.  
  4053. The list can be any length at all, within reason.
  4054.  
  4055. This feature is especially handy for use with the K95 Dialer, allowing a list
  4056. of phone numbers to be specified in the Telephone Number box without having
  4057. to set up or reference a separate dialing directory.
  4058.  
  4059. You can also use it to add commonly-dialed sequences as variables in your
  4060. C-Kermit customization file, e.g.:
  4061.  
  4062.   define work {{7654321}{7654322}{7654323}}
  4063.  
  4064. and then:
  4065.  
  4066.   dial {\m(work)}
  4067.  
  4068. (the variable name must be enclosed in braces).
  4069.  
  4070. Or more simply:
  4071.  
  4072.   define work dial {{7654321}{7654322}{7654323}}
  4073.  
  4074. and then:
  4075.  
  4076.   work
  4077.  
  4078. 2.2. Modems
  4079.  
  4080. 2.2.1. New Modem Types
  4081.  
  4082. Since C-Kermit 6.0:
  4083.  
  4084.   atlas-newcom-33600ifxC Atlas/Newcom 33600
  4085.   att-keepintouch        AT&T KeepinTouch PCMCIA V.32bis Card Modem
  4086.   att-1900-stu-iii       AT&T Secure Data STU-III Model 1900
  4087.   att-1910-stu-iii       AT&T Secure Data STU-III Model 1910
  4088.   bestdata               Best Data
  4089.   cardinal               Cardinal V.34 MVP288X series.
  4090.   compaq                 Compaq Data+Fax (e.g. in Presario)
  4091.   fujitsu                Fujitsu Fax/Modem Adapter
  4092.   generic-high-speed     Any modern error-correcting data-compressing modem
  4093.   itu-t-v25ter/v250      ITU-T (CCITT) V.25ter (V.250) standard command set
  4094.   megahertz-att-v34      Megahertz AT&T V.34
  4095.   megahertz-xjack        Megahertz X-Jack
  4096.   motorola-codex         Motorola Codex 326X Series
  4097.   motorola-montana       Motorola Montana
  4098.   mt5634zpx              Multitech MT5634ZPX
  4099.   rockwell-v90           Rockwell V.90 56K
  4100.   rolm-244pc             Siemens/Rolm 244PC (AT command set)
  4101.   rolm-600-series        Siemens/Rolm 600 Series (AT command set)
  4102.   spirit-ii              QuickComm Spirit II
  4103.   suprasonic             SupraSonic V288+
  4104.   supra-express-v90      Supra Express V.90
  4105.  
  4106. One of the new types, "generic-high-speed" needs a bit of explanation.  This
  4107. type was added to easily handle other types that are not explicitly covered,
  4108. without going through the bother of adding a complete user-defined modem type.
  4109. This one works for modern modems that use the AT command set, on the
  4110. assumption that all the default ("factory") settings of the modem (a) are
  4111. appropriate for Kermit, (b) include error correction, data compression,
  4112. and speed buffering; and (c) are recallable with the command AT&F.
  4113.  
  4114. If the command to recall your modem's profile is not AT&F, use the SET MODEM
  4115. COMMAND INIT-STRING command to specify the appropriate modem command.  The
  4116. default init-string is AT&F\13 (that is, AT, ampersand, F, and then carriage
  4117. return); a survey of about 20 modern modem types shows they all support this,
  4118. but they might mean different things by it.  For example, the USR Sportster or
  4119. Courier needs AT&F1 (not AT&F, which is equivalent to AT&F0, which recalls an
  4120. inappropriate profile), so for USR modems:
  4121.  
  4122.   set modem type generic-high-speed
  4123.   set modem command init AT&F1\13
  4124.  
  4125. Of course, USR modems already have their own built-in modem type.  But if you
  4126. use this one instead, it will dial faster because it has fewer commands to
  4127. give to the modem; in that sense "&F1" is like a macro that bundles numerous
  4128. commands into a single one.  See your modem manual for details about factory
  4129. profiles and commands to recall them.
  4130.  
  4131. WARNING: Do not use the generic-high-speed modem type in operating systems
  4132. like VMS where hardware flow control is not available, at least not unless you
  4133. change the init string from AT&F\13 to something else that enables local
  4134. Xon/Xoff or other appropriate type of flow control.
  4135.  
  4136. Also see Section 2.1.7 for additional hints about making dialing go faster.
  4137.  
  4138. 2.2.2. New Modem Controls
  4139.  
  4140. SET MODEM CAPABILITIES <list>
  4141.   In C-Kermit 7.0, this command automatically turns MODEM SPEED-MATCHING OFF
  4142.   if SB (Speed Buffering) is in the <list>, and turns it ON if SB is absent.
  4143.  
  4144. SET MODEM COMMAND PREDIAL-INIT [ <text> ]
  4145.   Commands to be sent to the modem just prior to dialing.  Normally none.
  4146.  
  4147. SET MODEM SPEAKER { ON, OFF }
  4148.   Determines whether modem speaker is on or off while call is being placed.
  4149.   ON by default.  Note: This command does not provide fine-grained control
  4150.   over when the speaker is on or off.  Normally, ON means while the call is
  4151.   being placed, until the point at which carrier is successfully established.
  4152.   If your modem has a different speaker option that you want to choose, then
  4153.   use the SET MODEM COMMAND SPEAKER ON <text> command to specify this option.
  4154.  
  4155. SET MODEM COMMAND SPEAKER { ON, OFF } [ <text> ]
  4156.   Specify or override the commands to turn your modem's speaker on and off.
  4157.  
  4158. SET MODEM VOLUME { LOW, MEDIUM, HIGH }
  4159.   When MODEM SPEAKER is on, select volume.  Note: In some modems, especially
  4160.   internal ones, these commands have no effect; this is a limitation of the
  4161.   particular modem, not of Kermit.
  4162.  
  4163. SET MODEM COMMAND VOLUME { LOW, MEDIUM, HIGH } [ <text> ]
  4164.   Specify or override the commands to set your modem's speaker volume.
  4165.  
  4166. SET MODEM COMMAND IGNORE-DIALTONE [ <text> ]
  4167.   The command to enable blind dialing (section 2.1.6).
  4168.  
  4169. SET MODEM ESCAPE-CHARACTER <code>
  4170.   Has been augmented to allow codes of 0 or less:
  4171.     < 0 means the escape mechanism is disabled.
  4172.     = 0 means to use (restore) the default value from the modem database.
  4173.     > 0 and < 128 is a literal value to be used instead of the default one.
  4174.     > 127 means the escape mechanism is disabled.
  4175.   This affects "modem hangup".  When the escape mechanism is disabled, but
  4176.   SET MODEM HANGUP-METHOD is MODEM-COMMAND, it sends the hangup command
  4177.   immediately, without the <pause>+++<pause> business first.  This is useful
  4178.   (for example) when sending lots of numeric pages, a process in which we
  4179.   never go online, and so never need to escape back.  Eliminating the
  4180.   unnecessary pauses and escape sequence allows a lot more pages to be sent
  4181.   per unit time.
  4182.  
  4183. Recall that C-Kermit can dial modems to which it is connected via TCP/IP
  4184. (Telnet or Rlogin) as described on page 126 of "Using C-Kermit", 2nd Ed.
  4185. In this case the MODEM HANGUP-METHOD should be MODEM-COMMAND, since RS-232
  4186. signals don't work over TCP/IP connections.  As noted in the manual, such
  4187. connections are set up by the following sequence:
  4188.  
  4189.   set host <host> [ <port> ]
  4190.   set modem type <name>
  4191.   dial <number>
  4192.  
  4193. But this can cause complications when you use Kermit to switch between serial
  4194. and TCP/IP connections.  In the following sequence:
  4195.  
  4196.   set host <name>
  4197.   set modem type <name>
  4198.   set port <name>
  4199.  
  4200. the first two commands obey the rules for dialing out over Telnet.  However,
  4201. the SET PORT command requires that Kermit close its current (Telnet)
  4202. connection before it can open the serial port (since Kermit can only have one
  4203. connection open at a time).  But since a modem type was set after the "set
  4204. host" command was given, Kermit assumes it is a Telnet dialout connection and
  4205. so sends the modem's hangup sequence is sent to the Telnet host.  To avoid
  4206. this, close the network connection explicitly before opening the serial one:
  4207.  
  4208.   set host <name>
  4209.   close
  4210.   set modem type <name>
  4211.   set port <name>
  4212.  
  4213. 2.3. TELNET and RLOGIN
  4214.  
  4215. For additional background, please also read the TELNET.TXT file.
  4216.  
  4217. Cautions:
  4218.  
  4219. If making a Telnet connection with C-Kermit takes a very long time, like
  4220. over a minute, whereas the system Telnet program makes the same connection
  4221. immediately, try including the /NOWAIT switch:
  4222.  
  4223.   C-Kermit> telnet /nowait hostname
  4224.  
  4225. See TELNET.TXT for details.  If it also takes a very long time to make a
  4226. Telnet connection with system Telnet, then the delay is most likely caused
  4227. by reverse DNS lookups when your host is not properly registered in DNS.
  4228.  
  4229. When supplying numeric IP addresses to C-Kermit or to any other application
  4230. (regular Telnet, Rlogin, etc), do not include leading 0's in any fields unless
  4231. you intend for those fields to be interpreted as octal (or hex) numbers.  The
  4232. description of the Internet address interpreter (the sockets library
  4233. inet_addr() routine) includes these words:
  4234.  
  4235.   All numbers supplied as "parts" in a "." notation may be decimal, octal,
  4236.   or hexadecimal, as specified in the C language (that is, a leading 0x or
  4237.   0X implies hexadecimal; otherwise, a leading 0 implies octal; otherwise,
  4238.   the number is interpreted as decimal).
  4239.  
  4240. To illustrate, 128.59.39.2 and 128.059.039.002 are NOT the same host!  Even
  4241. though most of the fields contain non-octal digits.  Using system Telnet (not
  4242. Kermit):
  4243.  
  4244.   $ telnet 128.059.039.002
  4245.   Trying 128.49.33.2 ...
  4246.  
  4247. Of course the same thing happens with Kermit because it uses (as it must) the
  4248. same system service for resolving network addresses that Telnet, FTP, and all
  4249. other TCP/IP applications use.
  4250.  
  4251. The RLOGIN section on page 123 does not make it clear that you can use the
  4252. SET TELNET TERMINAL-TYPE command to govern the terminal type that is reported
  4253. by C-Kermit to the RLOGIN server.
  4254.  
  4255. Note that the SET TCP commands described on pages 122-123 might be absent;
  4256. some platforms that support TCP/IP do not support these particular controls.
  4257.  
  4258. New commands:
  4259.  
  4260. TELOPT { AO, AYT, BREAK, CANCEL, EC, EL, EOF, EOR, GA, IP, DMARK, DO, DONT,
  4261.  NOP, SB, SE, SUSP, WILL, WONT }
  4262.   This command was available previously, but supported only DO, DONT, WILL,
  4263.   and WONT.  Now it lets you send all the Telnet protocol commands.  Note
  4264.   that certain commands do not require a response, and therefore can be used
  4265.   as nondestructive "probes" to see if the Telnet session is still open; e.g.:
  4266.  
  4267.     set host xyzcorp.com
  4268.     ...
  4269.     telopt nop
  4270.     if fail stop 1 Connection lost
  4271.  
  4272. SET TCP ADDRESS [ <ip-address> ]
  4273.   Specifies the IP address of the computer that C-Kermit is running on.
  4274.   Normally this is not necessary.  The exception would be if your
  4275.   machine has multiple network adapters (physical or virtual) with a
  4276.   different address for each adapter AND you want C-Kermit to use a
  4277.   specific address when making outgoing connections or accepting
  4278.   incoming connections.
  4279.  
  4280. SET TCP DNS-SERVICE-RECORDS {ON, OFF}
  4281.   Tells C-Kermit whether to try to use DNS SRV records to determine the
  4282.   host and port number upon which to find an advertised service.  For
  4283.   example, if a host wants regular Telnet connections redirected to some
  4284.   port other than 23, this feature allows C-Kermit to ask the host which
  4285.   port it should use.  Since not all domain servers are set up to answer
  4286.   such requests, this feature is OFF by default.
  4287.  
  4288. SET TCP REVERSE-DNS-LOOKUP { ON, OFF, AUTO }
  4289.   Tells Kermit whether to perform a reverse DNS lookup on TCP/IP connections.
  4290.   This allows Kermit to determine the actual hostname of the host it is
  4291.   connected to, which is useful for connections to host pools, and is required
  4292.   for Kerberos connections to host pools and for incoming connections.  If the
  4293.   other host does not have a DNS entry, the reverse lookup could take a long
  4294.   time (minutes) to fail, but the connection will still be made.  Turn this
  4295.   option OFF for speedier connections if you do not need to know exactly which
  4296.   host you are connected to and you are not using Kerberos.  AUTO, the
  4297.   default, means the lookup is done on hostnames, but not on numeric IP
  4298.   addresses.
  4299.  
  4300. SET TELNET WAIT-FOR-NEGOTIATIONS { ON, OFF }
  4301.   Each Telnet option must be fully negotiated either On or Off before the
  4302.   session can continue.  This is especially true with options that require
  4303.   sub-negotiations such as Authentication, Encryption, and Kermit; for
  4304.   proper support of these options Kermit must wait for the negotiations to
  4305.   complete.  Of course, Kermit has no way of knowing whether a reply is
  4306.   delayed or not coming at all, and so will wait a minute or more for
  4307.   required replies before continuing the session.  If you know that Kermit's
  4308.   Telnet partner will not be sending the required replies, you can set this
  4309.   option of OFF to avoid the long timeouts.  Or you can instruct Kermit to
  4310.   REFUSE specific options with the SET TELOPT command.
  4311.  
  4312. SET TELOPT [ { /CLIENT, /SERVER } ] <option> -
  4313.     { ACCEPTED, REFUSED, REQUESTED, REQUIRED } -
  4314.     [ { ACCEPTED, REFUSED, REQUESTED, REQUIRED } ]
  4315.   SET TELOPT lets you specify policy requirements for Kermit's handling of
  4316.   Telnet option negotiations.  Setting an option is REQUIRED causes Kermit
  4317.   to offer the option to the peer and disconnect if the option is refused.
  4318.   REQUESTED causes Kermit to offer an option to the peer.  ACCEPTED results
  4319.   in no offer but Kermit will attempt to negotiate the option if it is
  4320.   requested.  REFUSED instructs Kermit to refuse the option if it is
  4321.   requested by the peer.
  4322.  
  4323.   Some options are negotiated in two directions and accept separate policies
  4324.   for each direction; the first keyword applies to Kermit itself, the second
  4325.   applies to Kermit's Telnet partner; if the second keyword is omitted, an
  4326.   appropriate (option-specific) default is applied.  You can also include a
  4327.   /CLIENT or /SERVER switch to indicate whether the given policies apply
  4328.   when Kermit is the Telnet client or the Telnet server; if no switch is
  4329.   given, the command applies to the client.
  4330.  
  4331.   Note that some of Kermit's Telnet partners fail to refuse options that
  4332.   they do not recognize and instead do not respond at all.  In this case it
  4333.   is possible to use SET TELOPT to instruct Kermit to REFUSE the option
  4334.   before connecting to the problem host, thus skipping the problematic
  4335.   negotiation.
  4336.  
  4337.   Use SHOW TELOPT to view current Telnet Option negotiation settings.
  4338.   SHOW TELNET displays current Telnet settings.
  4339.  
  4340. 2.3.0. Bug Fixes
  4341.  
  4342. If "set host nonexistent-host" was given (and it properly failed), followed by
  4343. certain commands like SEND, the original line and modem type were not restored
  4344. and C-Kermit thought that it still had a network hostname; fixed in 7.0.
  4345.  
  4346. 2.3.1. Telnet Binary Mode Bug Adjustments
  4347.  
  4348. SET TELNET BUG BINARY-ME-MEANS-U-TOO { ON, OFF } was added to edit 192
  4349. after the book was printed.  Also SET TELNET BUG BINARY-U-MEANS-ME-TOO.
  4350. The default for both is OFF.  ON should be used when communicating with a
  4351. Telnet partner (client or server) that mistakenly believes that telling
  4352. C-Kermit to enter Telnet binary mode also means that it, too, is in binary
  4353. mode, contrary to the Telnet specification, which says that binary mode must
  4354. be negotiated in each direction separately.
  4355.  
  4356. 2.3.2. VMS UCX Telnet Port Bug Adjustment
  4357.  
  4358. A new command, SET TCP UCX-PORT-BUG, was added for VMS versions with UCX (DEC
  4359. TCP/IP), applying only to early versions of UCX, like 2.2 or earlier.  If you
  4360. try to use VMS C-Kermit to make a Telnet connection using a port name (like
  4361. "telnet", which is used by default), the underlying UCX getservbyname()
  4362. function might return the service number with its bytes swapped and the
  4363. connection will fail.  If "telnet hostname 23" works, then your version of UCX
  4364. has this bug and you can put "set tcp ucx-port-bug on" in your CKERMIT.INI
  4365. file to get around it.
  4366.  
  4367. 2.3.3. Telnet New Environment Option
  4368.  
  4369. The TELNET NEW-ENVIRONMENT option (RFC1572) is supported as 7.0.  This option
  4370. allows the C-Kermit Telnet client to send certain well-known variables to the
  4371. Telnet server, including USER, PRINTER, DISPLAY, and several others.  This
  4372. feature is enabled by default in Windows and OS/2, disabled by default
  4373. elsewhere.  The command to enable and disable it is:
  4374.  
  4375.   SET TELNET ENVIRONMENT { ON, OFF }
  4376.  
  4377. When ON, and you Telnet to another computer, you might (or might not) notice
  4378. that the "login:" or "Username:" prompt does not appear -- that's because your
  4379. username was sent ahead, in which case the remote system might prompt you only
  4380. for your password (similar to Rlogin).  Use "set telnet environment off" to
  4381. defeat this feature, particularly in scripts where the dialog must be
  4382. predictable.  You can also use this command to specify or override specific
  4383. well-known environment variable values:
  4384.  
  4385.  SET TELNET ENVIRONMENT { ACCT,DISPLAY,JOB,PRINTER,SYSTEMTYPE,USER } [ <text> ]
  4386.  
  4387. 2.3.4. Telnet Location Option
  4388.  
  4389. The TELNET LOCATION option (RFC779) is supported in 7.0.  This option allows
  4390. the C-Kermit Telnet client to send a location string to the server if the
  4391. server indicates its willingness to accept one.  If an environment variable
  4392. named LOCATION exists at the time C-Kermit starts, its value is used as the
  4393. location string.  If you want to change it, use:
  4394.  
  4395.   SET TELNET LOCATION <text>
  4396.  
  4397. If you omit the <text> from this command, the Telnet location feature is
  4398. disabled.
  4399.  
  4400. SET TELNET ENVIRONMENT DISPLAY is used to set the DISPLAY variable that is
  4401. sent to the host, as well as the the XDISPLAY location.
  4402.  
  4403. 2.3.5. Connecting to Raw TCP Sockets
  4404.  
  4405. The SET HOST and TELNET commands now accept an optional switch, /RAW-SOCKET,
  4406. at the end, only if you first give a host and a port.  Example:
  4407.  
  4408.   set host xyzcorp.com 23 /raw-socket
  4409.   set host 128.49.39.2:2000 /raw-socket
  4410.   telnet xyzcorp.com 3000 /raw
  4411.  
  4412. Without this switch, C-Kermit behaves as a Telnet client when (a) the port is
  4413. 23 or 1649, or (b) the port is not 513 and the server sent what appeared to be
  4414. Telnet negotiations -- that is, messages starting with 0xFF (IAC).  With this
  4415. switch, Kermit should treat all incoming bytes as raw data, and will not
  4416. engage in any Telnet negotiations or NVT CRLF manipulations.  This allows
  4417. transparent operation through (e.g.) raw TCP ports on Cisco terminal servers,
  4418. through the 'modemd' modem server, etc.
  4419.  
  4420. 2.3.6. Incoming TCP Connections
  4421.  
  4422. Accomplished via SET HOST * <port>, were introduced in C-Kermit 6.0, but for
  4423. UNIX only.  In Version 7.0, they are also available for VMS.
  4424.  
  4425. 2.4. The EIGHTBIT Command
  4426.  
  4427. EIGHTBIT is simply a shorthand for: SET PARITY NONE, SET TERMINAL BYTESIZE 8,
  4428. SET COMMAND BYTESIZE 8; that is, a way to set up an 8-bit clean connection
  4429. in a single command.
  4430.  
  4431. 2.5. The Services Directory
  4432.  
  4433. Chapter 7 of "Using C-Kermit" does not mention the ULOGIN macro, which is
  4434. used by our sample services directory, CKERMIT.KND.  Unlike UNIXLOGIN,
  4435. VMSLOGIN, etc, this one is for use with systems that require a user ID but
  4436. no password.  Therefore it doesn't prompt for a password or wait for a
  4437. password prompt from the remote service.
  4438.  
  4439. In version 7.0, the CALL macro was changed to not execute a SET MODEM TYPE
  4440. command if the given modem type was the same as the current one; otherwise the
  4441. new SET MODEM TYPE command would overwrite any customizations that the user
  4442. had made to the modem settings.  Ditto for SET LINE / SET PORT and SET SPEED.
  4443.  
  4444. 2.6. Closing Connections
  4445.  
  4446. Until version 7.0, there was never an obvious and general way to close a
  4447. connection.  If a serial connection was open, it could be closed by "set
  4448. line" or "set port" (giving no device name); if a network connection was
  4449. open, it could be closed by "set host" (no host name).
  4450.  
  4451. In version 7.0, a new command closes the connection in an obvious and
  4452. straightforward way, no matter what the connection type:
  4453.  
  4454.   CLOSE [ CONNECTION ]
  4455.  
  4456. The CLOSE command was already present, and required an operand such as
  4457. DEBUG-LOG, WRITE-FILE, etc, and so could never be given by itself.  The new
  4458. CONNECTION operand is now the default operand for CLOSE, so CLOSE by itself
  4459. closes the connection, if one is open, just as you would expect, especially
  4460. if you are a Telnet or Ftp user.
  4461.  
  4462. Also see the description of the new SET CLOSE-ON-DISCONNECT command in
  4463. Section 2.10.
  4464.  
  4465. 2.7. Using C-Kermit with External Communication Programs
  4466.  
  4467. C-Kermit 7.0 includes a new ability to create and conduct sessions through
  4468. other communications programs.  Two methods are available:
  4469.  
  4470.  a. Pty (pseudoterminal): The external program is run on a "pseudoterminal",
  4471.     which is controlled by Kermit.  This method works with practically any
  4472.     external program, but it is not portable.  At this writing, it works only
  4473.     on some (not all) UNIX versions, and not on any non-UNIX platforms.
  4474.  
  4475.  b. Pipe: The external program's standard input and output are redirected
  4476.     through a "pipe" controlled by Kermit.  This method is relatively
  4477.     portable -- it should work across all UNIX versions, and it also works
  4478.     in Windows and OS/2 -- but it is effective only when the external
  4479.     program actually uses standard i/o (and many don't).
  4480.  
  4481. The two methods are started differently but are used the same way thereafter.
  4482.  
  4483. The purpose of this feature is to let you use C-Kermit services like file
  4484. transfer, character-set translation, scripting, automatic dialing, etc, on
  4485. connections that Kermit can't otherwise make itself.
  4486.  
  4487. This feature is the opposite of the REDIRECT feature, in which C-Kermit makes
  4488. the connection, and redirects an external (local) command or program over this
  4489. connection.  In a pty or pipe connection, C-Kermit runs and controls a local
  4490. command or program, which makes the connection.  (The same method can be used
  4491. to simply to control a local program without making a connection; see Section
  4492. 2.8.)
  4493.  
  4494. To find out if your version of Kermit includes PTY support, type "show
  4495. features" and look for NETPTY in the alphabetical list of options.  For pipes,
  4496. look for NETCMD.
  4497.  
  4498. The commands are:
  4499.  
  4500.   SET NETWORK TYPE PTY  or  SET NETWORK TYPE PIPE
  4501.   SET HOST <command>
  4502.  
  4503. where <command> is any interactive command.  If the command does not use
  4504. standard i/o, you must use SET NETWORK TYPE PTY.
  4505.  
  4506. Notes:
  4507.  
  4508.  a. COMMAND is an invisible synonym for PIPE.
  4509.  b. The <command> and its arguments are case-sensitive in UNIX.
  4510.  
  4511. The SET NETWORK TYPE, SET HOST sequence sets the given network type for all
  4512. subsequent SET HOST commands until another SET NETWORK TYPE command is given
  4513. to change it.
  4514.  
  4515. You can also use the new /NETWORK-TYPE:PTY or /NETWORK-TYPE:PIPE (or simply
  4516. /PIPE or /PTY) switches on the SET HOST command itself:
  4517.  
  4518.   SET HOST /NETWORK-TYPE:PIPE <command>  ; These two are the same
  4519.   SET HOST /PIPE <command>
  4520.  
  4521.   SET HOST /NETWORK-TYPE:PTY <command>   ; Ditto
  4522.   SET HOST /PTY <command>
  4523.  
  4524. These are like SET NETWORK TYPE followed by SET HOST, except they apply only
  4525. to the connection being made and do not change the global network type setting
  4526. (see Section 1.5 about the difference between switches and SET commands).
  4527.  
  4528. Include any command-line options with the <command> that might be needed, as
  4529. in this example where C-Kermit uses another copy of itself as the
  4530. communications program:
  4531.  
  4532.   SET HOST /PIPE /CONNECT kermit -YQJ xyzcorp.com
  4533.  
  4534. As usual, if you include the /CONNECT switch, SET HOST enters CONNECT mode
  4535. immediately upon successful execution of the given command.  Therefore a new
  4536. command is available as a shorthand for SET HOST /CONNECT /PTY:
  4537.  
  4538.   PTY [ <command> ]
  4539.  
  4540. And for SET HOST /CONNECT /PIPE:
  4541.  
  4542.   PIPE [ <command> ]
  4543.  
  4544. Thus, the PTY and PIPE commands work like the TELNET and RLOGIN commands: they
  4545. set up the connection (in this case, using the given command) and then enter
  4546. CONNECT mode automatically (if the PIPE or PTY command is given without a
  4547. <command>, it continues the current session if one is active; otherwise it
  4548. gives an error message).
  4549.  
  4550. The PIPE command is named after the mechanism by which C-Kermit communicates
  4551. with the <command>: UNIX pipes.  C-Kermit's i/o is "piped" through the given
  4552. command.  Here is a typical example:
  4553.  
  4554.   PIPE rlogin -8 xyzcorp.com
  4555.  
  4556. This is equivalent to:
  4557.  
  4558.   SET HOST /PIPE rlogin -8 xyzcorp.com
  4559.   CONNECT
  4560.  
  4561. and to:
  4562.  
  4563.   SET HOST /PIPE /CONNECT rlogin -8 xyzcorp.com
  4564.  
  4565. IMPORTANT:
  4566.   If you are writing a script, do not use the PIPE, PTY, TELNET, or RLOGIN
  4567.   command unless you really want C-Kermit to enter CONNECT mode at that
  4568.   point.  Normally SET HOST is used in scripts to allow the login and
  4569.   other dialogs to be controlled by the script itself, rather than by
  4570.   an actively participating human at the keyboard.
  4571.  
  4572. Throughput of pty and pipe connections is limited by the performance of the
  4573. chosen command or program and by the interprocess communication (IPC) method
  4574. used and/or buffering capacity of the pipe or pty, which in turn depends on
  4575. the underlying operating system.
  4576.  
  4577. In one trial (on SunOS 4.1.3), we observed file transfer rates over an rlogin
  4578. connection proceeding at 200Kcps for downloads, but only 10Kcps for uploads on
  4579. the same connection with the same settings (similar disparities were noted in
  4580. HP-UX).  Examination of the logs revealed that a write to the pipe could take
  4581. as long as 5 seconds, whereas reads were practically instantaneous.  On the
  4582. other hand, using Telnet as the external program rather than rlogin, downloads
  4583. and uploads were better matched at about 177K each.
  4584.  
  4585. Most external communication programs, like C-Kermit itself, have escape
  4586. characters or sequences.  Normally these begin with (or consist entirely of) a
  4587. control character.  You must be sure that this control character is not
  4588. "unprefixed" when uploading files, otherwise the external program will "escape
  4589. back" to its prompt, or close the connection, or take some other unwanted
  4590. action.  When in CONNECT mode, observe the program's normal interaction rules.
  4591. Of course C-Kermit's own escape character (normally Ctrl-\) is active too,
  4592. unless you have taken some action to disable it.
  4593.  
  4594. On PTY connections, the underlying PTY driver is not guaranteed to be
  4595. transparent to contol characters -- for example, it might expand tabs,
  4596. translate carriage returns, generate signals if it sees an interrupt
  4597. character, and so on.  Similar things might happen on a PIPE connection.  For
  4598. this reason, if you plan to transfer files over a PTY or PIPE connection, tell
  4599. the file sender to:
  4600.  
  4601.   SET PREFIXING ALL
  4602.     This causes all control chracters to be prefixed and transmitted
  4603.     as printable ASCII characters.
  4604.  
  4605. If the external connection program is not 8-bit clean, you should also:
  4606.  
  4607.   SET PARITY SPACE
  4608.     This causes 8-bit data to be encoded in 7 bits using single and/or
  4609.     locking shifts.
  4610.  
  4611. And if it does not make a reliable connection (such as those made by Telnet,
  4612. Rlogin, Ssh, etc), you should:
  4613.  
  4614.   SET STREAMING OFF
  4615.     This forces C-Kermit to treat the connection as unreliable and
  4616.     to engage in its normal ACK/NAK protocol for error detection and
  4617.     correction, rather than "streaming" its packets, as it normally
  4618.     does on a network connection (Section 4.20).
  4619.  
  4620. In some cases, buffer sizes might be restricted, so you might also need to
  4621. reduce the Kermit packet length to fit; this is a trial-and-error affair.  For
  4622. example, if transfers always fail with 4000-byte packets, try 2000.  If that
  4623. fails too, try 1000, and so on.  The commands are:
  4624.  
  4625.   SET RECEIVE PACKET-LENGTH <number>
  4626.     This tells the file receiver to tell the file sender the longest
  4627.     packet length it can accept.
  4628.  
  4629.   SET SEND PACKET-LENGTH <number>
  4630.     This tells the file sender not to send packets longer than the given
  4631.     length, even if the receiver says longer ones are OK.  Of course, if
  4632.     the receiver's length is shorter, the shorter length is used.
  4633.  
  4634. If none of this seems to help, try falling back to the bare minimum,
  4635. lowest-common-denominator protocol settings:
  4636.  
  4637.   ROBUST
  4638.     No sliding windows, no streaming, no control-character unprefixing,
  4639.     packet length 90.
  4640.  
  4641. And then work your way back up by trial and error to get greater throughput.
  4642.  
  4643. Note that when starting a PIPE connection, and the connection program (such as
  4644. telnet or rlogin) prints some greeting or information messages before starting
  4645. the connection, these are quite likely to be printed with a stairstep effect
  4646. (linefeed without carriage return).  This is because the program is not
  4647. connected with the UNIX terminal driver; there's not much Kermit can do about
  4648. it.  Once the connection is made, everything should go back to normal.  This
  4649. shouldn't happen on a PTY connection because a PTY is, indeed, a terminal.
  4650.  
  4651. On a similar note, some connection programs (like Solaris 2.5 rlogin) might
  4652. print lots of error messages like "ioctl TIOCGETP: invalid argument" when
  4653. used through a pipe.  They are annoying but usually harmless.  If you want to
  4654. avoid these messages, and your shell allows redirection of stderr, you can
  4655. redirect stderr in your pipe command, as in this example where the user's
  4656. shell is bash:
  4657.  
  4658.   PIPE rlogin xyzcorp.com 2> /dev/null
  4659.  
  4660. Or use PTY rather than PIPE, since PTY is available on Solaris.
  4661.  
  4662. 2.7.0. C-Kermit over tn3270 and tn5250
  4663.  
  4664. Now you can make a connection from C-Kermit "directly" to an IBM mainframe and
  4665. transfer files with it, assuming it has Kermit-370 installed.  Because tn3270
  4666. is neither 8-bit clean nor transparent to control characters, you must give
  4667. these commands:
  4668.  
  4669.   SET PREFIXING ALL   ; Prefix all control characters
  4670.   SET PARITY SPACE    ; Telnet connections are usually not 8-bit clean
  4671.  
  4672. and then:
  4673.  
  4674.   SET HOST /PTY /CONNECT tn3270 abccorp.com
  4675.  
  4676. or simply:
  4677.  
  4678.   pty tn3270 abccorp.com
  4679.  
  4680. SET HOST /PIPE does not work in this case, at least not for file transfer.
  4681. File transfer does work, however, with SET HOST /PTY, provided you use the
  4682. default packet length of 90 bytes; anything longer seems to kill the session.
  4683.  
  4684. You can also make connections to IBM AS/400 computers if you have a tn5250
  4685. program installed:
  4686.  
  4687.   pty tn5250 <hostname>
  4688.  
  4689. In this case, however, file transfer is probably not in the cards since
  4690. nobody has ever succeeded in writing a Kermit program for the AS/400.
  4691.  
  4692. Hint:
  4693.  
  4694.   define tn3270 {
  4695.       check pty
  4696.       if fail end 1 Sorry - no PTY support...
  4697.       pty tn3270 \%*
  4698.  
  4699.   }
  4700.  
  4701. Similarly for tn5250.  Note that CHECK PTY and CHECK PIPE can be used in
  4702. macros and scripts to test whether PTY or PIPE support is available.
  4703.  
  4704. 2.7.1. C-Kermit over Telnet
  4705.  
  4706. Although C-Kermit includes its own Telnet implementation, you might need to
  4707. use an external Telnet program to make certain connections; perhaps because it
  4708. has access or security features not available in C-Kermit itself.  As noted
  4709. above, the only precautions necessary are usually:
  4710.  
  4711.   SET PREFIXING ALL   ; Prefix all control characters
  4712.   SET PARITY SPACE    ; Telnet connections might not be 8-bit clean
  4713.  
  4714. and then:
  4715.  
  4716.   SET HOST /PTY (or /PIPE) /CONNECT telnet abccorp.com
  4717.  
  4718. or, equivalently:
  4719.  
  4720.   PTY (or PIPE) telnet abccorp.com
  4721.  
  4722. 2.7.2. C-Kermit over Rlogin
  4723.  
  4724. C-Kermit includes its own Rlogin client, but this can normally be used only if
  4725. you are root, since the rlogin TCP port is privileged.  But ptys and pipes let
  4726. you make rlogin connections with C-Kermit through your computer's external
  4727. rlogin program, which is normally installed as a privileged program:
  4728.  
  4729.   SET PREFIXING ALL
  4730.  
  4731. and then:
  4732.  
  4733.   SET HOST /PTY (or /PIPE) /CONNECT rlogin -8 abccorp.com
  4734.  
  4735. or, equivalently:
  4736.  
  4737.   PTY (or PIPE) rlogin -8 abccorp.com
  4738.  
  4739. The "-8" option to rlogin enables transmission of 8-bit data.  If this is
  4740. not available, then include SET PARITY SPACE if you intend to transfer files.
  4741.  
  4742. Note that the normal escape sequence for rlogin is Carriage Return followed by
  4743. Tilde (~), but only when the tilde is followed by certain other characters;
  4744. the exact behavior depends on your rlogin client, so read its documentation.
  4745.  
  4746. 2.7.3. C-Kermit over Serial Communication Programs
  4747.  
  4748. Ptys and pipes also let you use programs that make serial connections, such as
  4749. cu or tip.  For example, C-Kermit can be used through cu to make connections
  4750. that otherwise might not be allowed, e.g. because C-Kermit is not installed
  4751. with the required write permissions to the dialout device and the UUCP
  4752. lockfile directory.
  4753.  
  4754. Suppose your UUCP Devices file contains an entry for a serial device tty04 to
  4755. be used for direct connections, but this device is protected against you (and
  4756. Kermit when you run it).  In this case you can:
  4757.  
  4758.   SET CONTROL PREFIX ALL
  4759.   PTY (or PIPE) cu -l tty04
  4760.  
  4761. (Similarly for dialout devices, except then you also need to include the phone
  4762. number in the "cu" command.)
  4763.  
  4764. As with other communication programs, watch out for cu's escape sequence,
  4765. which is the same as the rlogin program's: Carriage Return followed by Tilde
  4766. (followed by another character to specify an action, like "." for closing the
  4767. connection and exiting from cu).
  4768.  
  4769. 2.7.4. C-Kermit over Secure Network Clients
  4770.  
  4771.   DISCLAIMER: There are laws in the USA and other countries regarding
  4772.   use, import, and/or export of encryption and/or decryption or other
  4773.   forms of security software, algorithms, technology, and intellectual
  4774.   property.  The Kermit Project attempts to follow all known statutes,
  4775.   and neither intends nor suggests that Kermit software can or should
  4776.   be used in any way, in any location, that circumvents any regulations,
  4777.   laws, treaties, covenants, or other legitimate canons or instruments
  4778.   of law, international relations, trade, ethics, or propriety.
  4779.  
  4780. For secure connections or connections through firewalls, C-Kermit 7.0 can be a
  4781. Kerberos, SRP, and/or SOCKS client when built with the appropriate options and
  4782. libraries.  But other application-level security acronyms and methods -- SSH,
  4783. SSL, SRP, TLS -- pop up at an alarming rate and are (a) impossible to keep up
  4784. with, (b) usually mutually incompatible, and (c) have restrictions on export
  4785. or redistribution and so cannot be included in C-Kermit itself.
  4786.  
  4787. However, if you have a secure text-based Telnet (or other) client that employs
  4788. one of these security methods, you can use C-Kermit "through" it via a pty
  4789. or pipe.
  4790.  
  4791. 2.7.4.1. SSH
  4792.  
  4793. C-Kermit does not and can not incorporate SSH due to licensing, patent,
  4794. and USA export law restrictions.
  4795.  
  4796. The UNIX SSH client does not use standard input/output, and therefore can be
  4797. used only by Kermit's PTY interface, if one is present.  The cautions about
  4798. file transfer, etc, are the same as for Rlogin.  Example:
  4799.  
  4800.   SET PREFIXING ALL
  4801.   PTY ssh XYZCORP.COM
  4802.  
  4803. Or, for a scripted session:
  4804.  
  4805.   SET PREFIXING ALL
  4806.   SET HOST /PTY ssh XYZCORP.COM
  4807.  
  4808. Hint:
  4809.  
  4810.   define ssh {
  4811.       check pty
  4812.       if fail end 1 Sorry - no PTY support...
  4813.       pty ssh \%*
  4814.   }
  4815.  
  4816. 2.7.4.2. SSL
  4817.  
  4818. Secure Sockets Layer (SSL) is another TCP/IP security overlay, this one
  4819. designed by and for Netscape.  An SSL Telnet client is available for UNIX
  4820. from the University of Queensland.  More info at:
  4821.  
  4822.   http://www.psy.uq.oz.au/~ftp/Crypto/
  4823.  
  4824. Interoperability with C-Kermit is unknown.  C-Kermit also includes its own
  4825. built-in SSL/TLS support, but it is not exportable; see the C-Kermit
  4826. security.txt file for details.
  4827.  
  4828. 2.7.4.3. SRP
  4829.  
  4830. SRP(TM) is Stanford University's Secure Remote Password protocol.  An SRP
  4831. Telnet client is available from Stanford:
  4832.  
  4833.   http://srp.stanford.edu/srp/
  4834.  
  4835. Stanford's SRP Telnet client for UNIX has been tested on SunOS and works fine
  4836. with C-Kermit, as described in Section 2.7.1, e.g.
  4837.  
  4838.   SET PREFIX ALL
  4839.   PTY (or PIPE) srp-telnet xenon.stanford.edu
  4840.  
  4841. C-Kermit itself can be built as an SRP Telnet client on systems that have
  4842. libsrp.a installed; the C-Kermit support code, however, may not be exported
  4843. outside the USA or Canada.
  4844.  
  4845. 2.7.4.4. SOCKS
  4846.  
  4847. C-Kermit can be built as a SOCKS-aware client on systems that have a SOCKS
  4848. library.  See section 8.1.1 of the ckccfg.txt file.
  4849.  
  4850. C-Kermit 7.0 can also be run over SOCKSified Telnet or rlogin clients with SET
  4851. NETWORK TYPE COMMAND.  Suppose the Telnet program on your system is SOCKS
  4852. enabled but C-Kermit is not.  Make Kermit connections like this:
  4853.  
  4854.   SET PREFIX ALL
  4855.   PTY (or PIPE) telnet zzz.com
  4856.  
  4857. 2.7.4.5. Kerberos
  4858.  
  4859. UNIX C-Kermit can be built with MIT Kerberos IV or V authentication and
  4860. encryption.  Instructions are available in a separate document, security.txt.
  4861. Additional modules are required that can not be exported from the USA to any
  4862. country except Canada, by US law.
  4863.  
  4864. If you have Kerberos installed but you don't have a Kerberized version of
  4865. C-Kermit, you can use ktelnet as C-Kermit's external communications program
  4866. to make secure connections without giving up C-Kermit's services:
  4867.  
  4868.   SET PREFIX ALL
  4869.   PTY (or PIPE) ktelnet cia.gov
  4870.  
  4871. 2.8. Scripting Local Programs
  4872.  
  4873. If your version of Kermit has PTY support built in, then any text-based
  4874. program can be invoked with SET HOST /PTY or equivalent command and controlled
  4875. using the normal sequence of OUTPUT, INPUT, IF SUCCESS commands (this is the
  4876. same service that is provided by the 'expect' program, but controlled by the
  4877. Kermit script language rather than Tcl).
  4878.  
  4879. When PTY service is not available, then any program that uses standard input
  4880. and output can be invoked with SET HOST /PIPE.
  4881.  
  4882. Here's an example in which we start an external Kermit program, wait for its
  4883. prompt, give it a VERSION command, and then extract the numeric version number
  4884. from its response:
  4885.  
  4886.   set host /pty kermit -Y
  4887.   if fail stop 1 {Can't start external command}
  4888.   input 10 C-Kermit>
  4889.   if fail stop 1 {No C-Kermit> prompt}
  4890.   output version\13
  4891.   input 10 {Numeric: }
  4892.   if fail stop 1 {No match for "Numeric:"}
  4893.   clear input
  4894.   input 10 \10
  4895.   echo VERSION = "\fsubstr(\v(input),1,6)"
  4896.   output exit\13
  4897.  
  4898. This technique could be used to control any other interactive program, even
  4899. those that do screen formatting (like Emacs or Vi), if you can figure out the
  4900. sequence of events.  If your Kermit program doesn't have PTY support, then the
  4901. commands are restricted to those using standard i/o, including certain shells,
  4902. interactive text-mode "hardcopy" editors like ex, and so on.
  4903.  
  4904. If you are using the PTY interface, you should be aware that it runs the
  4905. given program or command directly on the pty, without any intervening shell
  4906. to interpret metacharacters, redirectors, etc.  If you need this sort of
  4907. thing, include the appropriate shell invocation as part of your command; for
  4908. example:
  4909.  
  4910.   pty echo *
  4911.  
  4912. just echoes "*"; whereas:
  4913.  
  4914.   pty ksh -c "echo *"
  4915.  
  4916. echoes all the filenames that ksh finds matching "*".
  4917.  
  4918. Similarly for redirection:
  4919.  
  4920.   set host /pty ksh -c "cat > foo"  ; Note: use shell quoting rules here
  4921.   set transmit eof \4
  4922.   transmit bar
  4923.  
  4924. And for that matter, for built-in shell commands:
  4925.  
  4926.   set host /pty ksh -c "for i in *; do echo $i; done"
  4927.  
  4928. The PIPE interface, on the other hand, invokes the shell automatically, so:
  4929.  
  4930.   pipe echo *
  4931.  
  4932. prints filenames, not "*".
  4933.  
  4934. 2.9. X.25 Networking
  4935.  
  4936. X.25 networking is documented in "Using C-Kermit", 2nd Edition.  When the book
  4937. was published, X.25 was available only in SunOS, Solaris, and Stratus VOS.
  4938. Unlike TCP/IP, X.25 APIs are not standardized; each vendor's X.25 libraries
  4939. and services (if they have them at all) are unique.
  4940.  
  4941. This section describes new additions.
  4942.  
  4943. 2.9.1. IBM AIXLink/X.25 Network Provider Interface for AIX
  4944.  
  4945. Support for X.25 was added via IBM's Network Provider Interface (NPI),
  4946. AIXLink/X.25 1.1, to the AIX 4.x version of C-Kermit 7.0.  Unfortunately,
  4947. AIXLink/X.25 is a rather bare-bones facility, lacking in particular any form
  4948. of PAD support (X.3, X.28, X.29).  Thus, the AIX version of C-Kermit, when
  4949. built to include X.25 networking, has neither a PAD command, nor a SET PAD
  4950. command.  The same is true for the underlying AIX system: no PAD support.
  4951. Thus it is not possible to have an interactive shell session over an X.25
  4952. connection into an AIX system (as far as we know), even from X.25-capable
  4953. Kermit versions (such as Solaris or VOS) that do include PAD support.
  4954.  
  4955. Thus the X.25 capabilities in AIX C-Kermit are limited to peer-to-peer
  4956. connections, e.g. from a C-Kermit client to a C-Kermit server.  Unlike the
  4957. Solaris, SunOS, and VOS versions, the AIX version can accept incoming X.25
  4958. connections:
  4959.  
  4960.   set network type x.25
  4961.   if fail stop 1 Sorry - no X.25 support
  4962.   ; Put any desired DISABLE or ENABLE or SET commands here.
  4963.   set host /server *
  4964.   if fail stop 1 X.25 "set host *" failed
  4965.  
  4966. And then access it from the client as follows:
  4967.  
  4968.   set network type x.25
  4969.   if fail stop 1 Sorry - no X.25 support
  4970.   set host xxxxxxx ; Specify the X.25/X.121 address
  4971.   if fail stop 1 Can't open connection
  4972.  
  4973. And at this point the client can use the full range of client commands:
  4974. SEND, GET, REMOTE xxx, FINISH, BYE.
  4975.  
  4976. The AIX version also adds two new variables:
  4977.  
  4978.   \v(x25local_nua)   The local X.25 address.
  4979.   \v(x25remote_nua)  The X.25 address of the host on the other end
  4980.                      of the connection.
  4981.  
  4982. C-Kermit's AIX X.25 client has not been tested against anything other than
  4983. a C-Kermit X.25 server on AIX.  It is not known if it will interoperate with
  4984. C-Kermit servers on Solaris, SunOS, or VOS.
  4985.  
  4986. To make an X.25 connection from AIX C-Kermit, you must:
  4987.  
  4988.   set x25 call-user-data xxxx
  4989.  
  4990. where xxxx can be any even-length string of hexadecimal digits, e.g. 123ABC.
  4991.  
  4992. 2.9.2. HP-UX X.25
  4993.  
  4994. Although C-Kermit presently does not include built-in support for HP-UX X.25,
  4995. it can still be used to make X.25 connections as follows: start Kermit and
  4996. tell it to:
  4997.  
  4998.   set prefixing all
  4999.   set parity space
  5000.   pty padem <address>
  5001.  
  5002. This should work in HP-UX 9.00 and later (see Section 2.7).  If you have an
  5003. earlier HP-UX version, or the PTY interface doesn't work or isn't available,
  5004. try:
  5005.  
  5006.   set prefixing all
  5007.   set parity space
  5008.   pipe padem <address>
  5009.  
  5010. Failing that, use Kermit to telnet to localhost and then after logging back
  5011. in, start padem as you would normally do to connect over X.25.
  5012.  
  5013. 2.10. Additional Serial Port Controls
  5014.  
  5015. C-Kermit 7.0 adds the following commands for greater control over serial
  5016. ports.  These commands are available only in C-Kermit versions whose
  5017. underlying operating systems provide the corresponding services (such as
  5018. POSIX and UNIX System V), and even then their successful operation depends
  5019. on the capabilities of the specific device and driver.
  5020.  
  5021. SET DISCONNECT { ON, OFF }
  5022.   On a SET LINE or SET PORT connection with SET CARRIER ON or AUTO, if
  5023.   the carrier signal drops during the connection, indicating that the
  5024.   connection has been lost, and C-Kermit notices it, this setting governs
  5025.   what happens next.  With SET DISCONNECT OFF, which is consistent with
  5026.   previous behavior, and therefore the default, C-Kermit continues to keep the
  5027.   device open and allocated.  With SET DISCONNECT ON, C-Kermit automatically
  5028.   closes and releases the device when it senses a carrier on-to-off
  5029.   transition, thus allowing others to use it.  However, it remains the default
  5030.   device for i/o (DIAL, REDIAL, INPUT, SEND, CONNECT, etc), so if a subsequent
  5031.   i/o command is given, the device is reopened if it is still available.  When
  5032.   it has been automatically closed in this manner, SHOW COMMUNICATIONS puts
  5033.   "(closed)" after its name, and in UNIX, the lockfile disappears -- both from
  5034.   SHOW COMM and from the lockfile directory itself.  Synonym:
  5035.   SET CLOSE-ON-DISCONNECT.
  5036.  
  5037. SET EXIT ON-DISCONNECT { ON, OFF }
  5038.   Like DISCONNECT, but makes the program exit if a connection drops.
  5039.  
  5040. Note that SET CLOSE-ON-DISCONNECT and SET EXIT ON-DISCONNECT apply only to
  5041. connections that drop; they do not apply to connections that can't be made
  5042. in the first place.  For example, they have no effect when a SET LINE,
  5043. SET HOST, TELNET, or DIAL command fails.
  5044.  
  5045. HANGUP
  5046.   If [CLOSE-ON-]DISCONNECT is ON, and the HANGUP command is given on a serial
  5047.   device, and the carrier signal is no longer present after the HANGUP
  5048.   command, the device is closed and released.
  5049.  
  5050. SET PARITY HARDWARE { EVEN, ODD }
  5051.   Unlike SET PARITY { EVEN, ODD, MARK, SPACE }, which selects 7 data bits
  5052.   plus the indicated kind of parity (to be done in software by Kermit itself),
  5053.   SET PARITY HARDWARE selects 8 data bits plus even or odd parity, to be done
  5054.   by the underlying hardware, operating system, or device driver.  This
  5055.   command is effective only with a SET LINE or SET PORT device.  That is, it
  5056.   has no effect in remote mode, nor on network connections.  There is
  5057.   presently no method for selecting 8 data bits plus mark or space parity.
  5058.   If hardware parity is in effect, the variable \v(hwparity) is set to
  5059.   "even" or "odd".  Note: some platforms might also support settings of
  5060.   SPACE, MARK, or NONE.
  5061.  
  5062. SET STOP-BITS { 1, 2 }
  5063.   This tells the number of 1-bits to insert after an outbound character's
  5064.   data and parity bits, to separate it from the next character.  Normally 1.
  5065.   Choosing 2 stop bits should do no harm, but will slow down serial
  5066.   transmission by approximately 10 percent.  Historically, 2 stop bits were
  5067.   used with Teletypes (at 110 bps or below) for print-head recovery time.
  5068.   There is presently no method for choosing any number of stop bits besides
  5069.   1 and 2.
  5070.  
  5071. SET SERIAL [ <dps> ]
  5072.   <dps> stands for Data-bits, Parity, Stop-bits.  This is the notation
  5073.   familiar to many people for serial port configuration: 7E1, 8N1, 7O2, etc.
  5074.   The data bits number also becomes the TERMINAL BYTESIZE setting.  The second
  5075.   character is E for Even, O for Odd, M for Mark, S for Space, or N for None.
  5076.   The list of available options depends on the capabilities of the specific
  5077.   platform.  If <dps> is omitted, 8N1 is used.  Type "set serial ?"  for a
  5078.   list of available choices.  Examples:
  5079.  
  5080.   SET SERIAL 7E1
  5081.     Equivalent to SET PARITY EVEN, SET STOP-BITS 1, SET TERM BYTE 7.
  5082.  
  5083.   SET SERIAL 8N1
  5084.     Equivalent to SET PARITY NONE, SET STOP-BITS 1, SET TERM BYTE 8.
  5085.  
  5086.   SET SERIAL 7E2
  5087.     Equivalent to SET PARITY EVEN and SET STOP-BITS 2, SET TERM BYTE 7.
  5088.  
  5089.   SET SERIAL 8E2
  5090.     Same as SET PARITY HARDWARE EVEN, SET STOP-BITS 2, SET TERM BYTE 8.
  5091.  
  5092.   SET SERIAL
  5093.     Same as SET PARITY NONE and SET STOP-BITS 1, SET TERM BYTE 8.
  5094.  
  5095. Notes:
  5096.  
  5097.  . The SET SERIAL xx2 options are available only in Kermit versions where the
  5098.    SET PARITY HARDWARE command is also available.  (SHOW FEATURES includes
  5099.    "HWPARITY" in its options list.)
  5100.  
  5101.  . The SET SERIAL 7xx and 8N1 options affect the software parity setting, even
  5102.    for network connections.
  5103.  
  5104.  . As noted in the manual, selecting 8 data bits does not give you 8-bit
  5105.    terminal sessions in CONNECT mode unless you also SET TERMINAL BYTESIZE 8.
  5106.    The default terminal bytesize remains 7, to protect against the situation
  5107.    where the remote host is generating parity but you don't know about it.  If
  5108.    the terminal bytesize was 8 by default and you CONNECTed to such a host,
  5109.    you would see only garbage on your screen.
  5110.  
  5111.  . If you do not give a SET STOP-BITS or SET SET SERIAL command, C-Kermit
  5112.    does not attempt to set the device's stop bits; instead, it uses whatever
  5113.    setting the device uses when not given explicit instructions about stop
  5114.    bits.
  5115.  
  5116. SHOW COMMUNICATIONS displays the current settings.  Stop bits and hardware
  5117. parity are shown only for SET PORT / SET LINE (serial) devices, since they
  5118. do not apply to network connections or to remote mode.  STOP-BITS is shown
  5119. as "(default)" if you have not given an explicit SET STOP-BITS or SET SERIAL
  5120. command.
  5121.  
  5122. The \v(serial) variable shows the SET SERIAL setting (8N1, 7E1, etc).
  5123.  
  5124. 2.11. Getting Access to the Dialout Device
  5125.  
  5126.   This section is for UNIX only; note the special words about QNX
  5127.   at the end.  Also see Section 2.0 for SET LINE switches, particularly
  5128.   the /SHARE switch for VMS only.
  5129.  
  5130. C-Kermit does its best to obey the UUCP lockfile conventions of each platform
  5131. (machine, operating system, OS version) where it runs, if that platform uses
  5132. UUCP.
  5133.  
  5134. But simply obeying the conventions is often not good enough, due to the
  5135. increasing likelihood that a particular serial device might have more than one
  5136. name (e.g. /dev/tty00 and /dev/term/00 are the same device in Unixware 7;
  5137. /dev/cua and /dev/cufa are the same device in NeXTSTEP), plus the increasingly
  5138. widespread use of symlinks for device names, such as /dev/modem.
  5139.  
  5140. C-Kermit 7.0 goes to greater lengths than previous versions to successfully
  5141. interlock with other communications program (and other instances of Kermit
  5142. itself); for example, by:
  5143.  
  5144.  . Creation of dual lockfiles whenever a symlink is used; one for the link
  5145.    name and one for the "real" name as revealed by readlink().
  5146.  
  5147.  . Creation of dual lockfiles in HP-UX according to HP rules.
  5148.  
  5149.  . Creation of dual uppercase/lowercase lockfile names in SCO UNIX/ODT/OSR5.
  5150.  
  5151.  . The use of ttylock() in versions of AIX where it works.
  5152.  
  5153.  . The use, wherever possible, of lockfile names based on inode/major/minor
  5154.    device number rather than device name.
  5155.  
  5156. See the ckuins.txt and ckubwr.txt files for details.
  5157.  
  5158. QNX is almost unique among UNIX varieties in having no UUCP programs nor
  5159. UUCP-oriented dialout-device locking conventions.  QNX does, however, allow a
  5160. program to get the device open count.  This can not be a reliable form of
  5161. locking unless all applications do it (and they don't), so by default, Kermit
  5162. uses this information only for printing a warning message such as:
  5163.  
  5164.   C-Kermit>set line /dev/ser1
  5165.   WARNING - "/dev/ser1" looks busy...
  5166.  
  5167. However, if you want to use it as a lock, you can do so with:
  5168.  
  5169.   SET QNX-PORT-LOCK { ON, OFF }
  5170.  
  5171. QNX-PORT-LOCK is OFF by default; if you set in ON, C-Kermit fails to open
  5172. any dialout device when its open count indicates that another process has it
  5173. open.  SHOW COMM (in QNX only) displays the setting, and if you have a port
  5174. open, it also shows the current open count (with C-Kermit's own access
  5175. always counting as 1).
  5176.  
  5177. 2.12. The Connection Log
  5178.  
  5179. C-Kermit 7.0 adds the ability to log connections, so you can see where you've
  5180. been and have a record of calls you've made.  A connection is defined as any
  5181. communications session that is begun by SET LINE, SET PORT, DIAL, SET HOST,
  5182. TELNET, or RLOGIN.  Connections are not logged unless you request it; the
  5183. command is:
  5184.  
  5185. LOG CX [ filename [ { NEW, APPEND } ] ]
  5186.   Enables logging of connections in the given file.  If the trailing
  5187.   { NEW, APPEND } keyword is omitted, the file is opened for appending;
  5188.   i.e. new records are written to the end.  If NEW is specified, a new
  5189.   file is created; if a file of the same name already existed, it is
  5190.   overwritten.  If the filename is omitted, CX.LOG in your home (login)
  5191.   directory is used (note: uppercase).  To accept all defaults, just use
  5192.   "log connections" (or "l c" for short).  Synonym: LOG CONNECTIONS.
  5193.  
  5194. CLOSE CX-LOG
  5195.   This closes the connection log if it was open.  (Note, the CLOSE CONNECTION
  5196.   command closes the connection itself).
  5197.  
  5198. SHOW CX
  5199.   This shows your current connection, if any, including the elapsed time
  5200.   (since you opened it).  Synonym: SHOW CONNECTION.
  5201.  
  5202. \v(cx_time)
  5203.   This variable shows the elapsed time of your current connection, or if
  5204.   there is no current connection, of your most recent connection, of if there
  5205.   have been no connections, 0.
  5206.  
  5207. The connection contains one line per connection, of the form:
  5208.  
  5209.   yyyymmdd hh:mm:ss username pid p=v [ p=v [ ... ] ]
  5210.  
  5211. where the timestamp (in columns 1-18) shows when the connection was made;
  5212. username is the login identity of the person who made the connection; pid is
  5213. Kermit's process ID when it made the connection.  The p's are parameters that
  5214. depend on the type of connection, and the v's are their values:
  5215.  
  5216.   T = Connection Type (TCP, SERIAL, DIAL, DECNET, etc).
  5217.   H = The name of the Host from which the connection was made.
  5218.   N = Destination phone Number or Network host name or address.
  5219.   D = Serial connections only: Device name.
  5220.   O = Dialed calls only: Originating country code & area code if known.
  5221.   E = Elapsed time in hh:mm:ss format (or hhh:mm:ss, etc).
  5222.  
  5223. If you always want to keep a connection log, simply add:
  5224.  
  5225.   log connections
  5226.  
  5227. to your C-Kermit customization file.  Note, however, that if you make a lot of
  5228. connections, your CX.LOG will grow and grow.  You can handle this by adding a
  5229. "logrotate" procedure like the following to your customization file, before
  5230. the "log connections" command:
  5231.  
  5232.   define LOGROTATE {                    ; Define LOGROTATE macro
  5233.       local \%i \%m \%d \%n \%f MAX
  5234.       def MAX 4                         ; How many months to keep
  5235.       if not def \%1 -                  ; No argument given
  5236.     end 1 \%0: No filename given
  5237.       if not = 1 \ffiles(\%1) -         ; Exactly 1 file must match
  5238.     end 1 \%0: \%1 - File not found
  5239.       .\%d := \fsubstr(\fdate(\%1),1,6) ; Arg OK - get file year & month
  5240.       if = \%d -                        ; Compare file year & month
  5241.         \fsubstr(\v(ndate),1,6) -       ; with current year & month
  5242.       end 0                         ; Same year & month - done
  5243.       rename \%1 \%1.\%d                ; Different - rename file
  5244.       .\%n := \ffiles(\%1.*)            ; How many old files
  5245.       if < \%n \m(MAX) end 0            ; Not enough to rotate
  5246.       .\%m := \%1.999999                ; Initial compare string
  5247.       for \%i 1 \%n 1 {                 ; Loop thru old logs
  5248.      .\%f := \fnextfile()           ; Get next file name
  5249.      if llt \%f \%m .\%m := \%f     ; If this one older remember it
  5250.       }
  5251.       delete \%m                        ; Delete the oldest one
  5252.   }
  5253.   log connections                       ; Now open the (possibly new) log
  5254.   logrotate \v(home)CX.LOG              ; Run the LOGROTATE macro
  5255.  
  5256. As you can see, this compares the yyyymm portion of the modification date
  5257. (\fdate()) of the given file (\%1) with the current yyyymm.  If they differ,
  5258. the current file has the yyyymm suffix (from its most recent modification
  5259. date) appended to its name.  Then we search through all other such files, find
  5260. the oldest one, and delete it.  Thus the current log, plus the logs from the
  5261. most recent four months, are kept.  This is all done automatically every time
  5262. you start C-Kermit.
  5263.  
  5264. On multiuser systems, it is possible to keep a single, shared, system-wide
  5265. connection log, but this is not recommended since (a) it requires you keep a
  5266. publicly write-accessible logfile (a glaring target for mischief), and (b) it
  5267. would require each user to log to that file and not disable logging.  A better
  5268. method for logging connections, in UNIX at least, is syslogging (see
  5269. ckuins.txt Section 15 and iksd.txt Section 4.2 for details).
  5270.  
  5271. 2.13. Automatic Connection-Specific Flow Control Selection
  5272.  
  5273. Beginning in C-Kermit 7.0, the appropriate flow-control method for each
  5274. connection type is kept in a table, for example:
  5275.  
  5276.   Remote:           NONE
  5277.   Modem:            RTS/CTS
  5278.   Direct-Serial:    NONE
  5279.   TCPIP:            NONE
  5280.  
  5281. The size of the table and values for each connection type can vary from
  5282. platform to platform.  Type "set flow ?" for a list of available flow-control
  5283. types.
  5284.  
  5285. The table is used to automatically select the appropriate kind of flow
  5286. control whenever you make a connection.  You can display the table with:
  5287.  
  5288.   SHOW FLOW-CONTROL
  5289.  
  5290. The defaults are as follows:
  5291.  
  5292. Remote:
  5293.   NONE or XON/XOFF.  This is because C-Kermit is not allowed to find out what
  5294.   type of connection the incoming user has (*).  No kind of flow control will
  5295.   work on every kind of connection, including (unexpectedly) KEEP, which we
  5296.   would have liked to use, but not turning off flow control at the remote end
  5297.   during file transfer on TCP/IP connections is fatal to the transfer (except
  5298.   in VMS and HP-UX, where it must be set to Xon/Xoff!)  Therefore if you are
  5299.   dialing in to a serial port on a server (UNIX or VMS) where C-Kermit is
  5300.   running, you will need to tell C-Kermit to "set flow keep" before
  5301.   transferring files (assuming the modem and port are configured correctly by
  5302.   the system administrator; otherwise you'll need to give a specific kind of
  5303.   flow control, e.g. "set flow xon/xoff"), so in this case C-Kermit will not
  5304.   disable flow control, as it must do when you are coming via Telnet (directly
  5305.   or through a terminal server, except on VMS and HP-UX).
  5306.  
  5307. Modem:
  5308.   This applies when you dial out with a modem.  In this case, the MODEM
  5309.   FLOW-CONTROL setting takes affect after the SET FLOW setting, so it can pick
  5310.   the most appropriate flow control for the combination of the particular
  5311.   modem and the computer/port/driver that is dialing.
  5312.  
  5313. Direct-Serial:
  5314.   The default here is NONE because C-Kermit has no way of knowing what kind
  5315.   of flow control, if any, is or can be done by the device at the other end
  5316.   of the connection.  RTS/CTS would be a bad choice here, because if the CTS
  5317.   signal is not asserted, the connection will hang.  And since direct
  5318.   connections are often made with 3-wire cables, there is a good chance the
  5319.   CTS signal will not be received.
  5320.  
  5321. TCPIP:
  5322.   NONE, since TCP and IP provide their own flow control transparently to the
  5323.   application, except in VMS, where Xon/Xoff is the default due to the
  5324.   requirements of the VMS TCP/IP products.
  5325.  
  5326. Other networks:
  5327.   NONE, since networks should provide their flow control transparently to the
  5328.   application.
  5329.  
  5330. (*) This is possibly the worst feature of UNIX, VMS, and other platforms
  5331.     where C-Kermit runs.  If C-Kermit was able to ask the operating system
  5332.     what kind of connection it had to the user, it could set up many things
  5333.     for you automatically.
  5334.  
  5335. You can modify the default-flow-control table with:
  5336.  
  5337.   SET FLOW-CONTROL /xxx { NONE, KEEP, RTS/CTS, XON/XOFF, ... }
  5338.  
  5339. where "xxx" is the connection type, e.g.
  5340.  
  5341.   SET FLOW /REMOTE NONE
  5342.   SET FLOW /DIRECT RTS/CTS
  5343.  
  5344. If you leave out the switch, SET FLOW works as before, choosing the flow
  5345. control method to be used on the current connection:
  5346.  
  5347.   SET FLOW XON/XOFF
  5348.  
  5349. Thus, whenever you make a connection with SET PORT, SET LINE, DIAL, SET HOST,
  5350. TELNET, RLOGIN, etc, an appropriate form of flow control is selected
  5351. automatically.  You can override the automatic selection with a subsequent
  5352. SET FLOW command, such as SET FLOW NONE (no switch included).
  5353.  
  5354. The flow control is changed automatically too when you give a SET MODEM TYPE
  5355. command.  For example, suppose your operating system (say Linux) supports
  5356. hardware flow control (RTS/CTS).  Now suppose you give the following
  5357. commands:
  5358.  
  5359.   set line /dev/ttyS2    ; Automatically sets flow to NONE
  5360.   set modem type usr     ; Automatically sets flow to RTS/CTS
  5361.   set modem type rolm    ; Doesn't support RTS/CTS so now flow is XON/XOFF
  5362.  
  5363. IMPORTANT: This new feature tends to make the order of SET LINE/HOST and
  5364. SET FLOW commands matter, where it didn't before.  For example, in VMS:
  5365.  
  5366.   SET FLOW KEEP
  5367.   SET LINE TTA0:
  5368.  
  5369. the SET LINE undoes the SET FLOW KEEP command; the sequence now must be:
  5370.  
  5371.   SET FLOW /DIRECT KEEP
  5372.   SET LINE TTA0:
  5373.  
  5374. or:
  5375.  
  5376.   SET LINE TTA0:
  5377.   SET FLOW KEEP
  5378.  
  5379. 2.14. Trapping Connection Establishment and Loss
  5380.  
  5381. If you define a macro called ON_OPEN, it is executed any time that a SET LINE,
  5382. SET PORT, SET HOST, TELNET, RLOGIN or similar command succeeds in opening a
  5383. connection.  The argument is the host or device name (as shown by SHOW
  5384. COMMUNICATIONS, and the same as \v(line)).  This macro can be used for all
  5385. sorts of things, like automatically setting connection- or host-specific
  5386. parameters when the connection is opened.  Example:
  5387.  
  5388.   def ON_OPEN {
  5389.       switch \%1 {
  5390.         :abccorp.com, set reliable off, break
  5391.         :xyzcorp.com, set receive packet-length 1000, break
  5392.         etc etc...
  5393.       }
  5394.   }
  5395.  
  5396. If you define a macro called ON_CLOSE, it will be executed any time that
  5397. a SET LINE, SET PORT, SET HOST, TELNET, RLOGIN or any other kind of connection
  5398. that C-Kermit has made is closed, either by the remote or by a local CLOSE,
  5399. HANGUP, or EXIT command or other local action, such as when a new connection
  5400. is opened before an old one was explicitly closed.
  5401.  
  5402. As soon as C-Kermit notices the connection has been closed, the ON_CLOSE macro
  5403. is invoked at (a) the top of the command parsing loop, or (b) when a
  5404. connection is closed implicitly by a command such as SET LINE that closes any
  5405. open connection prior to making a new connection, or (c) when C-Kermit closes
  5406. an open connection in the act of exiting.
  5407.  
  5408. The ON_CLOSE macro was inspired by the neverending quest to unite Kermit and
  5409. SSH (*).  In this case using the "tunnel" mechanism:
  5410.  
  5411.   def TUNNEL {                                ; \%1 = host to tunnel to
  5412.       local \%p
  5413.       if not def \%1 stop 1
  5414.       assign tunnelhost \%1                   ; Make global copy
  5415.       undef on_close
  5416.       set macro error off
  5417.       close connection                        ; Ignore any error
  5418.       open !read tunnel start \%1
  5419.       read \%p                                ; Get port number
  5420.       if fail stop 1 Tunnel failure: \%1
  5421.       close read
  5422.       if fail stop 1 Tunnel failure: \%1      ; See Section 4.2.8.1
  5423.       assign on_close {                       ; Set up close handler
  5424.           echo Closing tunnel: \m(tunnelhost)
  5425.           !tunnel stop \m(tunnelhost)
  5426.           undef on_close
  5427.       }
  5428.       set host localhost:\%p /telnet
  5429.       if success end 0
  5430.       undef on_close
  5431.       stop 1 Connection failure: \%1
  5432.   }
  5433.  
  5434. In this case, when the connection stops, we also need to shut down the tunnel,
  5435. even if it is at a later time after TUNNEL has finished executing.  This way
  5436. we can escape back, reconnect, transfer files, and so on until the connection
  5437. is broken by logging out from the remote, or by explicitly closing it, or by
  5438. EXITing from C-Kermit, at which time the tunnel is shut down.
  5439.  
  5440. When the connection is closed, no matter how, the ON_CLOSE macro executes
  5441. and then undefines (destroys) itself, since we don't want to be closing
  5442. tunnels in the future when we close subsequent connections.
  5443.  
  5444. Other such tricks can be imagined, including ending ON_CLOSE with a STOP
  5445. command to force the command stack to be peeled all the way back to the top,
  5446. for example in a deeply nested script that depends on the connection being
  5447. open:
  5448.  
  5449.   def on_close { stop 1 CONNECTION LOST }
  5450.  
  5451. When C-Kermit invokes the ON_CLOSE macro, it supplies one argument (\%1):
  5452. the reason the connection was closed as a number, one of the following:
  5453.  
  5454.   2 - Fatal failure to negotiate a required item on a network connection.
  5455.   1 - Closed by C-Kermit command.
  5456.   0 - All others (normally closed by remote).
  5457.  
  5458. which may be used for any purpose; for example, to add a comment to the
  5459. connection log:
  5460.  
  5461.   def on_close {
  5462.       local \%m
  5463.       if not open cx end 0
  5464.       switch \%1 {
  5465.         :0, .\%m = Closed by remote, break
  5466.         :1, .\%m = Closed by me, break
  5467.         :2, .\%m = Network protocol negotiation failure, break
  5468.       }
  5469.       if def \%m writeln cx {# \%m}
  5470.   }
  5471.  
  5472. (*) SSH can not be included in C-Kermit due to licensing, patent, and
  5473.     USA export law restrictions.  Furthermore, the 'ssh' client that is
  5474.     distributed for UNIX can not be run by C-Kermit's PIPE command because
  5475.     it does not use standard i/o.
  5476.  
  5477. 2.15. Contacting Web Servers with the HTTP Command
  5478.  
  5479. C-Kermit 7.0 (at this writing, the UNIX version only) supports direct contact
  5480. and interaction with Web servers via HTTP 1.0 protocol.  To make a connection,
  5481. use Kermit's normal method for making a TCP/IP connection, but specify the
  5482. HTTP port:
  5483.  
  5484.   SET HOST <host> http [ <switches> ]
  5485.  
  5486. where <host> is the IP hostname or address, and http is the name of the
  5487. TCP port for the Web server.  Relevant switches include:
  5488.  
  5489. /RAW
  5490.   Treat the connection as a transparent binary pipe.  This switch may be
  5491.   required if a port other than 'http' is used.
  5492.  
  5493. /SSL
  5494.   Make an secure private connection with SSL (only if SSL support is included
  5495.   in your version of Kermit).  In this case the port name might need to be
  5496.   https rather than http, e.g. "set host secureserver.xyxcorp.com https /ssl".
  5497.  
  5498. /TLS
  5499.   Make an secure private connection with TLS (only if TLS support is included
  5500.   in your version of Kermit).  In this case the port name would be https
  5501.   rather than http.
  5502.  
  5503. Then you can issue an HTTP command.  In most cases, the server closes the
  5504. connection when the command is complete.  Example:
  5505.  
  5506.   SET HOST www.columbia.edu http
  5507.   IF FAIL EXIT 1 Can't contact server
  5508.   HTTP GET kermit/index.html
  5509.  
  5510. At this point the connection is closed, since that's how HTTP 1.0 works.  If
  5511. you want to perform additional operations, you must establish a new connection
  5512. with another SET HOST command.
  5513.  
  5514. The HTTP command acts as a client to the Web server, except instead of
  5515. displaying the results like a Web browser would, it stores them.  Any HTTP
  5516. command can (but need not) include any or all of the following switches:
  5517.  
  5518. /AGENT:<user-agent>
  5519.   Identifies the client to the server; "C-Kermit" or "Kermit-95"
  5520.   by default.
  5521.  
  5522. /HEADER:<header-line>
  5523.   Used for specifying any optional headers.  A list of headers is provided
  5524.   using braces for grouping:
  5525.  
  5526.     /HEADER:{{<tag>:<value>}{<tag>:<value>}...}
  5527.  
  5528.   For a listing of valid <tag> value and <value> formats see RFC 1945:
  5529.   "Hypertext Transfer Protocol -- HTTP/1.0".  A maximum of eight headers
  5530.   may be specified.
  5531.  
  5532. /USER:<name>
  5533.   In case a page requires a username for access.
  5534.  
  5535. /PASSWORD:<password>
  5536.   In case a page requires a password for access.
  5537.  
  5538. /ARRAY:<arrayname>
  5539.   Tells Kermit to store the response headers in the given array, one line per
  5540.   element.  The array need not be declared in advance.  Example:
  5541.  
  5542.     http /array:c get kermit/index.html
  5543.     show array c
  5544.     Dimension = 9
  5545.     1. Date: Fri, 26 Nov 1999 23:12:22 GMT
  5546.     2. Server: Apache/1.3.4 (Unix)
  5547.     3. Last-Modified: Mon, 06 Sep 1999 22:35:58 GMT
  5548.     4. ETag: "bc049-f72-37d441ce"
  5549.     5. Accept-Ranges: bytes
  5550.     6. Content-Length: 3954
  5551.     7. Connection: close
  5552.     8. Content-Type: text/html
  5553.  
  5554. As you can see, the header lines are like MIME e-mail header lines:
  5555. identifier, colon, value.  The /ARRAY switch is the only method available
  5556. to a script to process the server responses for a POST or PUT command.
  5557.  
  5558. The HTTP commands are:
  5559.  
  5560. HTTP [ <switches> ] GET <remote-filename> [ <local-filename> ]
  5561.   Retrieves the named file.  If a <local-filename> is given, the file is
  5562.   stored locally under that name; otherwise it is stored with its own name.
  5563.  
  5564. HTTP [ <switches> ] HEAD <remote-filename> <local-filename>
  5565.   Like GET except without actually getting the file; instead it gets only
  5566.   the headers, storing them into the given file, whose name must be given,
  5567.   one line per header item, as shown above in the /ARRAY: switch description.
  5568.  
  5569. HTTP [ <switches> ] INDEX <remote-directory> [ <local-filename> ]
  5570.   Retrieves the file listing for the given server directory.
  5571.   NOTE: This command is not supported by most Web servers.
  5572.  
  5573. HTTP [ <switches> ] POST [ /MIME-TYPE:<type> ] <local-file> <remote-file>
  5574.   Used to send a response as if it were sent from a form.  The data to be
  5575.   posted must be read from a file.
  5576.  
  5577. HTTP [ <switches> ] PUT [ /MIME-TYPE:<type> ] <local-file> <remote-file>
  5578.   Uploads a local file to a server file.
  5579.  
  5580. HTTP [ <switches> ] DELETE <remote-filename>
  5581.   Instructs the server to delete the specified filename.
  5582.  
  5583.  
  5584. (3) TERMINAL CONNECTION
  5585.  
  5586. 3.1. CONNECT Command Switches
  5587.  
  5588. The following switches (see section 1.5) were added to the CONNECT command
  5589. in 7.0:
  5590.  
  5591.   /QUIETLY
  5592.     Don't print the "Connecting to..." or "Back at..." messages.
  5593.     CQ is an invisible command synonym for CONNECT /QUIETLY.
  5594.  
  5595.   /TRIGGER:string
  5596.     Specify a trigger or triggers (Section 3.2) effective for this CONNECT
  5597.     command only, temporarily overriding any current SET TERMINAL TRIGGER
  5598.     values (Section 3.2).
  5599.  
  5600. Note: Other switches might also be available; type "connect ?" for a list,
  5601. "help connect" for a description of each.
  5602.  
  5603. 3.2. Triggers
  5604.  
  5605. Triggers were added for UNIX, VMS, AOS/VS, and K95 in C-Kermit 7.0.
  5606.  
  5607. SET TERMINAL TRIGGER string
  5608.   Tells C-Kermit to look for the given string during all subsequent CONNECT
  5609.   sessions, and if seen, to return to command mode automatically, as if you
  5610.   had escaped back manually.  If the string includes any spaces, you must
  5611.   enclose it in braces.  Example:
  5612.  
  5613.     SET TERMINAL TRIGGER {NO CARRIER}
  5614.  
  5615. Comparisons are made after character-set translation.
  5616.  
  5617. If a string is to include a literal brace character, precede it with a
  5618. backslash:
  5619.  
  5620.     ; My modem always makes this noise when the connection is lost:
  5621.     SET TERMINAL TRIGGER |||ppp\{\{\{\{UUUUUUU
  5622.  
  5623. If you want Kermit to look for more than one string simultaneously, use the
  5624. following syntax:
  5625.  
  5626.     SET TERMINAL TRIGGER {{string1}{string2}...{stringn}}
  5627.  
  5628. In this case, C-Kermit will return to command mode automatically if any of
  5629. the given strings is encountered.  Up to 8 strings may be specified.
  5630.  
  5631. If the most recent return to command mode was caused by a trigger, the new
  5632. variable, \v(trigger), shows the trigger value; otherwise \v(trigger) is
  5633. empty.
  5634.  
  5635. The SHOW TRIGGER command displays the SET TERMINAL TRIGGER values as well as
  5636. the \v(trigger) value.
  5637.  
  5638. 3.3. Transparent Printing
  5639.  
  5640. As noted in the manual, C-Kermit's CONNECT command on UNIX is not a terminal
  5641. emulator, but rather a "semitransparent pipe" between the terminal or emulator
  5642. you are using to access C-Kermit, and the remote host to which C-Kermit is
  5643. connected.  The "semitransparent" qualifier is because of character-set
  5644. translation as well as several actions taken by the emulator in response to
  5645. the characters or strings that pass through it, such as APCs, Kermit packets
  5646. (autodownload), triggers, etc.
  5647.  
  5648. The UNIX version of C-Kermit 7.0 adds another such action: Transparent
  5649. printing, also called Controller printing (as distinct from Autoprint or line
  5650. or screen print).  It is intended mainly for use on UNIX workstation consoles
  5651. (as opposed to remote logins), but with some care can also be used when
  5652. accessing C-Kermit remotely.
  5653.  
  5654. Transparent printing is related to APC by sharing C-Kermit's built-in ANSI
  5655. escape-sequence parser to detect "printer on" and "printer off" sequences from
  5656. the host.  When the printer-on sequence is received, all subsequent arriving
  5657. characters -- including NUL, control characters, and escape sequences --
  5658. are sent to the SET PRINTER device instead of to your screen until
  5659. the printer-off sequence is received, or you escape back, whichever happens
  5660. first.  These bytes are not translated or modified or filtered in any way
  5661. by Kermit (except for possibly stripping of the 8th bit, as noted below), but
  5662. if filtering or translation is desired, this can be accomplished by your
  5663. SET PRINTER selection (e.g. by choosing a pipeline of filters).
  5664.  
  5665. By default, your SET PRINTER device is your default UNIX printer, but
  5666. it can also be a file, a command, or the null device (which causes all printer
  5667. material to be discarded).  See "Using C-Kermit", 2nd Ed., p.41 for details.
  5668.  
  5669. Transparent printing is controlled by the command:
  5670.  
  5671. SET TERMINAL PRINT { ON, OFF }
  5672.   When ON, transparent-print sequences are obeyed, and printing occurs on the
  5673.   system where C-Kermit is running.  When OFF, transparent print sequences are
  5674.   ignored and passed through to your actual terminal or emulator, along with
  5675.   the data they enclose.  OFF is the default, for compatibility with earlier
  5676.   C-Kermit releases.  As noted in the manual, when the current SET PRINTER
  5677.   device is a file, transparent-print material is appended to it; the file is
  5678.   not overwritten.
  5679.  
  5680. SET TERMINAL BYTESIZE { 7, 8 }
  5681. SET PARITY { EVEN, ODD, MARK, SPACE, NONE }
  5682.   If the terminal bytesize is 7, or PARITY is not NONE, the 8th bit of each
  5683.   byte is stripped prior to printing.
  5684.  
  5685. The transparent-print escape sequences are:
  5686.  
  5687. <ESC>[5i
  5688.   Printer On.  Send all subsequent incoming bytes to the printer without
  5689.   any kind of filtering, translation, or alteration.  Note: <ESC> stands for
  5690.   ASCII character number 27 (decimal), Escape.
  5691.  
  5692. <ESC>[4i
  5693.   Printer Off.  Resume displaying incoming bytes on the screen.
  5694.  
  5695. These are the same sequences used by DEC VT100 and higher terminals and other
  5696. ANSI X3.64 and ISO 6429 compatible terminals.  There is no provision for
  5697. selecting other printer-control sequences.
  5698.  
  5699. Restrictions:
  5700.  
  5701.  1. You must SET TERM TRANSPARENT-PRINT ON before you can use this feature.
  5702.  
  5703.  2. Only the 7-bit forms of the escape sequences are supported.  The 8-bit
  5704.     CSI C1 control is not recognized.
  5705.  
  5706.  3. Autoprint is not supported, since this requires a full-fledged terminal
  5707.     emulator with direct access to the screen.
  5708.  
  5709.  4. The start-print and stop-print sequences pass through to the screen (there
  5710.     is no way to avoid this without causing unacceptable delays or deadlocks
  5711.     in CONNECT mode).  Thus if your terminal or emulator also supports
  5712.     transparent printing via these same sequences, an empty file will be sent
  5713.     to its printer.  Normally this has no effect.
  5714.  
  5715. Point (4) is similar to the situation with autodownload and APC -- when you
  5716. have several Kermit clients in a chain, you should take care that these
  5717. features are enabled in only one of them.
  5718.  
  5719. Example 1:
  5720.  
  5721.   set printer {|lpr -Plaser}  ; Specify the printer (if not default).
  5722.   set term print on           ; Enable transparent printing.
  5723.   set term byte 8             ; Enable 8-bit characters.
  5724.   connect                     ; Enter CONNECT mode.
  5725.  
  5726. Example 2:
  5727.  
  5728.   set printer /home/users/olga/printer.log  ; Send printer material to a file.
  5729.  
  5730. Example 3:
  5731.  
  5732.   set printer {| grep -v ^Received | lpr}   ; Filter out some lines
  5733.  
  5734. Then use "pcprint" or "vtprint" commands on the host to initiate transparent
  5735. print operations.  See "Using C-Kermit", 2nd Ed., p.406 for details.
  5736.  
  5737. Here is a sample "pcprint" shell script for UNIX:
  5738.  
  5739. #!/bin/sh
  5740. echo -n '<ESC>[5i'
  5741. if [ $# -eq 0 ]; then
  5742.   cat
  5743. else
  5744.   cat $*
  5745. fi
  5746. echo -n '<FF><ESC>[4i'
  5747. # (end)
  5748.  
  5749. (Replace "<ESC>" by the actual ASCII Escape character and "<FF>" by the
  5750. ASCII Formfeed character).
  5751.  
  5752. If you always want transparent printing enabled, put "set term print on"
  5753. in your C-Kermit customization file (~/.mykermrc in UNIX).  The "set term
  5754. bytesize" selection, however, is a property of each separate connection.
  5755.  
  5756. 3.4. Binary and Text Session Logs
  5757.  
  5758. C-Kermit 7.0 corrects an oversight in earlier releases, in which binary
  5759. session logs (SET SESSION-LOG BINARY) translated character sets and performed
  5760. various formatting transformations (e.g. "newline mode") before writing
  5761. characters to the session log.  In C-Kermit 7.0, binary-mode session logging
  5762. writes characters as they come in, before anything (other that parity-bit
  5763. stripping) is done to them.  Text-mode session logging records the characters
  5764. after processing.
  5765.  
  5766. (4) FILE TRANSFER
  5767.  
  5768. Every file is transferred either in text mode (which implies record-format
  5769. and character-set translation) or binary mode (in which each byte is sent
  5770. literally without any kind of conversion).  The mode in which a file is
  5771. transferred is controlled by (a) the default mode, in the absence of any
  5772. other indications; (b) the SET FILE TYPE command; (c) various automatic
  5773. mechanisms based on client/server negotiations, directory information or
  5774. filename patterns, etc.
  5775.  
  5776. The default FILE TYPE was changed from TEXT to BINARY in C-Kermit 7.0
  5777. because:
  5778.  
  5779.  . Transferring a text file in binary mode does less damage than
  5780.    transferring a binary file in text mode.
  5781.  
  5782.  . Only binary-mode transfers can be recovered from the point of failure.
  5783.  
  5784.  . The automatic transfer-mode mechanisms switch to text mode on a per-file
  5785.    basis anyway, so only those files that are not covered by the automatic
  5786.    mechanisms are affected.
  5787.  
  5788.  . All file transfers on the Web are done in binary mode, so people are
  5789.    accustomed to it and expect it.
  5790.  
  5791. 4.0. BUG FIXES, MINOR CHANGES, AND CLARIFICATIONS
  5792.  
  5793. 4.0.0. Filenames with Spaces
  5794.  
  5795. Filenames that contain spaces are a major nuisance to a program like Kermit,
  5796. whose command language is line- and word-oriented, in which words are
  5797. separated by spaces and a filename is assumed to be a "word".  In general
  5798. (unless noted otherwise in the description of a particular command), there is
  5799. only one way to refer to such files in Kermit commands, and that is to enclose
  5800. the name in braces:
  5801.  
  5802.   send {this file}
  5803.  
  5804. Tells Kermit to send the file whose name is "this file" (two words, no
  5805. quotes).  Of course, various circumlocutions are also possible, such as:
  5806.  
  5807.   define \%a this file
  5808.   send \%a
  5809.  
  5810. BUT, perhaps contrary to expectation, you can't use "\32" to represent the
  5811. space:
  5812.  
  5813.   send this\32file
  5814.  
  5815. does not work.  Why?  Because the Kermit parser, which must work on many
  5816. operating systems including Windows, has no way of knowing what you mean by
  5817. "this\32file".  Do you mean a file whose name is "this file" in the current
  5818. directory?  Or do you mean a file whose name is "32file" in the "this"
  5819. subdirectory of the current directory?  Guessing won't do here; Kermit must
  5820. behave consistently and deterministically in all cases on all platforms.
  5821.  
  5822. Note that you can't use Esc or Tab within {...} for filename completion,
  5823. or question mark to get a filename list.  However, you can include wildcards;
  5824. for example:
  5825.  
  5826.   send {* *}
  5827.  
  5828. sends all files whose name contains a space.
  5829.  
  5830. All things considered, it is best to avoid spaces in file and directory names
  5831. if you can.  Also see Section 5.4 on this topic.
  5832.  
  5833. 4.0.1. Packet out of Window
  5834.  
  5835. C-Kermit 6.0 could send packets "out of window" if the window size was
  5836. greater than 1 and ACKs had arrived out of order.  Fixed in 6.1.
  5837.  
  5838. 4.0.2. MOVE after ADD SEND-LIST
  5839.  
  5840. ADD SEND-LIST followed by MOVE did not delete original files; fixed in 6.1.
  5841. Carrier loss was not detected during transfer; in 7.0 C-Kermit checks for
  5842. this (but results can not be guaranteed).  In any case, the protocol will
  5843. eventually time out if the connection is lost.
  5844.  
  5845. 4.0.3. GET and RECEIVE As-Names
  5846.  
  5847. In 5A(190) through 6.0.192, the GET and RECEIVE as-name did not properly
  5848. override the RECEIVE PATHNAMES setting.  In 7.0 it does.
  5849.  
  5850. 4.0.4. New Brief Statistics Listing
  5851.  
  5852. Version 7.0 adds a /BRIEF switch to the STATISTICS command, to display a short
  5853. file-transfer statistics report.  /BRIEF is now the default.  Use /VERBOSE to
  5854. see the full display, which is about 25 lines long.
  5855.  
  5856. 4.0.5. Improved FAST Command
  5857.  
  5858. The preinstalled definition of the FAST macro did not take enough factors into
  5859. account.  Now it sets packet lengths and window sizes appropriate to the
  5860. configuration.  Furthermore, in IRIX only, it might restrict the SEND packet
  5861. length to 4000, to work around a bug in the IRIX Telnet server, depending on
  5862. the IRIX version (see ckubwr.txt, IRIX section).  To see the built-in
  5863. definition of the FAST macro, type "show macro fast".  To change it, simply
  5864. define it to be whatever you want -- it's just a macro, like any other.
  5865.  
  5866. 4.0.6. The SET SEND BACKUP Command
  5867.  
  5868. Version 7.0 adds SET SEND BACKUP { ON, OFF }.  This tells whether backup
  5869. files should be sent.  Backup files are the ones created by Kermit (and EMACS,
  5870. and possibly other applications) to preserve old copies of files when creating
  5871. new ones with the same name.  Kermit does this when receiving a file and its
  5872. FILE COLLISION setting is BACKUP (or RENAME, in which case it the new file
  5873. gets the backup name).  On most platforms, the backup name is formed by adding:
  5874.  
  5875.   .~n~
  5876.  
  5877. to the end of the filename, where "n" is a number.  For example, if the
  5878. original file is oofa.txt, a backup file might be called:
  5879.  
  5880.   oofa.txt.~1~
  5881.  
  5882. (or oofa.txt.~2~, etc).  If you SET SEND BACKUP OFF, this tells Kermit not to
  5883. send files that have backup names.  Normally, SET SEND BACKUP is ON (as shown
  5884. by SHOW PROTOCOL), and backup files are sent if their names match the SEND
  5885. file specification.
  5886.  
  5887. Also see PURGE, SET FILE COLLISION, SEND /NOBACKUP, DIRECTORY /[NO]BACKUP.
  5888.  
  5889. 4.0.7. The SET { SEND, RECEIVE } VERSION-NUMBERS Command
  5890.  
  5891. VMS Only.  Normally when sending files, VMS C-Kermit strips the version
  5892. number.  For example, if the file is FOO.BAR;34, the name is sent as FOO.BAR
  5893. (without the ";34").  If you want to keep version numbers on when sending
  5894. files, use SET SEND VERSION-NUMBERS ON.  The effect depends on the receiver.
  5895.  
  5896. Normally when receiving files, and an incoming filename includes a VMS-style
  5897. version number (such as FOO.BAR;34) VMS C-Kermit strips it before trying to
  5898. create the new file; this way the new file receives the next highest version
  5899. number in the customary manner for VMS.  If you want version numbers on
  5900. incoming filenames to be used in creating the new files, use SET RECEIVE
  5901. VERSION-NUMBERS ON.
  5902.  
  5903. Normally these commands would be effective only when VMS C-Kermit is
  5904. exchanging files with a non-VMS Kermit program, since VMS-to-VMS transfers use
  5905. labeled mode unless you have gone out of your way to defeat it.
  5906.  
  5907. Example: You want to send all versions of all files in the current directory
  5908. from a VMS C-Kermit client to a UNIX C-Kermit server.  Use:
  5909.  
  5910.   set send version-numbers on
  5911.   send *.*;*
  5912.  
  5913. The resulting Unix files will have VMS-style version numbers as part of their
  5914. name, for example "foo.bar;1", "foo.bar;2", etc.
  5915.  
  5916. Now suppose you want to send these files from Unix to another VMS system and
  5917. preserve the version numbers.  Again we have a Unix C-Kermit server and VMS
  5918. C-Kermit client.  Give these commands to the client:
  5919.  
  5920.   set receive version-numbers on
  5921.   get *
  5922.  
  5923. 4.0.8. The SET { SEND, RECEIVE } { MOVE-TO, RENAME-TO } Commands
  5924.  
  5925. These commands are persistent global versions of the /MOVE-TO: and
  5926. /RENAME-TO: switches of the SEND, GET, and RECEIVE commands.  They should
  5927. normally be used only when setting up a dedicated transaction-processing
  5928. application, in which each file is to be moved or renamed immediately after,
  5929. and only if, it is transferred successfully, so that (for example) an
  5930. independent, concurrent process can notice when new files appear and process
  5931. them immediately without having to guess whether they are complete.
  5932.  
  5933. 4.0.9. SET FILE INCOMPLETE AUTO
  5934.  
  5935. SET FILE INCOMPLETE { KEEP, DISCARD }, which tells whether to keep or discard
  5936. incompletely received files, has a new option, AUTO, which is also the
  5937. default.  It means KEEP the incomplete file if the transfer is in binary mode,
  5938. otherwise DISCARD it.  This reduces the chances that a subsequent recovery
  5939. operation (RESEND, REGET, etc) could produce a corrupt file, since recovery
  5940. works only for binary-mode transfers.
  5941.  
  5942. 4.1. FILE-TRANSFER FILENAME TEMPLATES
  5943.  
  5944. File-transfer filename templates allow files to be renamed automatically by
  5945. the file sender, the receiver, or both, during transfer of groups of files.
  5946.  
  5947. 4.1.1. Templates in the As-Name
  5948.  
  5949. Prior to C-Kermit 6.1 and Kermit 95 1.1.12 the only options that could be
  5950. used to affect the names of files being transferred were SET FILENAMES
  5951. { LITERAL, CONVERTED } and SET { SEND, RECEIVE } PATHNAMES { ON, OFF }, plus
  5952. the "as-name" feature of the SEND (MOVE, etc) and RECEIVE commands.
  5953.  
  5954. Previously, the as-name could be used only for a single file.  For example:
  5955.  
  5956.   SEND FOO BAR
  5957.  
  5958. would send the file FOO under the name BAR, but:
  5959.  
  5960.   SEND *.TXT anything
  5961.  
  5962. was not allowed, since it would give the same name to each file that was sent.
  5963. When receiving:
  5964.  
  5965.   RECEIVE FOO
  5966.  
  5967. would rename the first incoming file to FOO before storing it on the disk,
  5968. but subsequent files would not be renamed to FOO, since this would result in
  5969. overwriting the same file repeatedly.  Instead, they were stored under the
  5970. names they arrived with.
  5971.  
  5972. Beginning in C-Kermit 6.1 and Kermit 95 1.1.12, it is possible to
  5973. specify as-names in SEND, RECEIVE, and related commands even for file
  5974. groups.  This is accomplished by using replacement variables in the as-name,
  5975. along with optional material such character-string functions and/or constant
  5976. strings.  An as-name containing replacement variables is called a filename
  5977. template.
  5978.  
  5979. The key to filename templates is the new variable:
  5980.  
  5981.   \v(filename)
  5982.  
  5983. During file transfer it is replaced by the name of each file currently being
  5984. transferred (after transfer, it is the name of the last file transferred).
  5985.  
  5986. So, for example:
  5987.  
  5988.   send *.txt \v(filename).new
  5989.  
  5990. sends each file with its own name, but with ".new" appended to it.  Of course
  5991. if the name already contains periods, this could confuse the file receiver, so
  5992. you can also achieve fancier effects with constructions like:
  5993.  
  5994.   send *.txt \freplace(\v(filename),.,_).new
  5995.  
  5996. which replaces all periods in the original filename by underscores, and then
  5997. appends ".new" to the result.  So, for example, oofa.txt would be sent as
  5998. oofa_txt.new.
  5999.  
  6000. Another new variable that is useful in this regard is \v(filenumber), which
  6001. is the ordinal number of the current file in the file group, so you can also:
  6002.  
  6003.   send *.txt FILE\flpad(\v(filenum),2,0)
  6004.  
  6005. resulting in a series of files called FILE00, FILE01, FILE02, etc.  (At the
  6006. end of the transfer, \v(filenum) tells the number of files that were
  6007. transferred).
  6008.  
  6009. If you specify a constant as-name when sending a file group:
  6010.  
  6011.   send *.txt thisnameonly
  6012.  
  6013. Kermit complains and asks you to include replacement variables in the
  6014. as-name.  You should generally use \v(filename) or \v(filenumber) for this
  6015. purpose, since other variables (with the possible exception of date/time
  6016. related variables) do not change from one file to the next.  But Kermit
  6017. accepts any as-name at all that contains any kind of variables for file
  6018. group, even if the variable will not change.  So:
  6019.  
  6020.   send *.txt \%a
  6021.  
  6022. is accepted, but all files are sent with the same name (the value of \%a, if
  6023. it has one and it is constant).  If the variable has no value at all, the
  6024. files are sent under their own names.
  6025.  
  6026. Of course, the value of \%a in the previous example need not be constant:
  6027.  
  6028.   define \%a FILE\flpad(\v(filenum),2,0)_at_\v(time)
  6029.   send *.txt \%a
  6030.  
  6031. The RECEIVE command, when given without an as-name, behaves as always, storing
  6032. all incoming files under the names they arrive with, subject to SET FILE NAME
  6033. and SET RECEIVE PATHNAMES modifications (Section 4.10).
  6034.  
  6035. However, when an as-name is given in the RECEIVE command, it is applied to
  6036. all incoming files rather than to just the first.  If it does not contain
  6037. replacement variables, then the current FILE COLLISION setting governs the
  6038. result.  For example:
  6039.  
  6040.   receive foo
  6041.  
  6042. will result in incoming files named foo, foo.~1~, foo.~2~, and so on, with the
  6043. default FILE COLLISION setting of BACKUP.  If it does contain replacement
  6044. variables, of course they are used.
  6045.  
  6046. When receiving files, the \v(filename) variable refers to the name that was
  6047. received in the incoming file-header packet, BEFORE any processing by SET
  6048. FILE NAMES or SET RECEIVE PATHNAMES.  Since the filenames in file-header
  6049. packets are usually in uppercase, you would need to convert them explicitly
  6050. if you want them in lowercase, e.g.:
  6051.  
  6052.   receive \flower(\v(filename)).new
  6053.  
  6054. 4.1.2. Templates on the Command Line
  6055.  
  6056. On the command-line, use templates as shown above as the -a option argument,
  6057. bearing in mind the propensity of UNIX and perhaps other shells to treat
  6058. backslash as a shell escape character.  So in UNIX (for example):
  6059.  
  6060.   kermit -s oofa.* -a x.\\v(filenum)
  6061.  
  6062. By the way, this represents a change from 6.0 and earlier releases in
  6063. which the as-name (-a argument or otherwise) was not evaluated by the command
  6064. parser.  Thus, for example, in VMS (where the shell does not care about
  6065. backslashes), it was possible to:
  6066.  
  6067.   kermit -s oofa.txt -a c:\tmp\oofa.txt
  6068.  
  6069. Now backslashes in the as-name must be quoted not only for the shell (if
  6070. necessary) but also for Kermit itself:
  6071.  
  6072.   kermit -s oofa.txt -a c:\\tmp\\oofa.txt      ; Kermit only
  6073.   kermit -s oofa.txt -a c:\\\\tmp\\\\oofa.txt  ; Shell and Kermit
  6074.  
  6075. You can also use the \fliteral() function for this:
  6076.  
  6077.   kermit -s oofa.txt -a \fliteral(c:\tmp\oofa.txt)      ; Kermit only
  6078.   kermit -s oofa.txt -a \\fliteral(c:\\tmp\\oofa.txt)   ; Shell and Kermit
  6079.  
  6080. 4.1.3. Post-Transfer Renaming
  6081.  
  6082. Filename templates are now also useful in SET { SEND, RECEIVE } RENAME-TO and
  6083. in the /RENAME-TO: switch, that can be given to the SEND, GET, or RECEIVE
  6084. commands; this is similar to an as-name, but is effective on a per-file basis
  6085. if and only if the file was transferred successfully.
  6086.  
  6087. MOVE-TO and RENAME-TO address a requirement commonly stated for transaction
  6088. processing and similar systems.  Suppose, for example, a central system "X"
  6089. accepts connections from multiple clients simultaneously; a process on X waits
  6090. for a file to appear and then processes the file.  This process must have a
  6091. way of knowing when the file has been completely and successfully transferred
  6092. before it starts to process it.  This can be accomplished easily using
  6093. C-Kermit's SET { SEND, RECEIVE } { MOVE-TO, RENAME-TO } command or /MOVE-TO:
  6094. or /RENAME-TO: switches, described in Sections 4.7.1-3.
  6095.  
  6096. Here's an example for the client side, in which files to be sent are placed in
  6097. a certain directory (/usr/olga/tosend in this example) by another process when
  6098. they are ready to go.  This might be in a hospital or big doctor's office,
  6099. where medical insurance claims are entered at a number of workstations, and
  6100. then deposited in the "tosend" directory, from which they are sent to a claims
  6101. clearinghouse.  We assume the connection is already made and a Kermit server
  6102. is on the other end.
  6103.  
  6104.   local srcdir findir              ; Declare local (automatic) variables
  6105.   assign srcdir /usr/olga/tosend   ; Local source directory (files to send)
  6106.   assign findir /usr/olga/sent     ; Where to move files after they are sent
  6107.   log transactions                 ; Keep a log of transfers
  6108.   cd \m(srcdir)                    ; Change to the source directory
  6109.   while true {                     ; Loop forever...
  6110.       send /move-to:\m(findir) *   ; Send all files
  6111.       sleep 60                     ; Sleep a minute
  6112.   }                                ; Go back and do it again
  6113.  
  6114. Note how simple this is.  Once each file is sent, it is moved so it won't be
  6115. sent again (you could also use SEND /RENAME-TO: or even SEND /DELETE).  If a
  6116. transfer fails, the file is not moved and so we try again to send it next time
  6117. around.  If there are no files to send, the SEND command does nothing but a
  6118. message is printed; you can avoid the message by checking first to see if any
  6119. files are in the directory:
  6120.  
  6121.   while true {                     ; Loop forever...
  6122.       if > \ffiles(*) 0 -          ; If there are any files
  6123.         send /move-to:\m(findir) * ; send them.
  6124.       sleep 60                     ; Sleep a minute.
  6125.   }                                ; Go back and do it again.
  6126.  
  6127. It's even simpler on the server side (here again we assume the connection
  6128. is already in place):
  6129.  
  6130.   local rcvdir findir              ; Declare local (automatic) variables
  6131.   assign rcvdir /usr/ivan/tmp      ; Local source directory (files to send)
  6132.   assign findir /usr/ivan/new      ; Where to move files after reception
  6133.   log transactions                 ; Keep a log of transfers
  6134.   cd \m(tmpdir)                    ; Change to the source directory
  6135.   set receive move-to \m(findir)   ; Declare move-to directory.
  6136.   server                           ; Enter server mode.
  6137.  
  6138. A separate process (e.g. the medical claim-form decoder) can look for files
  6139. appearing in the /usr/ivan/new directory and process them with every
  6140. confidence that they have been completely received.
  6141.  
  6142. Note that the use of MOVE-TO can result in moved files overwriting one another
  6143. (the application would normally avoid this by assigning each transaction a
  6144. unique, e.g. based on customer number and claim number).  But if filename
  6145. collisions are a possibility in your application, RENAME-TO might be a better
  6146. choice; you can use any variables you like in the template to ensure
  6147. uniqueness of the RENAME-TO filename; for example:
  6148.  
  6149.   SET RECEIVE RENAME-TO \v(filename)_\v(ndate)_\v(ntime)_\v(userid)_\v(pid)
  6150.  
  6151. 4.2. FILE-TRANSFER PIPES AND FILTERS
  6152.  
  6153. 4.2.1. INTRODUCTION
  6154.  
  6155. Beginning in C-Kermit 6.1 and Kermit 95 1.1.12, it is possible to send from a
  6156. command, or "pipe", as well as from a file, and to receive to a pipe or
  6157. command.  In a typical example, we might want to transfer an entire directory
  6158. tree from one UNIX system to another (but without using the methods described
  6159. in Sections 4.3, 4.10, 4.11, and 4.15).  We could do this in multiple steps as
  6160. follows:
  6161.  
  6162.   1. Create a tar archive of the desired directory tree
  6163.   2. Compress the tar archive
  6164.   3. Transfer it in binary mode to the other computer
  6165.   4. Decompress it
  6166.   5. Extract the directory tree from the tar archive
  6167.  
  6168. But this is inconvenient and it requires a temporary file, which might be
  6169. larger than we have room for.
  6170.  
  6171. The new pipe-transfer feature lets you do such things in a single step,
  6172. and without intermediate files.
  6173.  
  6174. Additional new features, also discussed here, let you specify pre- and post-
  6175. processing filters for outbound and incoming files, and give you a way to
  6176. insert the output from shell or system commands into C-Kermit commands.
  6177.  
  6178. The file-transfer related features are available only with Kermit protocol,
  6179. not with any external protocols, nor with K95's built-in XYZMODEM protocols
  6180. (because XYZMODEM recovers from transmission errors by rewinding the source
  6181. file, and you can't rewind a pipe).
  6182.  
  6183. This section begins by discussing the simple and straightforward use of these
  6184. features in UNIX, in which pipes and input/output redirection are a
  6185. fundamental component and therefore "just work", and then goes on to discuss
  6186. their operation in Windows and OS/2, where matters are much more complicated.
  6187.  
  6188. 4.2.1.1. TERMINOLOGY
  6189.  
  6190. Standard Input
  6191.   This is a precise technical term denoting the normal source of input for
  6192.   a command or program, which is the keyboard of your terminal by default,
  6193.   but which can be redirected to a file or pipe.
  6194.  
  6195. Stdin
  6196.   Abbreviation for Standard Input.
  6197.  
  6198. Standard Output
  6199.   A precise technical term denoting the normal destination for output from a
  6200.   command or program, which is your terminal screen by default, but which can
  6201.   be redirected to a file.
  6202.  
  6203. Stdout
  6204.   Abbreviation for Standard Output.
  6205.  
  6206. Stdio
  6207.   Abbreviation for Standard Input / Standard Output.
  6208.  
  6209. I/O
  6210.   Abbreviation for Input / Output.
  6211.  
  6212. Shell
  6213.   Text-based system command processer, such as the UNIX shell, DOS
  6214.   COMMAND.COM, etc.
  6215.  
  6216. Pipe
  6217.   A mechanism by which the standard output of one program is sent to
  6218.   the standard input of another.
  6219.  
  6220. Pipeline
  6221.   A series of programs connected by pipes.
  6222.  
  6223. 4.2.1.2. NOTATION
  6224.  
  6225. In command descriptions, "<command>" is replaced by a shell or system command
  6226. or pipeline.  The command names specified in these commands are interpreted by
  6227. your shell, just as if you were typing them at the shell prompt, and so if
  6228. they are in your PATH, they will be found in the expected manner.  Therefore
  6229. you don't have to specify complete pathnames for commands that are programs
  6230. (but it shouldn't hurt if you do).
  6231.  
  6232. The normal notation for I/O redirection is as follows:
  6233.  
  6234.   <  Read Stdin from the given file.
  6235.   >  Send Stdout to the given file.
  6236.   |  Send Stdout from the command on the left to the command on the right.
  6237.  
  6238. Examples:
  6239.  
  6240. sort < foo > bar
  6241.   Sorts the lines in file "foo" and writes the results to file "bar"
  6242.  
  6243. grep -c "some text" *.txt | grep -v ":0" | sort | pr -3 | lpr
  6244.   This is a command pipeline composed of 5 commands:
  6245.  
  6246.   grep -c "some text" *.txt
  6247.     Looks in all files whose names end with ".txt" for the string "some text"
  6248.     and writes to Stdout the names of each file followed by a colon and the
  6249.     number of occurrences in each.
  6250.  
  6251.   grep -v ":0"
  6252.     Prints to Stdout the lines from Stdin that do NOT contain the string ":0",
  6253.     in this case, it removes the names of files that do not contain "some
  6254.     text".
  6255.  
  6256.   sort
  6257.     Sorts the lines from Stdin alphabetically to Stdout.
  6258.  
  6259.   pr -3
  6260.     Arranges the lines from Stdin in three columns.
  6261.  
  6262.   lpr
  6263.     Prints its Stdin on the default printer.
  6264.  
  6265. Note that the Kermit features described here work only with commands that use
  6266. Stdio.  If you attempt to use them with commands whose input and output can
  6267. not be redirected, Kermit will most likely get stuck.  Kermit has no way of
  6268. telling how an external command works, nor what the syntax of the shell is, so
  6269. it's up to you to make sure you use these features only with redirectable
  6270. commands.
  6271.  
  6272. The quoting rules of your shell apply to the <command>.  Thus in UNIX, where
  6273. C-Kermit tries to use your preferred shell for running commands, shell
  6274. "metacharacters" within commands must be escaped if they are to be taken
  6275. literally, using the methods normal for your shell.  For example, the UNIX tr
  6276. (translate) command must have its arguments in quotes:
  6277.  
  6278.   tr "[a-z]" "[A-Z]"
  6279.  
  6280. otherwise the shell is likely to replace them by all filenames that match,
  6281. which is probably not what you want.  This is also true when using your shell
  6282. directly, and has nothing to do with Kermit.
  6283.  
  6284. 4.2.1.3. SECURITY
  6285.  
  6286. Some sites might not wish to allow access to system commands or external
  6287. programs from within Kermit.  Such access, including all the features
  6288. described here, can be disabled in various ways:
  6289.  
  6290.  1. When building from source code, include -DNOPUSH among the CFLAGS.
  6291.  2. At runtime, give the NOPUSH command.
  6292.  3. For server mode, give the DISABLE HOST command.
  6293.  4. Implicit use of pipes can be disabled as described in section 4.2.4.
  6294.  
  6295. Note: 3 and 4 are not necessary if you have done 1 or 2.
  6296.  
  6297. 4.2.2. Commands for Transferring from and to Pipes
  6298.  
  6299. SEND /COMMAND sends data from a command or command pipeline, and RECEIVE
  6300. /COMMENT writes data to a command or pipeline.  The GET /COMMAND command
  6301. asks a server to send material, and then writes the incoming material to a
  6302. command or pipeline.  These features, along with switches (like "/COMMAND",
  6303. described in section 4.7) are new to C-Kermit 6.1.  The following synonyms
  6304. are also provided:
  6305.  
  6306.   CSEND    = SEND /COMMAND
  6307.   CRECEIVE = RECEIVE /COMMAND
  6308.   CGET     = GET /COMMAND
  6309.  
  6310. None of these commands can be used if a SEND or RECEIVE FILTER (respectively,
  6311. Section 4.2.3) is in effect, or if a NOPUSH command (Section 4.2.1.3) has been
  6312. given, or if the current protocol is not Kermit.
  6313.  
  6314. 4.2.2.1. Sending from a Command
  6315.  
  6316. SEND /COMMAND <command> [ <as-name> ]
  6317. SEND /AS-NAME:<as-name> /COMMAND <command>
  6318. CSEND <command> [ <as-name> ]
  6319.   These three forms are the same.  They work like the SEND command, but
  6320.   instead of sending a file, it sends the standard output of the given
  6321.   <command>, either under the command's own name, or else with the given
  6322.   <as-name>.  If the <command> contains spaces, it must be enclosed in braces.
  6323.   Braces should also be used for the <as-name> if it contains spaces.  If
  6324.   braces are included around either the <command> or the <as-name>, they are
  6325.   removed after parsing but before use.  As with SEND, the transfer is in text
  6326.   or binary mode according the current FILE TYPE setting, unless you override
  6327.   the global transfer mode by including a /TEXT or /BINARY switch.  The
  6328.   <command> must require no input.
  6329.  
  6330. When sending from a command or pipeline, C-Kermit has no way of knowing
  6331. in advance how much data will be sent, and so it can not send the size
  6332. to the other Kermit in the Attribute packet, and so the receiving Kermit
  6333. has no way of displaying "percent done" or a progress bar (thermometer).
  6334.  
  6335. Examples that make sense in text mode (illustrated by common UNIX commands):
  6336.  
  6337.   SEND /COMMAND finger
  6338.   CSEND finger
  6339.     sends the current "finger" listing (who's logged in) under the
  6340.     name "finger".  The two forms "send /command" and "csend" are
  6341.     equivalent; we won't bother showing them both in the rest of the
  6342.     examples.
  6343.  
  6344.   SEND /COMMAND:{finger}
  6345.   CSEND {finger}
  6346.     Same as previous example (braces are removed from "{finger}").
  6347.  
  6348.   SEND /COMMAND:{ finger }
  6349.   CSEND { finger }
  6350.     Same as previous example, but note that the spaces are kept.  This
  6351.     does not prevent the shell from running the "finger" program, but
  6352.     its output is sent under the name " finger " (with a leading and
  6353.     trailing space).
  6354.  
  6355.   SEND /COMMAND:finger /AS-NAME:userlist
  6356.   CSEND finger userlist
  6357.     sends the current finger listing under the name "userlist".
  6358.  
  6359.   SEND /COMMAND:{finger | sort -r} /AS-NAME:userlist
  6360.   CSEND {finger | sort -r} userlist
  6361.     sends the current finger listing, sorted in reverse order, under the
  6362.     name "userlist".  The braces are needed to distinguish the <command>
  6363.     from the <as-name>.
  6364.  
  6365.   SEND /COMMAND:{finger | sort -r} /AS-NAME:{userlist}
  6366.   CSEND {finger | sort -r} {userlist}
  6367.     Same as previous example (braces are removed from "{userlist}").
  6368.  
  6369.   SEND /COMMAND:{finger | sort -r} /AS-NAME:{\freplace(\v(filename),\32,_)}
  6370.   CSEND {finger | sort -r} {\freplace(\v(filename),\32,_)}
  6371.     Like the previous example, but sends the output of the <command> under
  6372.     the name of the command, but with all spaces (\32) replaced by underscores,
  6373.     so the as-name is "finger_|_sort_-r".
  6374.  
  6375.   Examples that make sense in binary mode (three equivalent forms are shown):
  6376.  
  6377.   SEND /COMMAND /BINARY {tar cf - . | gzip -c} mydir.tar.gz
  6378.   SEND /COMMAND /BINARY /AS-NAME:mydir.tar.gz {tar cf - . | gzip -c}
  6379.   CSEND /BINARY {tar cf - . | gzip -c} mydir.tar.gz
  6380.     Makes a tar archive of the current directory, compresses it with the GNU
  6381.     gzip program, and sends it as "mydir.tar.gz".  The other Kermit can, of
  6382.     course, just store it as a file, or it can use CRECEIVE to uncompress and
  6383.     dearchive it as part of the transfer process.
  6384.  
  6385. When using a "pipeline" of commands in the <command> field, obviously,
  6386. the first command must not require any input, and the last command should
  6387. produce some output, and all intermediate commands should get some input and
  6388. produce some output.
  6389.  
  6390. 4.2.2.2. Receiving to a Command
  6391.  
  6392. RECEIVE /COMMAND <command>
  6393. CRECEIVE <command>
  6394.   This is like RECEIVE, except incoming material is written to the standard
  6395.   input of the given command, in text or binary mode according to the normal
  6396.   rules for file reception.  Be sure to include a redirector to a file (if the
  6397.   command normally writes to standard output), or the output of the command
  6398.   won't go anywhere.  The <command> may contain spaces; braces are not needed,
  6399.   but they are removed if used.
  6400.  
  6401. WARNING: C-Kermit has no way of knowing anything about the <command>, or even
  6402. whether it is a command.  Thus this command will always cause C-Kermit to
  6403. enter protocol mode, as long as some text is specified in the <command> field.
  6404. However, if the text does not correspond to a command, the transfer will
  6405. eventually fail with a message such as "Error writing data" or "Failure to
  6406. close file".
  6407.  
  6408. Examples for text mode (in UNIX):
  6409.  
  6410.   RECEIVE /COMMAND sort -r > reverse.txt
  6411.   CRECEIVE sort -r > reverse.txt
  6412.     The text that is received is sorted in reverse order and stored in
  6413.     the file "reverse.txt".  The two forms shown are equivalent.
  6414.  
  6415.   RECEIVE /COMMAND {sort -r > reverse.txt}
  6416.   CRECEIVE {sort -r > reverse.txt}
  6417.     The same as the previous example; if braces are included, they are
  6418.     simply removed.
  6419.  
  6420.   RECEIVE /COMMAND {sort -r > \flower(\v(filename)).reverse}
  6421.   CRECEIVE {sort -r > \flower(\v(filename)).reverse}
  6422.     Same but stores result under the incoming filename, lowercased, and
  6423.     with ".reverse" appended to it.
  6424.  
  6425.   RECEIVE /COMMAND sort
  6426.   CRECEIVE sort
  6427.     Does nothing useful, since the output of sort has nowhere to go.
  6428.  
  6429.   RECEIVE /COMMAND sort -r | pr -3 | lpr -Plaserjet
  6430.   CRECEIVE sort -r | pr -3 | lpr -Plaserjet
  6431.     The text that is received is sorted in reverse order, arranged into
  6432.     three columns, and sent to the "laserjet" printer.
  6433.  
  6434.   Examples for binary mode:
  6435.  
  6436.   RECEIVE /COMMAND:{gunzip -c | tar xf -}
  6437.   CRECEIVE {gunzip -c | tar xf -}
  6438.     Assuming the data that is received is a compressed tar archive,
  6439.     uncompresses the archive and passes it to tar for extraction.  In this
  6440.     case the braces are needed because otherwise the final "-" would be
  6441.     taken as a command continuation character (see "Using C-Kermit", 2nd
  6442.     Edition, p.33).
  6443.  
  6444. GET /COMMAND <remote-file> <command>
  6445. GET /COMMAND /AS-NAME:<command> <remote-file>
  6446. CGET <remote-file> <command>
  6447.   This command tells the Kermit client to send a GET request for the given
  6448.   remote file to a Kermit server.  Unlike GET, however, the incoming material
  6449.   is written to a command, rather than to a file.  If the <remote-file> or the
  6450.   <command> contain spaces, they must be enclosed in braces.  The same
  6451.   cautions about the <command> apply as for CRECEIVE.  Examples (for UNIX):
  6452.  
  6453.   GET /COMMAND oofa.txt sort -r > oofa.new
  6454.   GET /COMMAND {oofa.txt} {sort -r > oofa.new}
  6455.   CGET oofa.txt sort -r > oofa.new
  6456.   CGET {oofa.txt} {sort -r > oofa.new}
  6457.     These four are equivalent.  Each of them requests the server to send
  6458.     its "oofa.txt" file, and as it arrives, it is sorted in reverse order
  6459.     and written to "oofa.new".
  6460.  
  6461.   GET /COMMAND {profile exec a} lpr
  6462.   GET /COMMAND {profile exec a} {lpr}
  6463.   GET /COMMAND /AS-NAME:lpr {profile exec a}
  6464.   GET /COMMAND /AS-NAME:{lpr} {profile exec a}
  6465.   GET /COMMAND /AS:lpr {profile exec a}
  6466.   CGET {profile exec a} lpr
  6467.   CGET {profile exec a} {lpr}
  6468.     Here the remote filename contains spaces so it MUST be enclosed in
  6469.     braces.  As it arrives it is sent to the lpr program for printing.
  6470.     Braces are optional around "lpr" since it contains no spaces.
  6471.  
  6472.   GET /COMMAND *.txt {cat >> new.txt}
  6473.   GET /AS-NAME:{cat >> new.txt} /COMMAND *.txt
  6474.   CGET *.txt {cat >> new.txt}
  6475.     This gets all the ".txt" files from the server and concatenates them
  6476.     all into a single "new.txt" file on the client.
  6477.  
  6478.   GET /COMMAND *.txt {echo \v(filename)>>new.txt;cat>>new.txt}
  6479.   CGET *.txt {echo \v(filename)>>new.txt;cat>>new.txt}
  6480.     As above, but inserts each file's name before its contents.
  6481.  
  6482. 4.2.3. Using File-Transfer Filters
  6483.  
  6484. The commands described in section 4.2.2 let you send the output of a command,
  6485. or receive data into a command.  But what if you want to specify preprocessing
  6486. for files that you send, or postprocessing of files that you receive, even
  6487. when multiple files are involved?  For this you need a way to specify send and
  6488. receive filters.  The commands are SET SEND FILTER and SET RECEIVE FILTER;
  6489. SHOW PROTOCOL displays the current settings.
  6490.  
  6491. 4.2.3.1. The SEND Filter
  6492.  
  6493. SET SEND FILTER [ <command> ]
  6494.   This command specifies a <command> to be run on any file that you SEND (or
  6495.   MOVE, MSEND, etc).  It also applies to files sent when in server mode, in
  6496.   response to GET commands, but not to the results of REMOTE commands like
  6497.   REMOTE DIRECTORY, REMOTE TYPE, REMOTE HOST, etc.  The <command> may be, but
  6498.   need not be, enclosed in braces; if it is, the braces are stripped before
  6499.   use.  The output of this command is sent, rather than the file itself.  The
  6500.   current FILE TYPE setting (TEXT or BINARY) applies to the output of the
  6501.   command.  The <command> must contain at least one instance of \v(filename),
  6502.   for which the name of the actual file is substituted.  If the <command> is
  6503.   omitted, the send filter is removed and files are sent in the normal manner.
  6504.  
  6505. The SET SEND FILTER sets up a "global" filter -- that is, one that applies to
  6506. all subsequent file-sending commands until you change or remove it.  You can
  6507. also specify a "local" filter to be used in a specific file-sending command by
  6508. using the /FILTER switch (see section 1.5); for example:
  6509.  
  6510.   SEND /FILTER:<command> [ <other-switches> ] <filename>
  6511.  
  6512. Besides \v(filename), you can include any other script programming notation in
  6513. the send filter: variable names, array references, calls to built-in string or
  6514. other functions, and so on.  These are evaluated during file transfer, NOT
  6515. during parsing, and they are evaluated separately for each file.
  6516.  
  6517. When the SEND or MOVE (SEND /DELETE) command is used with a send filter, the
  6518. output from the filter is sent under the file's original name unless you
  6519. specify an "as-name" or template.  The Attribute packet (if any) contains the
  6520. original file's attributes (size, creation date, etc).  So (for example) if
  6521. the filter changes the file's size, the progress thermometer might be wrong.
  6522. (We can't send the size of the output from the filter, because it is not known
  6523. until the transfer is finished.)  If you prefer that the size not be sent, use
  6524. "set attributes size off".
  6525.  
  6526. You can not use send filters with RESEND (SEND /RECOVER) or PSEND
  6527. (SEND /START).
  6528.  
  6529. Examples for text mode:
  6530.  
  6531.   SET SEND FILTER sort -r \v(filename)     ; Braces may be omitted
  6532.   SET SEND FILTER {sort -r \v(filename)}   ; Braces may be included
  6533.   SEND *.txt
  6534.     This sends every file in the current directory whose name ends with
  6535.     ".txt" under its own name, but with its lines sorted in reverse order.
  6536.  
  6537.   SEND /FILTER:{sort -r \v(filename)} *.txt
  6538.     Same as above, but the filter applies only to this SEND command.
  6539.     Braces are required in this case.
  6540.  
  6541.   SET SEND FILTER {sort -r \v(filename)}
  6542.   SEND oofa.txt reverse.txt
  6543.     Sends the oofa.txt file with its lines sorted in reverse order under
  6544.     the name "reverse.txt".
  6545.  
  6546.   SET SEND FILTER {sort -r \v(filename)}
  6547.   SEND oofa.* \v(filename).reverse
  6548.     Sends all the oofa.* files with their lines sorted in reverse order;
  6549.     each file is sent under its own name but with ".reverse" appended to it.
  6550.  
  6551.   SET SEND FILTER {tr "[a-z]" "[A-Z]" < \v(filename)}
  6552.   SEND *.txt
  6553.     Sends all ".txt" files under their own names, but uppercasing their
  6554.     contents.
  6555.  
  6556. Note that the SEND FILTER applies not only to files that are sent with
  6557. SEND, MOVE, MSEND, etc, but also to files sent by the C-Kermit server in
  6558. response to GET requests.
  6559.  
  6560. Examples for binary mode:
  6561.  
  6562.   SET SEND FILTER {gzip -c \v(filename)}
  6563.   SEND /BINARY oofa.txt oofa.txt.gz
  6564.     Sends the oofa.txt file, compressed by gzip, as oofa.txt.gz.
  6565.  
  6566.   SEND /BINARY /FILTER:{gzip -c \v(filename)} oofa.txt oofa.txt.gz
  6567.     As above, but the filter applies only to this SEND command.
  6568.  
  6569.   SET SEND FILTER {gzip -c \v(filename)}
  6570.   SEND /BINARY oofa.* \fupper(\replace(\v(filename),.,_)).GZ
  6571.     Sends all the oofa.* files, compressed by gzip, each under its own name,
  6572.     but with the name uppercased, all periods within the name converted to
  6573.     underscores, and ".GZ" appended to it.  So, for example, "oofa.txt"
  6574.     is sent as "OOFA_TXT.GZ".
  6575.  
  6576. In the gzip examples, note that the amount of data that is sent is normally
  6577. less than the original file size because gzip compresses the file.  But Kermit
  6578. sends the original file size ahead in the attribute packet anyway (unless you
  6579. tell it not too).  Thus the transfer will probably appear to terminate early,
  6580. e.g. when the receiver's file-transfer display thermometer is only at 40%.
  6581. If this annoys you, tell Kermit to "set attribute length off".  On the other
  6582. hand, you can use the final position of the thermometer as a measure of the
  6583. effectiveness of compression.
  6584.  
  6585. 4.2.3.2. The RECEIVE Filter
  6586.  
  6587. SET RECEIVE FILTER [ <command> ]
  6588.   This command specifies that the given <command> will be run on any file
  6589.   that is received before it is written to disk.  The <command> may be, but
  6590.   need not be, enclosed in braces; if it is the braces are stripped before
  6591.   use.  The following two commands are equivalent:
  6592.  
  6593.     SET RECEIVE FILTER sort -r > \v(filename)
  6594.     SET RECEIVE FILTER {sort -r > \v(filename)}
  6595.  
  6596.   The RECEIVE filter <command> may contain a "\v(filename)" sequence to be
  6597.   replaced by the incoming filename from the file header packet, but it is not
  6598.   required.  However you must use it whenever your filter would normally write
  6599.   to Stdout, otherwise its output will be lost.
  6600.  
  6601.   The RECEIVE filter <command> may contain one or more "\v(filename)"
  6602.   sequence to be replaced by the incoming filename from the file header
  6603.   packet, but it is not required.  However you must use it whenever your
  6604.   filter would normally write to Stdout, otherwise its output will be lost.
  6605.  
  6606. RECEIVE /FILTER:<command> and GET /FILTER:<command> can also be used to
  6607. specify a filter to be used for only one file-transfer operation.
  6608.  
  6609. UNIX examples for text mode:
  6610.  
  6611.   SET RECEIVE FILTER lpr
  6612.   RECEIVE
  6613.     All the files that are received are sent to the default UNIX print
  6614.     spooler.
  6615.  
  6616.   RECEIVE /FILTER:lpr
  6617.     Same as above, except the lpr filter is used only with this
  6618.     RECEIVE command.
  6619.  
  6620.   RECEIVE lpr
  6621.     This is probably not what you want; it creates a file called lpr.
  6622.  
  6623.   SET RECEIVE FILTER {sort -r > \v(filename)}
  6624.   RECEIVE
  6625.     Stores each incoming file with its lines sorted in reverse order,
  6626.     under its own name.
  6627.  
  6628.   RECEIVE /FILTER:{sort -r > \v(filename)}
  6629.     As above, but the filter is used only for this RECEIVE command.
  6630.  
  6631.   SET RECEIVE FILTER sort -r > \v(filename)
  6632.   RECEIVE reverse.txt
  6633.     Stores each incoming file with its lines sorted in reverse order,
  6634.     under the name "reverse.txt".  The actual result depends on the
  6635.     FILE COLLISION setting.  If it is OVERWRITE and multiple files arrive,
  6636.     then each incoming file destroys the previous one.  If it is BACKUP
  6637.     (the default), filename conflicts are resolve by adding "version numbers"
  6638.     to the filenames: reverse.txt, reverse.txt.~1~, reverse.txt.~2~, etc.
  6639.  
  6640.   SET RECEIVE FILTER sort -r > \v(filename)
  6641.   RECEIVE \v(filename).reverse
  6642.     Stores each incoming file with its lines sorted in reverse order,
  6643.     under the name it arrived with, but with ".reverse" appended to it.
  6644.  
  6645.   SET RECEIVE FILTER sort -r > \v(filename)
  6646.   RECEIVE \flower(\v(filename)).reverse
  6647.     Like the previous example, but ensures that the filename is lowercase.
  6648.  
  6649. Examples for binary mode:
  6650.  
  6651.   SET RECEIVE FILTER gunzip -c > \v(filename)
  6652.   RECEIVE
  6653.     This receives one or more presumably compressed file and uncompresses
  6654.     each one into a file having the same name it was sent with.  For example,
  6655.     if the file is sent with the name OOFA.TXT.GZ, it is stored with that
  6656.     name, even after decompression.
  6657.  
  6658.   SET RECEIVE FILTER gunzip -c > \v(filename)
  6659.   RECEIVE \flower(\fsubstring(\v(filename),1,\flength(\v(filename))-3))
  6660.     Like the previous example, but the resulting filename has its rightmost
  6661.     three characters removed from it and the remainder is lowercased.  So if
  6662.     the incoming filename is OOFA.TXT.GZ, it is stored as oofa.txt after
  6663.     decompression.
  6664.  
  6665. Of course you don't want to type such long hideous commands, so we have also
  6666. introduced several new functions:
  6667.  
  6668. \fstripx(string[,character])
  6669.    This function removes the rightmost segment of the string that starts with
  6670.    the given character.  If no character is given, period (.) is used.  Thus
  6671.    it is most conveniently used for stripping the extension from a filename
  6672.    (or the decimal portion from a floating-point number written in US/UK
  6673.    style).  Examples:
  6674.  
  6675.      \fstripx(OOFA.TXT.GZ)             => OOFA.TXT
  6676.      \fstripx(OOFA.TXT.GZ,.)           => OOFA.TXT
  6677.      \fstripx(OOFA.TXT.GZ,X)           => OOFA.T
  6678.      \fstripx(\fstripx(OOFA.TXT.GZ))   => OOFA
  6679.      \fstripx($100.00)                 => $100
  6680.  
  6681. \fstripn(string,number)
  6682.    Removes the rightmost <number> characters from the string.  Examples:
  6683.  
  6684.      \fstripn(OOFA.TXT.GZ)             => OOFA.TXT.GZ
  6685.      \fstripn(OOFA.TXT.GZ,3)           => OOFA.TXT
  6686.      \fstripn(OOFA.TXT.GZ,7)           => OOFA
  6687.  
  6688. \fstripb(string[,c1[,c2]])
  6689.    Strips enclosing matching braces, brackets, parentheses, or quotes from
  6690.    the string.  The second argument, c1, specifies which kind of enclosure
  6691.    to look for; if not specified, any enclosing (), [], <>, {}, "", '', or
  6692.    `' are removed.  If c1 is specified and c2 is not, then if c1 is an
  6693.    opening brace, bracket, or parenthesis, the matching closing one is
  6694.    supplied automatically as c2.  If both c1 and c2 are specified, then to
  6695.    be stripped the string must begin with c1 and end with c2.  If the
  6696.    string is not enclosed in the indicated manner, the result is the
  6697.    original string.  Examples:
  6698.  
  6699.      \fstripb("abc")                   => abc
  6700.      \fstripb([abc])                   => abc
  6701.      \fstripb([abc)                    => [abc
  6702.      \fstripb(<abc>)                   => abc
  6703.      \fstripb(<abc>,[)                 => <abc>
  6704.      \fstripb((abc))                   => abc
  6705.      \fstripb((abc),[)                 => (abc)
  6706.      \fstripb((abc),{(})               => abc
  6707.      \fstripb(+abc+)                   => +abc+
  6708.      \fstripb(+abc+,+)                 => abc
  6709.      \fstripb(+abc+,+,^)               => +abc+
  6710.      \fstripb(+abc^,+,^)               => abc
  6711.      \fstripb('abc')                   => abc
  6712.      \fstripb(`abc')                   => abc
  6713.      \fstripb(``abc'')                 => `abc'
  6714.      \fstripb(\fstripb(``abc''))       => abc
  6715.  
  6716.    Notice the special syntax required for including a literal parenthesis
  6717.    in the argument list.  As the last two examples illustrate, \fstripb()
  6718.    strips only one level at at a time; nesting can be used to strip a small
  6719.    fixed number of levels; loops can be used to strip larger or indeterminate
  6720.    numbers of levels.
  6721.  
  6722. \flop(string[,char])
  6723.    Removes the leftmost segment of the string that ends with the given
  6724.    character.  If no character is given, period (.) is used.  Examples:
  6725.  
  6726.      \flop(OOFA.TXT.GZ)               => TXT.GZ
  6727.      \flop(OOFA.TXT.GZ,.)             => TXT.GZ
  6728.      \flop(OOFA.TXT.GZ,X)             => T.GZ
  6729.  
  6730. To remove the leftmost <number> characters, just use \fsubstring(s,<number>+1).
  6731. To return the rightmost <number> characters, use \fright(s,<number>).
  6732.  
  6733. So the hideous example:
  6734.  
  6735.   receive \flower(\fsubstring(\v(filename),1,\flength(\v(filename))-3))
  6736.  
  6737. can now be written as:
  6738.  
  6739.   receive \flower(\fstripx(\v(filename)))
  6740.  
  6741. That is, the filename stripped of its extension and then lowercased.  This
  6742. is not only shorter and less hideous, but also does not depend on the
  6743. length of the extension being 3.
  6744.  
  6745. Note that when a receive filter is in effect, this overrides your FILE
  6746. COLLISION setting, since Kermit has no way of knowing what the final
  6747. destination filename will be (because it does not know, and can not be
  6748. expected to know, the syntax of every version of every command shell on
  6749. every platform on the planet).
  6750.  
  6751. 4.2.4. Implicit Use of Pipes
  6752.  
  6753. If you wish, C-Kermit can also examine incoming filenames to see if they
  6754. start with "!", and if so, the subsequent text is treated as a command to
  6755. read from or write to.  For example, if a Kermit client is given the following
  6756. command:
  6757.  
  6758.   get {!finger | sort}
  6759.  
  6760. the server on the other end, if it supports this feature, will run the
  6761. "finger" program, pipe its standard output to the "sort" program, and send
  6762. sort's standard output back to you.  Similarly, if you:
  6763.  
  6764.   send oofa.txt !sort -r > oofa.new
  6765.  
  6766. or, equivalently:
  6767.  
  6768.   send oofa.txt {!sort -r > oofa.new}
  6769.  
  6770. or:
  6771.  
  6772.   send /as-name:{!sort -r > oofa.new} oofa.txt
  6773.  
  6774. this has the receiver send the contents of the incoming oofa.txt file to
  6775. the sort program, which sorts the text in reverse order and stores the
  6776. result in oofa.new.
  6777.  
  6778. This use of the exclamation mark should be familiar to UNIX users as the
  6779. "bang" feature that lets you run an external application or command from
  6780. within another application.
  6781.  
  6782. Kermit's "bang" feature is disabled by default, since it is not unheard for
  6783. filenames to actually begin with "!".  So if you want to use this feature,
  6784. you must enable it with the following command:
  6785.  
  6786. SET TRANSFER PIPES { ON, OFF }
  6787.   ON enables the recognition of "!" notation in incoming filenames during
  6788.   file transfer as an indicator that the remaining text is the name of a
  6789.   command.  OFF, the default, disables this feature and uses the text as
  6790.   a filename in the normal fashion.  This command does NOT affect SEND
  6791.   /COMMAND, GET /COMMAND, CSEND, etc.
  6792.  
  6793. So using a combination of CSEND (SEND /COMMAND) and the "bang" feature, you
  6794. can transfer a directory tree all in one command (assuming the remote
  6795. Kermit supports pipe transfers and has them enabled):
  6796.  
  6797.   CSEND {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  6798.  
  6799. or:
  6800.  
  6801.   SEND /COMMAND:{tar cf - . | gzip -c} /as:{!gunzip -c | tar xf -}
  6802.  
  6803. Pay close attention to the syntax.  Braces are needed around the <command>
  6804. because it contains spaces; braces are needed around the <as-name> because
  6805. it ends with "-".  The <as-name> must begin with "!" or receiving Kermit will
  6806. not recognize it as a command.  The CSEND command must NOT begin with "!"
  6807. unless you are running a command whose name really does start that character.
  6808.  
  6809. Similarly, you have a Kermit server send a directory tree to be unpacked
  6810. on the client end:
  6811.  
  6812.   CGET {!tar cf - . | gzip -c} {gunzip -c | tar xf -}
  6813.  
  6814. or:
  6815.  
  6816.   GET /COMMAND {!tar cf - . | gzip -c} /as:{gunzip -c | tar xf -}
  6817.  
  6818. Notice how, in this case, the bang is required in the remote command, to
  6819. distinguish it from a filename, but not in the local command, since by
  6820. definition of CGET (or GET /COMMAND), it is known to be a command.
  6821.  
  6822. SEND and RECEIVE FILTERs supersede the bang feature.  For example, if a
  6823. file arrives under the name "!gunzip -c | tar xf -", but the receiving Kermit
  6824. also has been given a command like:
  6825.  
  6826.   set receive filter sort -r > \v(filename)
  6827.  
  6828. then the incoming data will be sorted rather than gunzipped.
  6829.  
  6830. Finally, if SET TRANSFER PIPES is ON (and in this case, this must be done in
  6831. your C-Kermit initialization file), you can send from a pipe on the C-Kermit
  6832. command line:
  6833.  
  6834.   kermit -s "!finger | sort -r" -a userlist
  6835.  
  6836. In this case the "filename" contains spaces and so must be quoting using
  6837. your shell's quoting rules.
  6838.  
  6839. 4.2.5. Success and Failure of Piped Commands
  6840.  
  6841. Commands or programs started by Kermit as a result of CSEND or CRECEIVE
  6842. commands, CGET, SEND /COMMAND, REDIRECT commands (see section 4.2.8.2),
  6843. implicit use of pipes, RUN commands, and so forth, should return their exit
  6844. status codes to the Kermit command that caused them to be run, and
  6845. therefore IF SUCCESS and IF FAILURE tests after these commands should work
  6846. as expected.  For example:
  6847.  
  6848.   CSEND blah < filename
  6849.  
  6850. should fail if there is no command called "blah" or if there is no file called
  6851. "filename".  However, this is not foolproof and sometimes C-Kermit might think
  6852. a command succeeded when it failed, or vice versa.  This is most likely to
  6853. happen when the highly system-dependent methods that Kermit must use to
  6854. determine a command's exit status code do not supply the right information.
  6855.  
  6856. It can also happen because some commands might define success and failure
  6857. differently from what you expect, or because you are using a pipeline composed
  6858. of many commands, and one of them fails to pass failing exit status codes up
  6859. the chain.  The most likely culprit is the shell itself, which in most cases
  6860. must be interposed between Kermit and any external program to be run.
  6861.  
  6862. In any case, you can examine the following variable to find out the exit
  6863. status code returned to Kermit by the process most recently run by any command
  6864. that runs external commands or programs, including CSEND, CRECEIVE, REDIRECT,
  6865. RUN, etc:
  6866.  
  6867.   \v(pexitstat)
  6868.  
  6869. In UNIX, Windows and OS/2, the value should be -2 if no command has been run
  6870. yet, 0 if the most recent command succeeded, -1, -3, or -4 if there was an
  6871. internal error, and a positive number returned by the command itself if the
  6872. command failed.  If the number is in the range 1-127, this is the program's
  6873. exit status code.  If it is 128 or greater, this is supposed to indicate that
  6874. the command or program was interrupted or terminated from outside itself.
  6875.  
  6876. In Windows 95 and 98, the return values of the default shell are unreliable;
  6877. various third-party shells can be used to work around this deficiency.
  6878.  
  6879. In VMS, it is the actual exit status code of the command that was run.  This
  6880. is an odd number if the command succeeded, and an even number if it failed.
  6881. You can see the associated message as follows:
  6882.  
  6883.   run write sys$output f$message(\v(pexitstat))
  6884.  
  6885. Or, more conveniently, use the new Kermit function:
  6886.  
  6887.   echo \ferrstring(\v(pexitstat))
  6888.  
  6889. which converts a system error code (number) to the corresponding message.
  6890.  
  6891. 4.2.6. Cautions about Using Pipes to Transfer Directory Trees
  6892.  
  6893. Although utilities such as tar and zip/unzip might be available on different
  6894. platforms (such as UNIX and Windows), this does not necessarily mean you can
  6895. use them successfully to transfer directory trees between unlike platforms.
  6896. For example:
  6897.  
  6898.   CSEND {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  6899.  
  6900. when used from UNIX to Windows will have satisfactory results for binary
  6901. files, but not for text files.  UNIX text files have lines ending with
  6902. Linefeed (LF) only, whereas Windows text files have lines ending in Carriage
  6903. Return and Linefeed (CRLF).  Thus any text files that were in the archive
  6904. formed by the first tar command will be unpacked by the second tar command
  6905. in their original form, and will display and print incorrectly in Windows
  6906. (except in applications that have been explicitly coded to handle UNIX-format
  6907. text files).  On the other hand if you told gzip to use "text mode" to do
  6908. record format conversion (assuming there was a way to tell it, as there is
  6909. with most "zip" programs), this would destroy any binary files in the archive.
  6910.  
  6911. Furthermore, if the archive contains text files that are written in languages
  6912. other than English, the "special" (accented and/or non-Roman) characters are
  6913. NOT translated, and are therefore likely show up as gibberish on the target
  6914. system.  For example, West European languages are usually encoded in ISO Latin
  6915. Alphabet 1 in UNIX, but in PC code page 850 on the PC.  Capital A with acute
  6916. accent is code point 193 (decimal) Latin-1, but 181 in CP850.  So A-acute in
  6917. the UNIX file becomes Middle Box Bottom on the PC, and similarly for all the
  6918. other special characters, and for all other languages -- Greek, Russian,
  6919. Hebrew, Japanese, etc.
  6920.  
  6921. So when transferring text files between unlike platforms, you should use
  6922. direct Kermit file transfers so Kermit can apply the needed record-format and
  6923. character-set transformations.  Use pipelines containing archivers like tar or
  6924. zip only if all the files are binary or the two systems use the same record
  6925. format and character set for text files.
  6926.  
  6927. Also see sections 4.3, 4.10, 4.11, and 4.15 for how to transfer directory
  6928. trees between both like and unlike systems directly with Kermit.
  6929.  
  6930. 4.2.7. Pipes and Encryption
  6931.  
  6932. Of course pipelines could be used for encrypted file transfers, assuming
  6933. proper precautions could be taken concerning the transmission of the key.
  6934. But there is rarely a good way to do this.  To illustrate using UNIX crypt:
  6935.  
  6936.   csend {crypt key < filename} {!crypt key > filename}
  6937.  
  6938. Or, more ambitiously:
  6939.  
  6940.   csend {tar cf - . | gzip -c | crypt key} {!crypt key | gunzip -c | tar xf -}
  6941.  
  6942. transmits the key in the file header packet as part of the (clear-text) remote
  6943. command, defeating the entire purpose of encrypting the file data.
  6944.  
  6945. But if you are connected in terminal mode to the remote computer and type:
  6946.  
  6947.   creceive {crypt key > filename}
  6948.  
  6949. at the remote Kermit prompt, you have also transmitted the key in clear text
  6950. over the communications link.
  6951.  
  6952. At present, the only secure way to use CSEND and CRECEIVE with an encryption
  6953. filter is to have a human operator at both ends, so the key does not have to
  6954. be transmitted.
  6955.  
  6956. Theoretically it would be possible to use PGP software (Pretty Good Privacy,
  6957. by Phil Zimmerman, Phil's Pretty Good Software) to avoid key transmission
  6958. (since PGP uses separate public and private key and "lets you communicate
  6959. securely with people you've never met, with no secure channels needed for
  6960. prior exchange of keys"), but the specific method has yet to be worked out.
  6961.  
  6962.   HINT: See the PGP User's Guide, e.g. at:
  6963.   http://www.telstra.com.au/docs/PGP/
  6964.   Especially the topic "Using PGP as a UNIX-Style Filter":
  6965.   http://www.telstra.com.au/docs/PGP/pgpdoc2/pgpdoc2_17.html
  6966.  
  6967. In any case, better and more convenient security options are now available:
  6968. Kerberos authentication and encryption (described in the kerberos.txt file)
  6969. and the new ability to run C-Kermit "though" other communication programs,
  6970. described in Section 2.7.
  6971.  
  6972. 4.2.8. Commands and Functions Related to Pipes
  6973.  
  6974. 4.2.8.1. The OPEN !READ and OPEN !WRITE Commands
  6975.  
  6976. These are described in "Using C-Kermit", and are generally useful with reading
  6977. output from commands that produce more than one line on their standard output,
  6978. or writing multiple lines into commands that accept them on their standard
  6979. input.
  6980.  
  6981. In C-Kermit 7.0 CLOSE !READ is accepted as a synonym for CLOSE READ, and
  6982. CLOSE !WRITE for CLOSE WRITE.
  6983.  
  6984. Testing the success and failure of these commands, however, can be a bit
  6985. tricky.  Consider:
  6986.  
  6987.   open !read lalaskjfsldkfjsldkfj
  6988.  
  6989. (where "lalaskjfsldkfjsldkfj" is neither a valid command nor the name of a
  6990. program or script that can be run).  OPEN !READ, in UNIX at least, translates
  6991. this into execl(shellpath,shellname,"-c",command).  This means it starts your
  6992. preferred shell (e.g. from the SHELL environment variable) and asks it to
  6993. execute the given command.  It must be this way, because your command can be a
  6994. either an internal shell command (which only your shell can execute) or an
  6995. external command, which only your shell knows how to find (it knows your PATH
  6996. and interprets, etc).  Therefore unless OPEN !READ can't start your shell,
  6997. it always succeeds.
  6998.  
  6999. Continuing with the nonexistent-command example:
  7000.  
  7001.   C-Kermit>open !read lalaskjfsldkfjsldkfj
  7002.   C-Kermit>status
  7003.    SUCCESS
  7004.   C-Kermit>read line
  7005.   C-Kermit>status
  7006.    SUCCESS
  7007.   C-Kermit>echo "\m(line)"
  7008.   "bash: lalaskjfsldkfjsldkfj: command not found"
  7009.   C-Kermit>close read
  7010.   C-Kermit>status
  7011.    FAILURE
  7012.   C-Kermit>
  7013.  
  7014. In other words, the failure can not be detected on OPEN, since the OPEN
  7015. command succeeds if it can start your shell.  It can't be detected on READ,
  7016. since all this does is read output from the shell, which in this case happens
  7017. to be an error message.  However, failure IS detected upon close, since this
  7018. is the occasion upon which the shell gives Kermit its exit status code.
  7019.  
  7020. For an illustration of this situation, see Section 2.14.
  7021.  
  7022. 4.2.8.2. The REDIRECT Command
  7023.  
  7024. A second method of I/O redirection is offered by the REDIRECT command.
  7025. This is a rather advanced and tricky feature that is presently supported
  7026. only in UNIX C-Kermit, in OS-9 C-Kermit, and in Kermit 95.  Syntax:
  7027.  
  7028. REDIRECT <command>
  7029.   Runs the given <command>, sending its standard output to the current
  7030.   communications channel (SET LINE, SET PORT, or SET HOST connection),
  7031.   and reading its standard input from the same connection.  Works only in
  7032.   local mode -- i.e. a connection is required -- and then only if the given
  7033.   command uses Standard I/O.
  7034.  
  7035. Example:
  7036.  
  7037.   redirect finger
  7038.  
  7039. runs the local "finger" command and sends its output over the connection as
  7040. plain text, where presumably there is a process set up to read it.  Another
  7041. example:
  7042.  
  7043.   redirect finger | sort -r
  7044.  
  7045. shows the use of a pipeline.
  7046.  
  7047. Note: REDIRECT differs from CSEND/CRECEIVE in two important ways: (1) it does
  7048. not use the Kermit protocol, and (2) it uses a bidirectional pipe rather than
  7049. a one-way pipe.
  7050.  
  7051. The primary use of the REDIRECT command is to run external protocols, such as
  7052. sz/rz in UNIX for ZMODEM, when they work over Standard I/O(*).  Example:
  7053.  
  7054.   set host xyzcorp.com
  7055.   (login, etc)
  7056.   redirect sz oofa.zip
  7057.  
  7058. lets you make a Telnet connection with C-Kermit and then do a ZMODEM transfer
  7059. over it.  ZMODEM protocol messages go both ways over the same connection
  7060. simultaneously.
  7061.  
  7062. It is possible to use C-Kermit on UNIX as your PPP dialer and then to REDIRECT
  7063. the connection to the PPP software, but C-Kermit 7.0 offers a better approach
  7064. to PPP dialing in its new EXEC command (Section 1.23).
  7065.  
  7066. In theory, you can also redirect an interactive process.  For example, suppose
  7067. you tell Kermit 95 to wait for an incoming TCP/IP connection:
  7068.  
  7069.   set host * 3000
  7070.  
  7071. and then tell C-Kermit on UNIX to:
  7072.  
  7073.   set host kermit95hostname 3000
  7074.   redirect ksh
  7075.  
  7076. and then tell Kermit 95 to CONNECT: now you are talking to the UNIX K-shell;
  7077. you can give commands (pwd, ls, etc) and see the results.  In practice, the
  7078. K-shell's terminal modes are messed up because (a) it is not going through the
  7079. Unix terminal driver, and (b) it is "smart" and knows it is being redirected,
  7080. and so acts in a decidedly inhospitable manner (other applications like EMACS,
  7081. vi, etc, simply refuse to run if their standard i/o has been redirected).
  7082.  
  7083. (*) Only pre-1988 versions of the publicly-distributed sz/rz programs use
  7084.     Standard I/O; those released later than that do not use Standard I/O and
  7085.     therefore do not work with REDIRECT.  However, Omen Technology does offer
  7086.     an up-to-date redirectable version called crzsz, which must be licensed
  7087.     for use.
  7088.  
  7089. 4.2.8.3. Receiving Mail and Print Jobs
  7090.  
  7091. As of 7.0, and in UNIX only, files that are sent to C-Kermit as mail (when
  7092. the other Kermit uses a MAIL or SEND /MAIL command) or to be printed (via
  7093. REMOTE PRINT or SEND /PRINT) are now piped directly to the mail or print
  7094. program, rather than written to temporary files and then mailed or printed and
  7095. then deleted.  This has the advantages of (a) not requiring a temporary file,
  7096. and (b) allowing mail to have a proper subject in place of the filename.
  7097. Temporary files were bad not only because they required (a) space, and (b)
  7098. writeability of the current directory, but also because using them could
  7099. result in wiping out an existing file.  See section 4.7 for more about SEND
  7100. /MAIL and SEND /PRINT.
  7101.  
  7102. 4.2.8.4. Pipe-Related Functions
  7103.  
  7104. The \fcommand(<command>) function runs the given shell or system command and
  7105. returns the command's standard output as its value (with any newline
  7106. characters stripped from the end), unless the result is too long, in which
  7107. case it returns the empty string.  The maximum length for the result is at
  7108. least 1022 bytes, and it might be longer on some platforms.  Examples (UNIX):
  7109.  
  7110.   C-Kermit> echo "\fcommand(date)"
  7111.   "Fri Apr 18 13:31:42 1997"
  7112.   C-Kermit> echo "\fcommand(finger | wc -l)" ; how many users logged in?
  7113.   "      83"
  7114.   C-Kermit> evaluate \fcommand(finger | wc -l) * 2
  7115.   166
  7116.   C-Kermit> echo Welcome to \fcommand(tty) on \fcommand(date)
  7117.   Welcome to /dev/ttyre on Fri Apr 18 13:31:42 1997
  7118.   C-Kermit> echo "\fcommand(ls oofa.*)"
  7119.   "oofa.c
  7120.   oofa.h
  7121.   oofa.o"
  7122.   C-Kermit> cd /directory-with-thousands-of-files
  7123.   C-Kermit> echo "\fcommand(ls -l)" ; This would be too long
  7124.   ""
  7125.   C-Kermit>
  7126.  
  7127. If a command's output would be too long, you can use the other, more laborious
  7128. method of reading from a command: OPEN !READ <command>, READ each line,
  7129. CLOSE !READ.
  7130.  
  7131. The \frawcommand(<command>) function is identical to \fcommand(<command>),
  7132. except it does not remove trailing newline characters:
  7133.  
  7134.   C-Kermit> echo "\frawcommand(date)"
  7135.   "Fri Apr 18 13:31:42 1997
  7136.   "
  7137.   C-Kermit> echo "\frawcommand(ls oofa.*)"
  7138.   "oofa.c
  7139.   oofa.h
  7140.   oofa.o
  7141.   "
  7142.   C-Kermit>
  7143.  
  7144. Use \frawcommand() if you want to retain the final line terminators, or if
  7145. the command's output is "binary".  But remember that if the result of this
  7146. (or any other) function contains any NUL (ASCII code 0) characters, the first
  7147. NUL will terminate the result string because this is how C strings work
  7148. (it's "C-Kermit", remember?).
  7149.  
  7150. These functions are useful not only locally, but also in the client/server
  7151. arena.  If you need to get the results from a system command on the server
  7152. end into a variable on the client end, just do:
  7153.  
  7154.   [ remote ] query kermit command(date)
  7155.  
  7156. The result is in the local \v(query) variable; see "Using C-Kermit", 2nd Ed.,
  7157. pp.359-360 for details.
  7158.  
  7159. 4.3. Automatic Per-File Text/Binary Mode Switching
  7160.  
  7161. When transferring files between like systems (e.g. UNIX-to-UNIX), binary mode
  7162. can be used for all files unless character-set translation is needed, and in
  7163. fact Kermit programs of recent vintage recognize each others' platforms and
  7164. switch to binary mode automatically when it is appropriate (e.g. DOS to OS/2,
  7165. or UNIX to UNIX).  (Exception: LABELED mode is chosen for VMS-to-VMS and
  7166. OS/2-to-OS/2 tranfers so complex file formats can be preserved.)
  7167.  
  7168. On a client/server connection between like systems, the transfer mode is
  7169. currently determined by the file sender, rather than always by the client.
  7170. If the client is sending, it controls the transfer mode.  If a GET command is
  7171. sent to the server, the server sends all files in binary mode if its TRANSFER
  7172. CHARACTER-SET is TRANSPARENT; otherwise it uses text mode for text files
  7173. (according to its text-pattern list) and binary mode for binary files.  Of
  7174. course, the client can control the server's transfer character-set with the
  7175. REMOTE SET TRANSFER CHARACTER-SET command.
  7176.  
  7177. When transferring files between unlike systems, however, (e.g. UNIX-to-DOS),
  7178. some files (such as executable program images) must be transferred in binary
  7179. mode but others (such as plain-text files) must be transferred in text mode so
  7180. their record format and character sets can be appropriately converted.  If a
  7181. binary file is transferred in text mode, it is ruined.  If a text file is
  7182. transferred in binary mode, then at the very least, its format can be
  7183. incorrect; at worst it is also corrupted because its character set was not
  7184. converted (in extreme cases the corruption is total, e.g. because one system
  7185. is ASCII-based and the other EBCDIC).
  7186.  
  7187. 4.3.1. Exceptions
  7188.  
  7189. VMS C-Kermit, when sending files to a non-VMS system, switches to text or
  7190. binary mode automatically for each file, based on the record format in the
  7191. file's directory entry; thus the mechanisms described in this section do not
  7192. apply to VMS C-Kermit, yet the effect is the same: automatic text/binary mode
  7193. switching when VMS C-Kermit is sending files.  See the VMS Appendix of "Using
  7194. C-Kermit" for details.
  7195.  
  7196. Kermit versions that support LABELED or IMAGE transfer mode are likewise
  7197. not affected by this feature when one of those modes is selected (normally
  7198. used only when transferring between like systems).
  7199.  
  7200. Kermit versions that support file-transfer pipes and filters are not affected
  7201. by this feature when pipes or filters are used, since the output of a pipe or
  7202. filter (such as gzip) is likely to require transfer in a different mode than
  7203. the original file.
  7204.  
  7205. Finally, SEND /TEXT or SEND /BINARY will force files to be sent in the
  7206. indicated mode, overriding all automatic transfer-mode-choosing mechanisms.
  7207.  
  7208. 4.3.2. Overview
  7209.  
  7210. Suppose you give C-Kermit a command like:
  7211.  
  7212.   SEND *.*
  7213.  
  7214. And suppose the pattern *.* matches a mixture of text files (such as program
  7215. source code) and binary files (such os object modules or executable programs).
  7216.  
  7217. C-Kermit 6.0 and earlier (except on VMS) send all files in the same mode:
  7218. whatever you said in your most recent SET FILE TYPE command, or else whatever
  7219. mode was chosen automatically according to the rules on page 236 of "Using
  7220. C-Kermit", 2nd Ed.
  7221.  
  7222. But when text and binary files are mixed in the same group, and the files are
  7223. being transferred to an unlike system (e.g. UNIX to IBM Mainframe), this
  7224. results in corruption of either all the text files or all the binary files.
  7225.  
  7226. Stream-oriented file systems such as in UNIX and DOS do not record any
  7227. information about the file to tell us whether the file should be transferred
  7228. in binary or text mode, making it impossible to select the transfer mode
  7229. for each file in a group automatically with any certainty.
  7230.  
  7231. However, we can use some fairly-well established file naming conventions for
  7232. this purpose.  C-Kermit 7.0 lets you provide lists of filename patterns that
  7233. are used to separately determine the file type for each individual file being
  7234. transfered.  A pattern is a string, possibly containing the special characters
  7235. "*" (asterisk, which matches any string of zero of more characters) and/or "?"
  7236. (question mark, which matches any single character).  For example "a*b"
  7237. matches all files whose names start with "a" and end with "b", such as "ab",
  7238. "arb", "ababababab", etc, but not "abba".  And "a?b" matches any file whose
  7239. name starts with "a", ends with "b", and is exactly 3 characters long.
  7240.  
  7241.   NOTE: When typing commands at the C-Kermit prompt, you must
  7242.   prefix "?" with \ to override its normal function of giving help.
  7243.  
  7244. (Also see section 4.9 for additional pattern-matching notations that might
  7245. be available in your version of C-Kermit.)
  7246.  
  7247. When you have specified filename recognition patterns, C-Kermit can transfer
  7248. the ones whose names match any of the binary-mode patterns in binary mode, and
  7249. those with names that match any of the text-mode patterns in text mode, and
  7250. those whose names match neither in the prevailing mode you have chosen, or
  7251. that was chosen automatically via peer recognition.
  7252.  
  7253. 4.3.3. Commands
  7254.  
  7255. SET FILE PATTERNS { ON, OFF, AUTO }
  7256.   This tells Kermit whether to do per-file filename pattern-matching to
  7257.   determine text or binary mode.  The normal and default setting is AUTO,
  7258.   which means to use pattern lists to switch transfer mode only when it is
  7259.   certain that the other Kermit program supports automatic notification of
  7260.   transfer mode (via Attribute packets) on a per-file basis (this information
  7261.   is obtained automatically during protocol startup negotiation).  ON means to
  7262.   always determine the transfer mode from the filename and pattern list when
  7263.   sending files.  Use OFF to disable this feature (without resetting your
  7264.   pattern lists).  Also note that if you have selected LABELED file transfer
  7265.   (SET FILE TYPE LABELED), this takes precedence over filename-matching
  7266.   patterns and all files are sent in labeled mode.
  7267.  
  7268. SET TRANSFER MODE MANUAL
  7269.   Disables the use of filename patterns, no matter what the FILE PATTERNS
  7270.   setting.
  7271.  
  7272. REMOTE SET TRANSFER MODE MANUAL
  7273.   Client command to disable automatic transfer mode, and therefore also
  7274.   filename patterns, in the server.  Synonym: REMOTE SET XFER MODE MANUAL.
  7275.  
  7276. { GET, SEND, etc } { /BINARY, /TEXT }
  7277.   Including a /BINARY or /TEXT (or, where supported, /IMAGE or /LABELED)
  7278.   switch with a file-transfer command changes the transfer mode to manual
  7279.   for that command only, and therefore disables patterns that that command.
  7280.  
  7281. SET FILE BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7282.   A list of zero or more patterns, separated by spaces (not commas).  Letters
  7283.   in a pattern are case-sensitive if the underlying filenames are case
  7284.   sensitive (as in UNIX), and case-insensitive otherwise (as in Windows).  If
  7285.   a file's name is matched by any pattern in the list and SET FILE PATTERNS is
  7286.   ON, the file is sent in binary mode.  Examples:
  7287.  
  7288.     SET FILE BINARY-PATTERNS *.gz *.Z *.tar *.zip *.o *.so *.a *.out ; UNIX
  7289.     SET FILE BINARY-PATTERNS *.EXE *.ZIP *.OBJ *.COM ; DOS or OS/2 or Windows
  7290.  
  7291.   If a pattern contains spaces, enclose it in braces.
  7292.  
  7293. SET FILE TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7294.   Like SET FILE BINARY-PATTERNS, but the patterns choose text files rather
  7295.   than binary ones.  Examples:
  7296.  
  7297.     SET FILE TEXT-PATTERNS *.TXT *.KSC *.HTM* *.BAT ; DOS, Windows, OS/2
  7298.  
  7299. ADD BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7300.   Adds one or more patterns to the BINARY-PATTERN list.
  7301.  
  7302. ADD TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7303.   Adds one or more patterns to the TEXT-PATTERN list.
  7304.  
  7305. REMOVE BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7306.   Removes one or more patterns from the BINARY-PATTERN list.  The given
  7307.   patterns are matched with the ones in the BINARY-PATTERNS list with
  7308.   case sensitivity if the underlying file system has case-sensitive names
  7309.   (as do UNIX and OS-9), otherwise with case independence.
  7310.  
  7311. REMOVE TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7312.   Removes one or more patterns from the TEXT-PATTERN list.
  7313.  
  7314. SHOW PATTERNS
  7315.   Displays the current pattern selections.
  7316.  
  7317. Whenever you give a SET FILE BINARY-PATTERNS or SET FILE TEXT-PATTERNS
  7318. command, the previous list is replaced.  If you give one of these commands
  7319. without a pattern list, the previous list is removed.
  7320.  
  7321. When patterns are active and files are being sent, text patterns (if any) are
  7322. applied first (but only if not RESENDing and not sending in LABELED mode),
  7323. then binary patterns, so if the same pattern appears in both lists, binary
  7324. mode is chosen.
  7325.  
  7326. 4.3.4. Examples
  7327.  
  7328. Here's an example that might be used when sending files from UNIX:
  7329.  
  7330.   set file type binary
  7331.   set file text-patterns *.c *.h *.w *.txt makefile
  7332.   set file binary-patterns *.o
  7333.   msend makefile wermit wart ck*.[cwho] ck*.txt
  7334.  
  7335. Note that "wermit" and "wart" do not match any patterns so they are sent in
  7336. the prevailing mode, which is binary.  Also note the use of "makefile" as a
  7337. pattern that does not contain any wildcard characters (there is no other
  7338. convention to distinguish among "wermit" and "wart", which are binary
  7339. executables, and "makefile", which is a text file, purely by their names).
  7340.  
  7341. Most C-Kermit implementations have a default pattern list built in, which
  7342. includes patterns that are almost certain to succeed in picking the right
  7343. transfer mode.  Others are omitted due to ambiguity.  For example ".hlp", and
  7344. ".ini" are generally binary types in Windows but text types everywhere else.
  7345.  
  7346.   NOTE: ".doc", used for decades to denote plain-text documentation
  7347.   files, now more often than not denotes a Microsoft Word Document, so
  7348.   ".doc" is now considered a binary type since it does less harm to
  7349.   transfer a plain-text document in binary mode than it does to transfer
  7350.   an MS Word file in text mode (except when IBM mainframes are involved!)
  7351.  
  7352.   ANOTHER NOTE: ".com" files are binary in DOS-like operating systems,
  7353.   but they are text (DCL command procedures) in VMS.  VMS C-Kermit sends
  7354.   .COM files in text mode; K95 sends them in binary mode.  If you download
  7355.   a .COM file from VMS to DOS or Windows, and then upload it to another
  7356.   VMS system, be sure to use SEND /TEXT to preserve its textness.
  7357.  
  7358. You can see the default pattern list by starting C-Kermit without its
  7359. initialization file (e.g. "kermit -Y") and using the SHOW PATTERNS command.
  7360. If you will be depending on this feature, be sure to examine the list
  7361. carefully in conjunction with the applications that you use.
  7362.  
  7363. The default pattern list does not take "backup files" into account because
  7364. (a) people usually don't want to transfer them; and (b) it would make the
  7365. pattern lists more than twice as long.  For example, we would need to include
  7366. both *.txt and *.txt.~[0-9]*~ for ".txt" files, and similarly for all the
  7367. others.  Instead, you can use SEND /NOBACKUP (or SET SEND BACKUP OFF) to
  7368. skip over all backup files.
  7369.  
  7370. Put your most commonly-used safe pattern declarations in your C-Kermit
  7371. customization file (ckermod.ini, .mykermrc, k95custom.ini, etc).
  7372.  
  7373. As noted, SET FILE PATTERNS is ON by default.  Sometimes, however, it is
  7374. desirable, or necessary, to force files to be sent in a particular mode, and
  7375. often this must be done from the command line (e.g. when using Kermit as a
  7376. download helper in a Web browser like Lynx).  The -V command-line options is
  7377. equivalent to SET FILE PATTERNS OFF and SET TRANSFER MODE MANUAL.  Example:
  7378.  
  7379.   kermit -Vis oofa.txt
  7380.  
  7381. forces oofa.txt to be sent in binary mode, even though ".txt" might match a
  7382. text pattern.
  7383.  
  7384. 4.4. File Permissions
  7385.  
  7386. "Permissions" refers to a code associated with a file that specifies who is
  7387. allowed to access it, and in what manner.  For example, the owner, the members
  7388. of one or more groups, the system administrator, and everybody else, might be
  7389. allowed various combinations of Read, Write, Append, Execute, or Listing
  7390. access.
  7391.  
  7392. The permission code goes by different names on different platforms.  In UNIX,
  7393. it might be called the filemode.  In VMS, it is called the file protection
  7394. (or protection mask).
  7395.  
  7396. The comments in this section presently apply only to the UNIX and VMS versions
  7397. of C-Kermit, to which these features were added in version 7.0; the DOS,
  7398. Windows, and OS/2 file systems embody no notions of protection, and so MS-DOS
  7399. Kermit and Kermit 95 do not send file permissions, and ignore them when
  7400. received.
  7401.  
  7402. The permissions for a received file are determined by a combination of the
  7403. file transfer mode (VMS-to-VMS transfers only), whether a file of the same
  7404. name exists already, whether permissions of the file are received in the file
  7405. attribute packet, and the setting of ATTRIBUTES PROTECTION.
  7406.  
  7407. The default for ATTRIBUTES PROTECTION is ON.  If no attributes are received,
  7408. the effect is the same as if attributes PROTECTION were OFF.
  7409.  
  7410. For VMS-to-VMS transfers, the default LABELED mode simply copies the
  7411. protection code from source to destination.
  7412.  
  7413. 4.4.1. When ATTRIBUTES PROTECTION is OFF
  7414.  
  7415. If no file of the same name exists, system defaults determine the permissions
  7416. of the new file.  Otherwise, the actions taken depend on the current FILE
  7417. COLLISION setting: BACKUP, OVERWRITE, RENAME, etc, as documented in "Using
  7418. C-Kermit".  But now the new file (if it is created at all) automatically
  7419. inherits the permissions (mode bits) of the existing file in a way that is
  7420. appropriate for the platform.
  7421.  
  7422. 4.4.1.1. Unix
  7423.  
  7424. All mode bits are inherited except the directory bit, since the
  7425. incoming file can not possibly be a directory.  (In any case, it is not
  7426. possible to receive a file that has the same name as an existing directory
  7427. unless FILE COLLISION is set to RENAME).
  7428.  
  7429. 4.4.1.2. VMS
  7430.  
  7431. Files with the same name as an existing file, transferred in modes other than
  7432. LABELED between VMS systems, inherit the protection of the prior version.
  7433.  
  7434. 4.4.2 When ATTRIBUTES PROTECTION is ON
  7435.  
  7436. File permissions can be conveyed as part of the file transfer process, in
  7437. accordance with the Kermit protocol definition.  If the file sender puts
  7438. system-dependent and/or system-independent versions of the file protection
  7439. (permissions) into the Attribute (A) packet, the file receiver can set the new
  7440. file's permissions from them.  Otherwise, the permissions are set the same as
  7441. for ATTRIBUTES PROTECTION OFF.
  7442.  
  7443. When the incoming A packet contains system-dependent permissions, the file
  7444. receiver checks to see if the sender has the same system ID (e.g. both the
  7445. sending and receiving systems are UNIX, or both are VMS); if so, it decodes
  7446. and uses the system-dependent permissions; otherwise it uses the generic ones
  7447. (if any) and applies them to the owner field, setting the other fields
  7448. appropriately as described in the following sections.
  7449.  
  7450. Setting the incoming file's protection from the A packet is controlled by SET
  7451. ATTRIBUTES PROTECTION (or PERMISSION), which is ON by default, and its status
  7452. is displayed by SHOW ATTRIBUTES.
  7453.  
  7454. The main benefit of this feature is to not have to "chmod +x" an executable
  7455. file after transfer from UNIX to UNIX.  Its cross-platform benefits are less
  7456. evident, perhaps to retain the status of the Unix 'x' bit on a VMS system,
  7457. for subsequent transfer back to a Unix system.
  7458.  
  7459. 4.4.2.1. System-Specific Permissions
  7460.  
  7461. System-specific file permissions are used when the two Kermit programs
  7462. recognize each other as running on the same type of system.  For example,
  7463. both are running under some form of UNIX (it doesn't matter which UNIX
  7464. variation -- HP-UX, Solaris, AIX, etc -- all use the same scheme for file
  7465. permissions); or both are running under VMS (even if one is on an Alpha and
  7466. the other on a VAX, and/or one is old and the other is new).
  7467.  
  7468. 4.4.2.1.1. UNIX
  7469.  
  7470. UNIX supports three categories of users, File Owner, Group, and World,
  7471. and three types of file access permission: Read, Write, and Execute.  Thus,
  7472. a UNIX file's permissions are expressed in 9 bits.
  7473.  
  7474. The system-dependent permission string for UNIX is a 3-digit octal string, the
  7475. low-order 9 bits of the st_mode member of the stat struct; we deliberately
  7476. chop off the "file format" bits because they are not permissions, nor do we
  7477. convey the setuid/setgid bits, lock bit, sticky bit, etc.
  7478.  
  7479. 4.4.2.1.2. VMS
  7480.  
  7481. VMS supports four categories of users, System, File Owner, Group, and World,
  7482. and four types of file access permission: Read, Write, Execute, and Delete.
  7483. Thus, a VMS file's permissions are expressed in 16 bits.
  7484.  
  7485. The system-dependent protection string for VMS is a 4-digit hexadecimal
  7486. string, corresponding to the internal-format protection word of the file
  7487. (RWED for each of World,Group,Owner,System).  A new file normally gets all 16
  7488. protection bits from the original file of the same name.
  7489.  
  7490. Note: VMS-to-VMS transfers take place in LABELED mode when the two C-Kermits
  7491. recognize each other's platform as VMS (unless you have disabled LABELED-mode
  7492. transfers).  In this case, all of a file's attributes are preserved in the
  7493. transfer and the protection mask (and other information) is taken from the
  7494. file's internal information, and this takes precedence over any information
  7495. in the Attribute packets.  You can defeat the automatic switching into
  7496. LABELED mode (if you want to) with SET TRANSFER MODE MANUAL.
  7497.  
  7498. 4.4.2.2. System-Independent Permissions
  7499.  
  7500. The system-independent ("generic") protection is used when the system IDs of
  7501. the two Kermit programs do not agree (e.g. one is UNIX, the other is VMS).
  7502. The generic protection attribute includes the following permissions (not all
  7503. are applicable to every file system): Read, Write, Append, Execute, Delete,
  7504. Search.  The generic permissions are derived from the owner permissions of
  7505. the source file, thus, a Unix 'w' permission becomes VMS Write,Delete.
  7506.  
  7507. The Owner field of the new file's permissions is set from the incoming
  7508. generic protection attribute.
  7509.  
  7510. In UNIX, the Group and World permissions are set according to your umask,
  7511. except that execute permission is NOT set in these fields if it was not also
  7512. set in the generic protection (and consequently, is set in the Owner field).
  7513.  
  7514. In VMS, the System, Group, and World permissions are set according to the
  7515. process default file permission (as shown in VMS by SHOW PROTECTION), except
  7516. that no permissions are allowed in these fields that are not included in the
  7517. generic permissions.
  7518.  
  7519. Note that the VMS and UNIX interpretations of Execute permission are not
  7520. identical.  In UNIX, a file (binary executable, shell script, etc) may not
  7521. be executed unless it has Execute permission, and normally files that are
  7522. not intended for execution do not have Execute permission.  In VMS, Read
  7523. permission implictly supplies Execute capability.  Generally files that have
  7524. Read permission also have explicit Execute permission, but files (binary
  7525. executables, DCL command procedures) that have Read permission and not
  7526. Execute permission can still be executed.
  7527.  
  7528. 4.5. File Management Commands
  7529.  
  7530. 4.5.1. The DIRECTORY Command
  7531.  
  7532. Prior to C-Kermit 7.0, the DIRECTORY command always ran an external system
  7533. command (such as "ls" on UNIX) or program to product the directory listing.
  7534. This had certain advantages, mostly that you could include system-dependent
  7535. options for customized listings, e.g. on UNIX:
  7536.  
  7537.   dir -lt c* | more
  7538.  
  7539. or in VMS:
  7540.  
  7541.   directory /size/date/protection/except=*.obj oofa.*;0
  7542.  
  7543. This approach, however, carries some disadvantages: C-Kermit can't return
  7544. SUCCESS or FAILURE status for (e.g.) "dir foo" according to whether the file
  7545. "foo" exists; and it runs an inferior process, which might be a problem in
  7546. some environments for resource and/or security reasons, and won't work at all
  7547. in a "nopush" environment (e.g. one in which C-Kermit is configured to forbid
  7548. access to exterior commands and programs, e.g. in a VMS "captive account").
  7549.  
  7550. In C-Kermit 7.0 on VMS and UNIX, and in K95 1.1.18 and later, the DIRECTORY
  7551. command is internal to Kermit.  It can be run in a "nopush" environment and
  7552. returns SUCCESS or FAILURE status appropriately.  In UNIX it prints all dates
  7553. and times in a consistent way (unlike ls).  In VMS it prints precise file
  7554. sizes, rather than "blocks".  It offers several formatting and other options,
  7555. but it is not necessarily more flexible than the corresponding external
  7556. commands or programs (the UNIX "ls" program, the VMS "directory" command).
  7557. The syntax is:
  7558.  
  7559.   DIRECTORY [ switch [ switch [ ... ] ] ] [ filespec ]
  7560.  
  7561. If no filespec is given, all files in the current directory are listed.
  7562.  
  7563. Optional switches include all the standard file-selection switches presented
  7564. in Section 1.5.4, plus:
  7565.  
  7566. /ALL
  7567.   Show both regular files and directories; this is the default.
  7568.  
  7569. /ARRAY:x
  7570.   Instead of displaying a directory listing, put the files that would have
  7571.   been shown (based on the filespec and other selection switches) in the
  7572.   given array.  The array need not (and should not) be predeclared; if the
  7573.   array already exists, it is destroyed and reused.  The array name can be a
  7574.   single letter, like "a", or any fuller form, such as "&a", "\&a", "\&a[]",
  7575.   etc.  If the /ARRAY switch is included, the following other switches are
  7576.   ignored: /BRIEF, /VERBOSE, /HEADING, /PAGE, /ENGLISHDATE, /ISODATE,
  7577.   /XFERMODE, /MESSAGE, /SORT, /REVERSE, /ASCENDING.  In other words, only
  7578.   file selection switches are meaningful with /ARRAY: /FILES, /DIRECTORIES,
  7579.   /ALL, /DOTFILES, /NOBACKUP, /RECURSIVE, /SMALLER, /LARGER, /AFTER,
  7580.   /BEFORE, /EXCEPT, etc.  The resulting array has the number of files (n) as
  7581.   its 0th element, and the filenames in elements 1 through n.  Example:
  7582.  
  7583.     dir /array:&a /files /nobackup /after:19990101 /larger:10000 [ab]*
  7584.     show array &a
  7585.  
  7586. /FILES
  7587.   Only show regular files.
  7588.  
  7589. /DIRECTORIES
  7590.   Only show directories.
  7591.  
  7592. /BACKUP
  7593.   In UNIX, OS-9, K-95, and other versions that support SET FILE COLLISION
  7594.   BACKUP and create backup files by appending .~n~ to the filename (where
  7595.   "n" is a number), /BACKUP means to include these files in directory
  7596.   listings.  This is the default.
  7597.  
  7598. /NOBACKUP
  7599.   This is the opposite of /BACKUP: that is, do not include backup files in
  7600.   the listing.
  7601.  
  7602. /BRIEF
  7603.   List filenames only; use a compact format, as many filenames as will fit
  7604.   across the screen (based on the longest name).  A brief listing is always
  7605.   sorted alphabetically.
  7606.  
  7607. /VERBOSE
  7608.   List one file per line, and include date, size, and (in UNIX only)
  7609.   permissions of each file.  This is the opposite of /BRIEF, and is the
  7610.   default.
  7611.  
  7612. /PAGE
  7613.   Pause at the end of each screenful and give a "more?" prompt, even if
  7614.   SET COMMAND MORE-PROMPTING is OFF.
  7615.  
  7616. /NOPAGE
  7617.   Don't pause at the end of each screenful and give a "more?" prompt, even if
  7618.   SET COMMAND MORE-PROMPTING is ON.  If neither /PAGE or /NOPAGE is given,
  7619.   paging is according to the prevailing COMMAND MORE-PROMPTING setting (which
  7620.   can be displayed with SHOW COMMAND).
  7621.  
  7622. /ENGLISHDATE
  7623.   Show dates in dd-mmm-yyyy format; mmm is the first three letters of the
  7624.   English month name.
  7625.  
  7626. /ISODATE
  7627.   Show dates in ISO 8061 yyyy-mm-dd format; mm is the month number, 1-12.
  7628.   This is the opposite of /ENGLISHDATE, and is the default.
  7629.  
  7630. /HEADINGS
  7631.   Print a heading before the listing and a summary at the end.
  7632.  
  7633. /NOHEADINGS
  7634.   Don't print a heading before the listing or a summary at the end.
  7635.   This is the opposite of /HEADINGS, and is the default.
  7636.  
  7637. /XFERMODE
  7638.   Only in Kermit programs that support SET FILE PATTERNS.  If this switch is
  7639.   included, and the filename matches any FILE BINARY-PATTERN (Section 4.3),
  7640.   "(B)" is printed after the filename; otherwise, if it matches a FILE
  7641.   TEXT-PATTERN, "(T)" is printed.
  7642.  
  7643. /NOXFERMODE
  7644.   Don't display transfer-mode indicators.  This is the opposite of /XFERMODE
  7645.   and is the default.
  7646.  
  7647. /RECURSIVE
  7648.   Show files not only in the given directory, but also in its subdirectories
  7649.   (if any), their subdirectories, etc.
  7650.  
  7651. /NORECURSIVE
  7652.   Don't show files in subdirectories.  This is the opposite of /RECURSIVE,
  7653.   and is the default.
  7654.  
  7655. /MESSAGE:text
  7656.   This lets you specify a short text string to be appended to the end of
  7657.   each directory listing line (a space is supplied automatically).  If the
  7658.   text contains any spaces, enclose it in braces, e.g. /MESSAGE:{two words}.
  7659.  
  7660. /NOMESSAGE
  7661.   Don't append any message to the end of each directory listing line
  7662.   (default).
  7663.  
  7664. /SORT:[{NAME,SIZE,DATE}]
  7665.   Sort the listing by name, size, or date.  If the /SORT switch is given
  7666.   but the "sort-by" keyword is omitted, the listing is sorted by name.
  7667.   /SORT:NAME /ASCENDING (alphabetic sort by name) is the default.
  7668.  
  7669. /NOSORT
  7670.   Don't sort the listing.  Files are listed in whatever order they are
  7671.   supplied by the operating system, e.g. inode order in UNIX.
  7672.  
  7673. /REVERSE
  7674.   If the /SORT switch is given, reverse the order of the sort.
  7675.   Synonym: /DESCENDING.
  7676.  
  7677. /ASCENDING
  7678.   If the /SORT switch is given, sort the listing in normal order.
  7679.   This is the opposite of /REVERSE and is the default.
  7680.  
  7681. Note that most of the DIRECTORY-specific switches come in pairs, in which
  7682. one member of a pair (e.g.  /NOHEADINGS) is the opposite of the other
  7683. (e.g. /HEADINGS).
  7684.  
  7685. If you always want to use certain options, you can set them with the SET
  7686. OPTIONS DIRECTORY command (Section 1.5.5).  Use SHOW OPTIONS to list the
  7687. options currently in effect.  To make the desired options apply every time you
  7688. run C-Kermit, put a SET OPTIONS DIRECTORY command in your C-Kermit
  7689. customization file, specifying the desired options.  Options set in this
  7690. manner apply to every subsequent DIRECTORY command.  Of course, if you include
  7691. switches in a DIRECTORY command, these override any defaults, built-in or
  7692. custom.  Example:
  7693.  
  7694.   DIRECTORY            ; Use "factory defaults"
  7695.   SET OPTIONS DIRECTORY /SORT:SIZE /REVERSE /HEADINGS  ; Customize defaults
  7696.   DIRECTORY            ; Use customized defaults
  7697.   DIR /SORT:NAME       ; Override customized default SORT key
  7698.   SET OPT DIR /RECURS  ; Add /RECURSIVE to customized defaults
  7699.   DIR /ASCEND          ; Override customized default SORT order
  7700.  
  7701. Notes:
  7702.  
  7703.  . Only a single sort key is supported; there is presently no way to
  7704.    have multiple sort keys.
  7705.  
  7706.  . If the /BRIEF switch is given, all other switches (except /[NO]RECURSIVE,
  7707.    /[NO]DOTFILES, /DIRECTORIES, /FILES, and /ALL) are ignored.
  7708.  
  7709.  . /SORT:<anything> gives incorrect results if any files have lengths
  7710.    greater than 10 digits (i.e. that are more than 9999999999 bytes long, i.e.
  7711.    if they are 10GB or more in size) because the overlong length field causes
  7712.    the date and name fields to be misaligned.
  7713.  
  7714.  . /SORT:NAME is redundant in VMS since VMS returns filenames in alphabetic
  7715.    order anyway.
  7716.  
  7717.  . /SORT:NAME ignores alphabetic case on platforms where case does not matter
  7718.    in filenames, but this works only for unaccented Roman letters A-Z.
  7719.  
  7720.  . /SORT:NAME is currently based on code values, and so works fine for ASCII,
  7721.    but will probably produce unexpected results for files with non-ASCII or
  7722.    8-bit characters in their names.  (Locale-based sorting raises rather
  7723.    significant issues of portability, size, performance, etc.)
  7724.  
  7725.  . /SORT:DATE works right only for ISO-format dates, not English ones.
  7726.  
  7727.  . /SORT:SIZE sorts the size field lexically.  On some platforms
  7728.    (e.g. Windows), the size of a directory file is listed as "<DIR>" rather
  7729.    than as a number; in this case, the "<DIR>" files are gathered at the end
  7730.    (or beginning, depending on the sort order) of the listing.
  7731.  
  7732.  . /RECURSIVE is accepted but ignored in AOS/VS.  Use the normal
  7733.    system-specific filespec notation, e.g. "dir #.txt".
  7734.  
  7735.  . /RECURSIVE has no affect when a full, absolute pathname is given; e.g.
  7736.    "dir /recursive /tmp/foo" (where "foo" is a regular file) only shows the
  7737.    "/tmp/foo" file.  If you want to see all "foo" files in the /tmp tree,
  7738.    do "cd /tmp" and then "dir /recursive foo".
  7739.  
  7740.  . If a file size of -1 is shown, or date-time of 0000-00-00 00:00:00, this
  7741.    means the file was located, but access to information about the file was
  7742.    denied to C-Kermit.
  7743.  
  7744.  . In VMS, if FOO.DIR;1 is a directory within your current directory,
  7745.    "directory foo" and "directory [.foo]" list the files in the [.FOO]
  7746.    subdirectory, but "directory foo.dir" lists the directory file itself;
  7747.    similarly for "*.dir" versus "[.*]", etc.
  7748.  
  7749.  . In UNIX, if "foo" is a directory within your current directory,
  7750.    "directory foo" lists the files in the foo directory.  If you want to
  7751.    list the foo directory file itself, put an asterisk at the end:
  7752.    "dir foo*".
  7753.  
  7754. Hint: How to find the biggest files in a directory tree:
  7755.  
  7756.   cd xxx ; (root of tree)
  7757.   directory /sort:size /recursive /reverse /dotfiles /page
  7758.  
  7759. Another hint: If you often use several different directory-listing formats,
  7760. define macro shortcuts for them:
  7761.  
  7762.   DEFINE WD DIRECTORY /SORT:DATE /REVERSE \%*  ; Reverse chronological order
  7763.   DEFINE SD DIRECTORY /SORT:SIZE /REVERSE \%*  ; Reverse order of size
  7764.   DEFINE ND DIRECTORY /SORT:NAME /ASCEND \%*   ; Alphabetical by name
  7765.   DEFINE DL DIR /DIR /SORT:NAME /ASCEND \%*    ; Alphabetical directory list
  7766.  
  7767. Put these definitions in your C-Kermit customization file.  Note that "\%*"
  7768. (Section 7.5) in these definitions lets you include other switches in your
  7769. macro invocations, e.g.:
  7770.  
  7771.   wd /headings *.txt
  7772.  
  7773. Of course you can still access your external directory listing program by
  7774. using RUN or "!", e.g. in VMS:
  7775.  
  7776.   run directory /size/date/protection/except=*.obj oofa.*;0
  7777.  
  7778. or:
  7779.  
  7780.   !dir /size/date/prot/exc=*.obj oofa.*;0
  7781.  
  7782. In UNIX, use "!ls" or just "ls" (which is a special synonym for "!ls").
  7783.  
  7784. 4.5.2. The CD and BACK Commands
  7785.  
  7786. In 7.0, the CD command has a new friend, the BACK command.  BACK
  7787. means "CD to my previous current directory".  A second BACK brings you back
  7788. to where you were before the first one; thus successive BACK commands switch
  7789. back and forth between two directories.
  7790.  
  7791. 4.5.2.1. Parsing Improvements
  7792.  
  7793. The CD command, as well as other commands that parse a directory name, were
  7794. changed in 7.0 to provide all the expected functions: completion on Tab
  7795. or Esc, directory-name lists on ?, etc.  Other affected commands include
  7796. SET SERVER GET-PATH, SET TEMP-DIRECTORY, SET FILE DOWNLOAD-DIRECTORY, and
  7797. SPACE.  CD and REMOTE CD also now work with logical names.
  7798.  
  7799. In VMS, the situation is a bit complicated since a directory name can look
  7800. like "DEV:", "[FOO.BAR]", "DEV:[FOO.BAR]", "[FOO]BAR.DIR;1", etc.  Completion
  7801. and ?-help might not always work, but they do in many cases.  Examples:
  7802.  
  7803.   cd ?           Lists all subdirectories of the current directory
  7804.   cd []?         Ditto
  7805.   cd k?          Ditto, but only those starting with K
  7806.   cd [foo]?      Lists all subdirectories of the [FOO] directory
  7807.   cd [-]?        Lists all subdirectories of the superior directory
  7808.   cd [--]?       Lists all subdirectories of the directory 2 levels up
  7809.   cd [...]?      Lists all directories below the current one
  7810.   cd [foo.?      Does not work.
  7811.  
  7812. C-Kermit allows all of the following in VMS:
  7813.  
  7814.   cd bar         CD to subdirectory BAR of the current directory
  7815.   cd .bar        Ditto
  7816.   cd [.bar]      Ditto
  7817.   cd bar.dir     etc...
  7818.   cd bar.dir;
  7819.   cd bar.dir;1
  7820.   cd [foo.bar]
  7821.   cd bar.baz     This can go more than 1 level deep...
  7822.   cd dir:        (where logical name DIR is defined as [FOO.BAR])
  7823.  
  7824. As well as the following:
  7825.  
  7826.   cd ..          Go up one level as in UNIX
  7827.   cd .           The current directory
  7828.   cd             My login directory
  7829.  
  7830. Note that "cd -" (go up one level) does not work as expected, because "-" is
  7831. Kermit's command continuation character.  However, "cd [-]", and "cd {-}" have
  7832. the desired effect (and so does "cd ..", which is easier to type).
  7833.  
  7834. 4.5.2.2. The CDPATH
  7835.  
  7836. The CD command in the UNIX, Windows, OS/2, and VMS versions of C-Kermit, as of
  7837. version 6.1 / 1.1.12, searches the CDPATH for the given directory, if it is not
  7838. absolute and if a CDPATH environment variable is defined.  Example (in UNIX
  7839. ksh or bash):
  7840.  
  7841.   $ export CDPATH=$HOME:$HOME/kermit:/tmp
  7842.  
  7843. Now if you give a "cd xxx" command, no matter what your current directory is,
  7844. if the "xxx" directory is not a subdirectory of your current directory, then
  7845. the xxx subdirectory of your home directory is used or if that does not exist,
  7846. then the xxx subdirectory of the kermit subdirectory of your home directory is
  7847. used or if that does not exist, then /tmp/xxx is used.  This is how the ksh
  7848. "cd" command works, and now the C-Kermit CD command works the same way.
  7849.  
  7850. In VMS, you can define CDPATH to be a list of directories that contain actual
  7851. directory delimiters, and/or logical names representing directories, using
  7852. commas to separate them, e.g.:
  7853.  
  7854.   $ define cdpath [HOME],[SOMEOTHERDIR],[HOME.MISC]
  7855.  
  7856. or:
  7857.   $ define cdpath SYS$LOGIN:,DISK1:[HOME],DISK2:[SCRATCH.IVAN]
  7858.  
  7859. Example:
  7860.   $ define cdpath SYS$LOGIN:,[IVAN],[OLAF],[OLGA.MISC]
  7861.   $ kermit
  7862.   DISK1:[OLGA] C-Kermit> cd blah
  7863.  
  7864. tries the BLAH subdirectory of the user's login directory, then [OLGA.BLAH],
  7865. [IVAN.BLAH], [OLAF.BLAH], and [OLGA.MISC.BLAH], in that order, using the first
  7866. one it finds, failing if it finds none.
  7867.  
  7868. In C-Kermit 7.0, you may also set the CDPATH from the Kermit prompt:
  7869.  
  7870. SET CD PATH <path>
  7871.   Allows the CD PATH to be set from within C-Kermit.
  7872.  
  7873. SHOW CD shows the CD path and all other information relevant to the CD command.
  7874.  
  7875. 4.5.2.3. CD Messages
  7876.  
  7877. Whenever you change directory, you can have C-Kermit display a "Read Me" file
  7878. from the new directory automatically.  The commands are:
  7879.  
  7880. SET CD MESSAGE { ON, OFF, FILE <list> }
  7881.   ON enables this feature; OFF (the default) disables it.  File lets you
  7882.   specify the name of the "Read Me" file.  A list of names to look for can be
  7883.   given in the following format:
  7884.  
  7885.     {{name1}{name2}{name3}{...}}
  7886.  
  7887.   e.g. SET SERVER CD-MESSAGE FILE {{./.readme}{README.TXT}{READ.ME}}
  7888.   The default list of CD-message files is system dependent.
  7889.  
  7890. SHOW CD shows your current directory, previous directory, CD path, and CD
  7891. message info.
  7892.  
  7893. 4.5.3. Creating and Removing Directories
  7894.  
  7895. The MKDIR command now allows you to create multiple directories at once:
  7896.  
  7897.   C-Kermit> mkdir a/b/c/d
  7898.  
  7899. creates the directory a in the current directory (if it doesn't exist
  7900. already), and then creates a subdirectory b of the a directory (if it didn't
  7901. exist already), and so on.
  7902.  
  7903. If you use MKDIR to try to create a directory that already exists, C-Kermit
  7904. will print a warning ("?Directory already exists"), but the MKDIR command
  7905. will still succeed.  If you want to avoid the warning message, use
  7906. IF DIRECTORY first to check if the directory already exists.
  7907.  
  7908. The RMDIR command, however, will not remove more than one directory, nor
  7909. will it remove a directory that contains any files.  (There is, as yet, no
  7910. RMDIR /RECURSIVE command, although one might be added later.)
  7911.  
  7912. In VMS, these commands (like CD) are more forgiving of your syntax than is the
  7913. DCL command shell; "mkdir oofa" is equivalent to "mkdir [.oofa]" and so on.
  7914. Also in VMS, you'll find that C-Kermit's RMDIR command is easier than deleting
  7915. a directory in DCL, since it automatically first gives it owner delete
  7916. permission if you are the owner.
  7917.  
  7918. 4.5.4. The DELETE and PURGE Commands
  7919.  
  7920. The DELETE command now offers a selection of switches, and has a new
  7921. companion, the PURGE command.  First, DELETE:
  7922.  
  7923. DELETE [ switches... ] filespec
  7924.   Deletes the file or files that match the filespec, which may contain
  7925.   wildcards (Section 4.9).
  7926.  
  7927. Optional switches include the standard file-selection switches presented in
  7928. Section 1.5.4, plus:
  7929.  
  7930. /ASK
  7931.   Before deleting each file, ask permission interactively.  Answers are
  7932.   Yes or OK (delete the file), No (don't delete it), or Quit (stop executing
  7933.   the DELETE command).
  7934.  
  7935. /NOASK
  7936.   Don't ask permission to delete each file.
  7937.  
  7938. /LIST
  7939.   List each file and show whether it was deleted.  Synonyms: /LOG, /VERBOSE.
  7940.  
  7941. /NOLIST
  7942.   Don't list files while deleting them.  Synonyms: /NOLOG, /QUIET.
  7943.  
  7944. /HEADING
  7945.   Print a heading and summary line.
  7946.  
  7947. /NOHEADING
  7948.   Don't print a heading and summary line.
  7949.  
  7950. /PAGE
  7951.   When listing, pause at the end of each screenful and give the "More?"
  7952.   prompt.  If you reply "n" (no), the DELETE command terminates.
  7953.  
  7954. /SIMULATE
  7955.   Do everything implied by the given switches and filespec, except do not
  7956.   actually delete any files.  This lets you preview which files would be
  7957.   deleted; implies /LIST.
  7958.  
  7959. Now the PURGE command:
  7960.  
  7961. PURGE [ switches... ] [ filespec ]
  7962.   (VMS only) Runs the DCL PURGE command.  Switches and filespec, if any,
  7963.   are passed directly to DCL without parsing or verification.  Deletes
  7964.   excess versions of the given (or all) files.  The rest of this section
  7965.   does not apply to VMS.
  7966.  
  7967. PURGE [ switches... ] [ filespec ]
  7968.   (UNIX only) Deletes "backup files" that match the filespec, which may
  7969.   contain wildcards (Section 4.9).  If no filespec is given, all backup
  7970.   files in the current directory are selected (subject to modification by
  7971.   any switches).  Do not include backup notation in the filespec.
  7972.  
  7973. Explanation:
  7974.  
  7975. To avoid destroying preexisting files when a new file arrives that has the
  7976. same name, C-Kermit backs up the old file by appending a "backup number" to
  7977. its name.  In UNIX, the backup suffix consists of a period, a tilde, a number,
  7978. and another tilde.  For example, if a file called oofa.txt exists and a new
  7979. oofa.txt file arrives, the original is renamed to oofa.txt.~1~.  If another
  7980. oofa.txt file arrives, the existing one is renamed to oofa.txt.~2~.  And so
  7981. on.  This system is compatible with the one used by EMACS.  Thus over time, if
  7982. you receive a lot of files with C-Kermit or edit them with EMACS, backup files
  7983. can build up.  The new PURGE command lets you clean out accumulated backup
  7984. files:
  7985.  
  7986. Optional switches include the standard file-selection switches presented in
  7987. Section 1.5.4, plus all the switches listed above for the DELETE command,
  7988. plus:
  7989.  
  7990. /KEEP:n
  7991.   Retains the 'n' most recent (highest-numbered) backup files for each file.
  7992.   For example, if oofa.txt, oofa.txt.~1~, oofa.txt.~2~, oofa.txt.~10~,
  7993.   oofa.txt.~12~, and oofa.txt.~100~ exist, "purge /keep:2 oofa.txt" deletes
  7994.   oofa.txt.~1~, oofa.txt.~2~, and oofa.txt.~10~, and keeps oofa.txt,
  7995.   oofa.txt.~12~, and oofa.txt.~100~.  If /KEEP is given without a number,
  7996.   one (the highest numbered) backup file is kept.
  7997.  
  7998. CAUTION: The PURGE command should be used only when *.~*~ files truly are
  7999. backup files.  This is the case for EMACS, and it is the DEFAULT for C-Kermit.
  8000. However, if C-Kermit's FILE COLLISION has been set to RENAME, newly received
  8001. files will look like backup files.  In that case, don't use the PURGE command
  8002. or you'll be removing new files rather than old ones.  (Use SHOW FILE to find
  8003. the FILE COLLISION setting.)
  8004.  
  8005. The PURGE command is presently available only in UNIX.  The command succeeds
  8006. if it deleted any files, or if it deleted no files but there were no errors.
  8007. It fails if it deleted no files and there were errors (i.e. deletion was
  8008. attempted but failed).  In VMS, backup file versions are handled automatically
  8009. by the OS, and a PURGE command can be used at the VMS prompt to clean them up.
  8010.  
  8011. If you want certain switches to be supplied automatically with each DELETE or
  8012. PURGE command, you can set them with SET OPTIONS (Section 1.5.5) and you can
  8013. display any such settings with SHOW OPTIONS.  Of course you can override them
  8014. on a per-command basis by including switches in your PURGE or DELETE command.
  8015.  
  8016. Also see SET FILE COLLISION, SHOW FILE, SEND /NOBACKUP, SET SEND BACKUP, and
  8017. DIRECTORY /[NO]BACKUP.
  8018.  
  8019. 4.6. Starting the Remote Kermit Server Automatically
  8020.  
  8021. As noted on pages 275-276 of "Using C-Kermit" 2nd edition, you can have Kermit
  8022. send "kermit receive" commands automatically when it is in local mode and you
  8023. give a SEND or similar command, to start the remote Kermit receiver in case it
  8024. is not already started.  The "kermit receive" commands are specified by:
  8025.  
  8026.   SET PROTOCOL KERMIT <binary-receive-command> <text-receive-command>
  8027.  
  8028. As of version 7.0, a Kermit protocol option has been added to send a string
  8029. to the host in advance of any Kermit packets when you give a GET-class or
  8030. REMOTE command.  This will switch the remote C-Kermit into the appropriate
  8031. mode or, if the remote system is at a system command (shell) prompt,
  8032. execute the string on the remote system.  The new syntax of the SET PROTOCOL
  8033. KERMIT command is:
  8034.  
  8035.   SET PROTOCOL KERMIT [ <s1> [ <s2> [ <s3> ] ] ]
  8036.  
  8037. where:
  8038.  
  8039.        Default         Meaning
  8040.   s1  {kermit -ir}     Remote "kermit receive in binary mode" command.
  8041.   s2  {kermit -r}      Remote "kermit receive in text mode" command.
  8042.   s3  {kermit -x}      Remote "start kermit server" command.
  8043.  
  8044. NOTE: If the remote Kermit is 6.0, the following are recommended for fast
  8045. startup and high-performance file transfer (see Appendix I in "Using
  8046. C-Kermit", second Edition, for command-line options):
  8047.  
  8048.   s1   kermit -YQir   (Kermit receive binary, skip init file, fast.)
  8049.   s2   kermit -YQTr   (Kermit receive text, skip init file, fast.)
  8050.   s3   kermit -YQx    (Kermit server, skip init file, fast.)
  8051.  
  8052. If the remote is C-Kermit 7.0 or later, change the -x option (enter server
  8053. mode) to -O (uppercase letter O), which means "enter server mode for One
  8054. transaction only); this way, it is not stuck in server after the transfer.
  8055. Also note that the Q is redundant in version 7.0, since fast Kermit protocol
  8056. settings are now the default.
  8057.  
  8058. Note that in case the C-Kermit executable is called "wermit" or "ckermit"
  8059. you can change "kermit" in the strings above to "wermit" or "ckermit" and
  8060. C-Kermit 7.0 or later will recognize these as synonyms for "kermit", in case
  8061. it is at its command prompt when one of these strings is sent to it.
  8062.  
  8063. 4.7. File-Transfer Command Switches
  8064.  
  8065. Over the years, various new methods of transferring a file have accumulated,
  8066. until we had, in addition to the SEND command, also MOVE (send and then
  8067. delete), MAIL (send as email), REMOTE PRINT (send to be printed), CSEND (send
  8068. the output of a command), PSEND (send a part of a file), BSEND (send in binary
  8069. mode), RESEND (resume an interrupted SEND), etc etc.  Similarly: GET, REGET,
  8070. CGET, RETRIEVE, and so on.
  8071.  
  8072. Not only is it confusing to have different names for these commands, many of
  8073. which are not real words, but this also does not allow all combinations, like
  8074. "send a file as mail, then delete it".
  8075.  
  8076. In C-Kermit 7.0, the SEND, GET, and RECEIVE commands were restructured to
  8077. accept modifier switches (switches are explained in Section 1.5).
  8078.  
  8079. 4.7.1. SEND Command Switches
  8080.  
  8081. Without switches, the SEND command still works exactly as before:
  8082.  
  8083.   send oofa.txt      ; send a single file
  8084.   send oofa.*        ; send multiple files
  8085.   send oofa.txt x.x  ; send oofa.txt as x.x (tell receiver its name is x.x)
  8086.   send               ; send from SEND-LIST
  8087.  
  8088. But now the following modifier switches may be included between "send" and the
  8089. filename.  Zero, one, two, or more switches may be included in any combination
  8090. that makes sense.  Switch names (such as /BINARY) can be abbreviated, just
  8091. like any other keywords.  Most of these switches work only when using Kermit
  8092. protocol (/TEXT and /BINARY are the exceptions).
  8093.  
  8094.   /AFTER:date-time
  8095.     Specifies that only those files modified (or, in VMS, created) after
  8096.     the given date-time (see section 1.6) are to be sent.  Examples:
  8097.  
  8098.       send /text /after:{2-Feb-1997 10:28:30} *.txt
  8099.       send /text /after:\fdate(oofa.txt) *.txt
  8100.  
  8101.     Synonym: /SINCE.
  8102.  
  8103.   /ARRAY:arrayname
  8104.     Specifies that instead of sending a file, C-Kermit is to send the
  8105.     contents of the given array.  Since an array does not have a filename,
  8106.     you should include an /AS-NAME switch to specify the name under which
  8107.     the array is to be sent (if you do not, the name "_array_x_" is used,
  8108.     where 'x' is replaced by the array designator).  See section 7.10 for
  8109.     array-name syntax.  As noted in that section, you can also include a
  8110.     range to have a segment of the array sent, rather than the whole
  8111.     thing; for example: "send /array:&a[100:199]".  It is strongly
  8112.     recommended that you accompany the /ARRAY switch with a /TEXT or
  8113.     /BINARY switch to force the desired transfer mode, since otherwise the
  8114.     various automatic mechanisms might switch to binary mode when you
  8115.     really wanted text, or vice versa.  In text mode a line terminator is
  8116.     added to the end of each array element, but not in binary mode.  For
  8117.     details and examples see Section 7.10.11.
  8118.  
  8119.   /AS-NAME:text
  8120.     Specifies "text" as the name to send the file under.
  8121.     You can also still specify the as-name as the second filename on the
  8122.     SEND command line.  The following two commands are equivalent:
  8123.  
  8124.       send oofa.txt oofa.new
  8125.       send /as:oofa.new oofa.txt
  8126.  
  8127.   /BEFORE:date-time
  8128.     Specifies that only those files modified (or, in VMS, created)
  8129.     before the given date-time (section 1.6) are to be sent.
  8130.  
  8131.   /BINARY
  8132.     Performs this transfer in binary mode without affecting the global
  8133.     transfer mode, overriding not only the FILE TYPE and TRANSFER MODE
  8134.     settings, but also the FILE PATTERN setting, but for this SEND command
  8135.     only.  In other words, SEND /BINARY means what it says: send the file
  8136.     in binary mode, regardless of any other settings.  Example:
  8137.  
  8138.       set file type text      ; Set global transfer mode to text
  8139.       send /binary oofa.zip   ; Send a file in binary
  8140.       send oofa.txt           ; This one is sent in text mode
  8141.  
  8142.   /COMMAND
  8143.     SEND /COMMAND is equivalent to CSEND (section 4.2.2) -- it says to send
  8144.     the output from a command, rather than the contents of a file.
  8145.     The first "filename" on the SEND command line is interpreted as the name
  8146.     of a command; the second (if any) is the as-name.  Examples:
  8147.  
  8148.       send /command {grep Sunday oofa.txt} sunday.txt
  8149.       send /as-name:sunday.txt /command {grep Sunday oofa.txt}
  8150.       send /bin /command {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  8151.  
  8152.   /DELETE
  8153.     Deletes the file (or each file in the group) after it has been sent
  8154.     successfully (but does not delete it if it was not sent successfully).
  8155.     SEND /DELETE is equivalent to MOVE.  Has no effect when used with
  8156.     /COMMAND.  Example:
  8157.  
  8158.       send /delete *.log
  8159.  
  8160.   /DOTFILES
  8161.     (UNIX and OS-9 only)  Normally files whose names begin with "." are
  8162.     skipped when matching wildcards that do not also beging with ".".
  8163.     Include /DOTFILES to force these files to be included too.
  8164.  
  8165.   /RECURSIVE
  8166.     Descend the through the directory tree when locating files to send.
  8167.     Automatically sets /PATHNAMES:RELATIVE.  Explained in section 4.11.
  8168.  
  8169.   /EXCEPT:<pattern>
  8170.     See Section 1.5.4.
  8171.  
  8172.   /NOBACKUP
  8173.     This means to skip backup files when sending, even if they match the
  8174.     SEND file specification.  This is equivalent to using SEND /EXCEPT and
  8175.     including *.~[0-9]*~ in the exception list (or *.~*~ if Kermit was built
  8176.     without pattern-matching support; see Section 4.9.1).  Including this
  8177.     switch is equivalent to giving SET SEND BACKUP OFF (Section 4.0.6) prior
  8178.     to SEND, except its effect is local to the SEND command with which it was
  8179.     given.
  8180.  
  8181.   /NODOTFILES
  8182.     The opposite of /DOTFILES (q.v.)
  8183.  
  8184.   /FILENAMES:{CONVERTED,LITERAL}
  8185.     Use this switch to override the current global SET FILE NAMES setting
  8186.     for this transfer only.
  8187.  
  8188.   /FILTER:<command>
  8189.     This specifies a filter to pass the file through before sending it.
  8190.     See the section on file-transfer pipes and filters.  The /FILTER switch
  8191.     applies only to the file-transfer command it is given with; it does not
  8192.     affect the global SEND FILTER setting, if any.
  8193.  
  8194.   /IMAGE
  8195.     VMS: Sends in image mode.  Non-VMS: same as /BINARY.
  8196.  
  8197.   /LABELED
  8198.     VMS and OS/2 only: Sends in labeled mode.
  8199.  
  8200.   /LARGER-THAN:number
  8201.     Specifies that only those files that are longer than the given number
  8202.     of bytes are to be sent.
  8203.  
  8204.   /LISTFILE:filename
  8205.     Specifies that the files to be sent are listed in a file with the given
  8206.     filename.  The file contains one filename per line.  These filenames are
  8207.     not checked in any way; each filename is taken and does not use or
  8208.     depend on any Kermit-specific syntax.  In particular, backslashes are
  8209.     not treated specially, leading and trailing spaces are not stripped,
  8210.     etc.  However, if a filename contains wildcards, they are expanded.
  8211.     Example: If a file named files.txt contains the following lines:
  8212.  
  8213.       blah.txt
  8214.       oofa*
  8215.       x.x
  8216.  
  8217.     (but without leading or trailing spaces), then the C-Kermit command
  8218.     "send /listfile:files.txt" will send the files blah.txt, x.x, and all
  8219.     files whose names start with "oofa", assuming the files exist and are
  8220.     readable.  The /LISTFILE switch, can, of course, be used with other
  8221.     switches when it makes sense, for example, /EXCEPT, /BINARY, /AFTER,
  8222.     /SMALLER, /MOVE-TO, /DELETE, /AS-NAME with a template, etc.
  8223.  
  8224.   /MAIL:address
  8225.     Sends the file as e-mail to the given address or addresses.
  8226.     "send /mail:address filename" is equivalent to "mail filename address".
  8227.     You can include multiple addresses separated by commas.  Examples:
  8228.  
  8229.       send /mail:kermit-support@columbia.edu packet.log
  8230.       send /mail:cmg,fdc,jrd oofa.txt
  8231.  
  8232.     As with any switch argument, if the address or address list contains any
  8233.     spaces, you must enclose it in braces.  The format of the addresses must
  8234.     agree with that understood by the mail-sending program on the receiver's
  8235.     computer.
  8236.  
  8237.   /MOVE-TO:directory-name
  8238.     Specifies that after each (or the only) source file is sent successfully,
  8239.     and ONLY if it is sent successfully, it should be moved to the named
  8240.     directory.  If the directory name contains spaces, enclose it in braces.
  8241.     If the directory does not exist, it is created if possible; if it can't be
  8242.     created, the command fails and an error message is printed.  Example:
  8243.       send /text /move-to:/users/olga/backup/ *.txt
  8244.  
  8245.   /NOT-AFTER:date-time
  8246.     Specifies that only those files modified at or before the given date and
  8247.     time are to be sent.
  8248.  
  8249.   /NOT-BEFORE:date-time
  8250.     Specifies that only those files modified at or after the given date and
  8251.     time are to be sent.
  8252.  
  8253.   /PATHNAMES:{OFF,ABSOLUTE,RELATIVE}
  8254.     Use this switch to override the current global SET SEND PATHNAMES setting
  8255.     for this transfer only.  /PATHNAMES:ABSOLUTE or RELATIVE also sets
  8256.     /FILENAMES:LITERAL (also for this transfer only) since pathnames are not
  8257.     sent otherwise.
  8258.  
  8259.   /RENAME-TO:text
  8260.     Specifies that after the (or each) source file is sent successfully, and
  8261.     ONLY if it is sent successfully, it should be renamed to the name given.
  8262.     If the name contains spaces, enclose it in braces.  If a file group is
  8263.     being sent, then the "text" must contain a variable reference such as
  8264.     \v(filename) (see section 4.1).  Example:
  8265.       send /rename-to:ok_\v(filename) *.*
  8266.     This sends each file in the current directory and if it was sent
  8267.     successfully, changes its name to begin with "ok_".
  8268.  
  8269.   /SMALLER-THAN:number
  8270.     Specifies that only those files that are smaller than the given number
  8271.     of bytes are to be sent.
  8272.  
  8273.   /SUBJECT:text
  8274.     Subject for email.  Actually, this is just a synonym for /AS-NAME.  If the
  8275.     text includes spaces, you must enclose it in braces.  If you don't specify
  8276.     a subject (or as-name), the name of the file is used as the subject.
  8277.     Example:
  8278.       send /mail:kermit-support@columbia.edu /subj:{As requested} packet.log
  8279.  
  8280.   /PRINT:options
  8281.     Sends the file to be printed, optionally specifying options for the
  8282.     printer.  Equivalent to REMOTE PRINT filename options.  Examples:
  8283.  
  8284.       send /print oofa.txt              ; No options.
  8285.       send /print:/copies=3 oofa.txt    ; "/copies=3" is a VMS PRINT switch.
  8286.       send /print:-#3 oofa.txt          ; "-#3" is a UNIX lpr switch.
  8287.  
  8288.   /PROTOCOL:name
  8289.     Uses the given protocol to send the file (Kermit, Zmodem, etc) for this
  8290.     transfer without changing global protocol.  Only available in Kermit 95,
  8291.     UNIX, and OS-9.  Example:
  8292.  
  8293.       set protocol kermit               ; Set global protocol
  8294.       send /proto:zmodem /bin oofa.zip  ; Send just this file with Zmodem
  8295.       send oofa.txt                     ; This file is sent with Kermit
  8296.  
  8297.   /QUIET
  8298.     When sending in local mode, this suppresses the file-transfer display.
  8299.  
  8300.   /RECOVER
  8301.     Used to recover from a previously interrupted transfer; SEND /RECOVER is
  8302.     equivalent to RESEND.  Recovery only works in binary mode; SEND /RECOVER
  8303.     and RESEND include an implied /BINARY switch.  Even then, recovery will
  8304.     successful only if (a) the original (interrupted) transfer was also in
  8305.     binary mode, or (b) if it was in text mode, the two Kermit programs run on
  8306.     platforms where text-mode transfers are not length-changing.
  8307.  
  8308.   /STARTING:number
  8309.     Starts sending the file from the given byte position.
  8310.     SEND /STARTING:n filename is equivalent to PSEND filename n.
  8311.  
  8312.   /TEXT
  8313.     Performs this transfer in text mode without affecting the global
  8314.     transfer mode, overriding not only the FILE TYPE and TRANSFER MODE
  8315.     settings, but also the FILE PATTERN setting, for this SEND command
  8316.     only.  In other words, SEND /TEXT really send the file in text mode,
  8317.     regardless of any other settings or negotiations.
  8318.  
  8319. About mail...  Refer to section 4.7.1.  The same rules apply as for file
  8320. transfer.  If you are mailing multiple files, you can't use an as-name (in
  8321. this case, a subject) unless it contains replacement variables like
  8322. \v(filenum).  For example, if you:
  8323.  
  8324.   send /mail:somebody@xyz.com *.txt
  8325.  
  8326. Then each file will arrive as a separate email message with its name as the
  8327. subject.  But if you:
  8328.  
  8329.   send /mail:somebody@xyz.com /subject:{Here is a file} *.txt
  8330.  
  8331. Then each file message will have the same subject, which is probably not what
  8332. you want.  You can get around this with constructions like:
  8333.  
  8334.   send /mail:somebody@xyz.com /subject:{Here is \v(filename)} *.txt
  8335.  
  8336. which embed the filename in the subject.
  8337.  
  8338. The MOVE, CSEND, MAIL, and RESEND commands now also accept the same switches.
  8339. And the switches are also operative when sending from a SEND-LIST (see "Using
  8340. C-Kermit", 2nd Ed, pp.191-192), so, for example, it is now possible to SEND
  8341. /PRINT or SEND /MAIL from a SEND-LIST.
  8342.  
  8343. The MSEND and MMOVE commands also take switches, but not all of them.  With
  8344. these commands, which take an arbitrary list of filespecs, you can use
  8345. /BINARY, /DELETE, /MAIL, /PRINT, /PROTOCOL, /QUIET, /RECOVER, and /TEXT (and
  8346. /IMAGE or /LABELED, depending on the platform).  MMOVE is equivalent to MSEND
  8347. /DELETE.  (If you want to send a group of files, but in mixed transfer modes
  8348. with per-file as-names, use ADD SEND-LIST and then SEND.)
  8349.  
  8350. The MSEND/MMOVE switches come before the filenames, and apply to all of them:
  8351.  
  8352.   msend /print /text *.log oofa.txt /etc/motd
  8353.  
  8354. If you type any of these commands (SEND, CSEND, MSEND, etc) followed by a
  8355. question mark (?), you will see a list of the switches you can use.  If you
  8356. want to see a list of filenames, you'll need to type something like "send ./?"
  8357. (UNIX, OS/2, Windows, etc), or "send []?" (VMS), etc.  Of course, you can also
  8358. type pieces of a filename (anything that does not start with "/") and then "?"
  8359. to get a list of filenames that start that way; e.g. "send x.?"  still works
  8360. as before.
  8361.  
  8362. In UNIX, where "/" is also the directory separator, there is usually no
  8363. ambiguity between a fully-specified pathname and a switch, except when a file
  8364. in the root directory has the same name as a switch (as noted in section 1.5):
  8365.  
  8366.   send /etc/motd                        ; Works as expected
  8367.   send /command                         ; ???
  8368.  
  8369. The second example interprets "/command" as a switch, not a filename.  To
  8370. actually send a file called "command" in the root directory, use:
  8371.  
  8372.   send {/command}
  8373.  
  8374. or other system-dependent forms such as //command, /./command, c:/command,
  8375. etc, or cd to / and then "send command".
  8376.  
  8377. 4.7.2. GET Command Switches
  8378.  
  8379. Without switches, the GET command still works about the same as before:
  8380.  
  8381.   get oofa.txt                          ; GET a single file
  8382.   get oofa.*                            ; GET multiple files
  8383.  
  8384. However, the mechanism for including an "as-name" has changed.  Previously,
  8385. in order to include an as-name, you were required to use the "multiline" form
  8386. of GET:
  8387.  
  8388.   get
  8389.   <remote-filespec>
  8390.   <local-name>
  8391.  
  8392. This was because the remote filespec might contain spaces, and so there would
  8393. be no good way of telling where it ended and where the local name began, e.g:
  8394.  
  8395.   get profile exec a foo
  8396.  
  8397. But now since we can use {braces} for grouping, we don't need the multiline
  8398. GET form any more, and in fact, support for it has been removed.  If you give
  8399. a GET command by itself on a line, it fails and an error message is printed.
  8400. The new form is:
  8401.  
  8402.   GET [ switches... ] remote-name [ local-name ]
  8403.  
  8404. If the remote-name or local-name contains spaces, they must be enclosed in
  8405. braces:
  8406.  
  8407.   get {profile exec a} foo
  8408.   get oofa.txt {~/My Files/Oofa text}
  8409.  
  8410. If you want to give a list of remote file specifications, use the MGET
  8411. command:
  8412.  
  8413.   MGET [ switches... ] remote-name [ remote-name [ remote-name ... ] ]
  8414.  
  8415. Now you can also include modifier switches between "get" or "mget" and the
  8416. remote-name; most of the same switches as SEND:
  8417.  
  8418.   /AS-NAME:text
  8419.     Specifies "text" as the name to store the incoming file under.  (This
  8420.     switch is not available for MGET.)  You can also still specify the
  8421.     as-name as the second filename on the GET command line.  The following
  8422.     two commands are equivalent:
  8423.  
  8424.       get oofa.txt oofa.new
  8425.       get /as:oofa.new oofa.txt
  8426.  
  8427.   /BINARY
  8428.     Tells the server to send the given file(s) in binary mode without
  8429.     affecting the global transfer mode.  Example:
  8430.  
  8431.       set file type text      ; Set global transfer mode to text
  8432.       get /binary oofa.zip    ; get a file in binary mode
  8433.       get oofa.txt            ; This one is transferred in text mode
  8434.  
  8435.     Or, perhaps more to the point:
  8436.  
  8437.       get /binary foo.txt     ; where "*.txt" is a text-pattern
  8438.  
  8439.     This works only if the server is C-Kermit 7.0 or later or K95 1.1.18
  8440.     or later.
  8441.  
  8442.   /COMMAND
  8443.     GET /COMMAND is equivalent to CGET (section 4.2.2) -- it says to receive
  8444.     the file into the standard input of a command, rather than saving it on
  8445.     disk.  The /AS-NAME or the second "filename" on the GET command line is
  8446.     interpreted as the name of a command.  Examples:
  8447.  
  8448.       get /command sunday.txt {grep Sunday oofa.txt}
  8449.       get /command /as-name:{grep Sunday oofa.txt} sunday.txt
  8450.       get /bin /command {!gunzip -c | tar xf -} {tar cf - . | gzip -c}
  8451.  
  8452.   /DELETE
  8453.     Asks the Kermit server to delete the file (or each file in the group)
  8454.     after it has been transferred successfully (but not to delete it if it
  8455.     was not sent successfully).  GET /DELETE is equivalent to RETRIEVE.
  8456.     Example:
  8457.  
  8458.       get /delete *.log
  8459.  
  8460.   /EXCEPT:pattern
  8461.     Specifies that any files whose names match the pattern, which can be a
  8462.     regular filename, or may contain "*" and/or "?" metacharacters,
  8463.     are to be refused upon arrival.  To specify multiple patterns (up to 8),
  8464.     use outer braces around the group, and inner braces around each pattern:
  8465.  
  8466.       /EXCEPT:{{pattern1}{pattern2}...}
  8467.  
  8468.     See the description of SEND /EXCEPT in Section 4.7.1 for examples, etc.
  8469.     Refusal is accomplished using the Attribute Rejection mechanism (reason
  8470.     "name"), which works only when Attribute packets have been successfully
  8471.     negotiated.
  8472.  
  8473.   /FILENAMES:{CONVERTED,LITERAL}
  8474.     Use this switch to override the current global SET FILE NAMES setting
  8475.     for this transfer only.
  8476.  
  8477.   /FILTER:<command>
  8478.     This specifies a filter to pass the incoming file through before writing
  8479.     to disk.  See the section on file-transfer pipes and filters.  The /FILTER
  8480.     switch applies only to the file-transfer command it is given with; it does
  8481.     not affect the global RECEIVE FILTER setting, if any.
  8482.  
  8483.   /IMAGE
  8484.     VMS: Transfer in image mode.  Non-VMS: same as /BINARY.
  8485.  
  8486.   /LABELED
  8487.     VMS and OS/2 only: Specifies labeled transfer mode.
  8488.  
  8489.   /MOVE-TO:<directory>
  8490.     This tells C-Kermit to move each file that is successfully received to
  8491.     the given directory.  Files that are not successfully received are not
  8492.     moved.  By default, files are not moved.
  8493.  
  8494.   /PATHNAMES:{OFF,ABSOLUTE,RELATIVE,AUTO}
  8495.     Use this switch to override the current global SET RECEIVE PATHNAMES
  8496.     setting for this transfer only.  /PATHNAMES:ABSOLUTE or RELATIVE also sets
  8497.     /FILENAMES:LITERAL (also for this transfer only) since incoming pathnames
  8498.     would not be treated as pathnames otherwise.  See Section 4.10.
  8499.  
  8500.   /QUIET
  8501.     When sending in local mode, this suppresses the file-transfer display.
  8502.  
  8503.   /RECOVER
  8504.     Used to recover from a previously interrupted transfer; GET /RECOVER
  8505.     is equivalent to REGET.  Recovery only works in binary mode; SEND /RECOVER
  8506.     and RESEND include an implied /BINARY switch.  Even then, recovery will
  8507.     successful only if (a) the original (interrupted) transfer was also in
  8508.     binary mode, or (b) if it was in text mode, the two Kermit programs run
  8509.     on platforms where text-mode transfers are not length-changing.
  8510.  
  8511.   /RECURSIVE
  8512.     Tells the server that the GET file specification applies recursively.
  8513.     This switch also automatically sets /PATHNAMES:RELATIVE in both the server
  8514.     AND the client.  When used in conjunction with /DELETE, this "moves" a
  8515.     directory tree from the server's computer to the client's computer (except
  8516.     that only regular files are deleted from the server's computer, not
  8517.     directories; thus the original directories will be left, but will contain
  8518.     no files).  Note that all servers that support /RECURSIVE do not
  8519.     necessarily do so in combination with other switches, such as /RECOVER.
  8520.     (Servers that do include C-Kermit 7.0 and later, K95 1.1.18 and later.)
  8521.  
  8522.   /RENAME-TO:<string>
  8523.     This tells C-Kermit to rename each file that is successfully received to
  8524.     the given string.  Files that are not successfully received are not
  8525.     renamed.  By default, files are not renamed.  The <string> can be a
  8526.     literal string, which is appropriate when only one file is being received,
  8527.     or it can contain one or more variables that are to be evaluated at the
  8528.     time each file is received, such as \v(filename), \v(filenumber),
  8529.     \v(ntime), \v(pid), \v(user), etc.  WARNING: if you give a literal string
  8530.     and more than one file arrives, each incoming file will be given the same
  8531.     name (but SET FILE COLLISION BACKUP or RENAME can be used to keep the
  8532.     incoming files from overwriting each other).
  8533.  
  8534.   /TEXT
  8535.     Tells the server to perform this transfer in text mode without affecting
  8536.     its global transfer mode.  See /BINARY for additional info.
  8537.  
  8538. The /MAIL and /PRINT options are not available, but you can use /COMMAND
  8539. to achieve the same effect, as in these UNIX examples:
  8540.  
  8541.   get /command oofa.txt {mail kermit@columbia.edu}
  8542.   get /command oofa.txt lpr
  8543.  
  8544. In OS/2 or Windows, you can GET and print like this:
  8545.  
  8546.   get oofa.txt prn
  8547.  
  8548. The CGET, REGET, RETRIEVE commands also accept the same switches as GET.  CGET
  8549. automatically sets /COMMAND; REGET automatically sets /RECOVER and /BINARY,
  8550. and RETRIEVE automatically sets /DELETE.
  8551.  
  8552. 4.7.3. RECEIVE Command Switches
  8553.  
  8554. Without switches, the RECEIVE command still works as before:
  8555.  
  8556.   receive            ; Receives files under their own names
  8557.   receive /tmp       ; Ditto, but into the /tmp directory
  8558.   r                  ; Same as "receive"
  8559.   receive foo.txt    ; Receives a file and renames to foo.txt
  8560.  
  8561. Now you can also include modifier switches may be included between "receive"
  8562. and the as-name; most of the same switches as GET:
  8563.  
  8564.   /AS-NAME:text
  8565.     Specifies "text" as the name to store the incoming file under.
  8566.     You can also still specify the as-name as a filename on the
  8567.     command line.  The following two commands are equivalent:
  8568.       r oofa.new
  8569.       r /as:oofa.new
  8570.  
  8571.   /BINARY
  8572.     Performs this transfer in binary mode without affecting the global
  8573.     transfer mode.  NOTE: This does not override the incoming filetype (as
  8574.     it does with GET), so this switch is useful only if ATTRIBUTE TYPE is
  8575.     OFF, or if the other Kermit does not send a TYPE (text or binary)
  8576.     attribute.  In any case, it has no affect whatsoever on the file sender.
  8577.  
  8578.   /COMMAND
  8579.     RECEIVE /COMMAND is equivalent to CRECEIVE (section 4.2.2) -- it says to
  8580.     receive the file into the standard input of a command, rather than saving
  8581.     it on disk.  The /AS-NAME or the "filename" on the RECEIVE command line
  8582.     is interpreted as the name of a command.
  8583.  
  8584.       r /command {grep Sunday oofa.txt}
  8585.       r /command /as-name:{grep Sunday oofa.txt}
  8586.       r /bin /command {tar cf - . | gzip -c}
  8587.  
  8588.   /EXCEPT:pattern
  8589.     Specifies that any files whose names match the pattern, which can be a
  8590.     regular filename, or may contain "*" and/or "?" metacharacters,
  8591.     are to be refused upon arrival.  To specify multiple patterns (up to 8),
  8592.     use outer braces around the group, and inner braces around each pattern:
  8593.  
  8594.       /EXCEPT:{{pattern1}{pattern2}...}
  8595.  
  8596.     See the description of SEND /EXCEPT in Section 4.7.1 for examples, etc.
  8597.     Refusal is accomplished using the Attribute Rejection mechanism (reason
  8598.     "name"), which works only when Attribute packets have been successfully
  8599.     negotiated.
  8600.  
  8601.   /FILENAMES:{CONVERTED,LITERAL}
  8602.     Use this switch to override the current global SET FILE NAMES setting
  8603.     for this transfer only.
  8604.  
  8605.   /FILENAMES:{CONVERTED,LITERAL}
  8606.     Use this switch to override the current global SET FILE NAMES setting
  8607.     for this transfer only.
  8608.  
  8609.   /FILTER:<command>
  8610.     This specifies a filter to pass the incoming file through before writing
  8611.     to disk.  See the section on file-transfer pipes and filters.  The /FILTER
  8612.     switch applies only to the file-transfer command it is given with; it does
  8613.     not affect the global RECEIVE FILTER setting, if any.
  8614.  
  8615.   /IMAGE
  8616.     VMS: Transfer in image mode.  Non-VMS: same as /BINARY.
  8617.     See comments under RECEIVE /BINARY.
  8618.  
  8619.   /LABELED
  8620.     VMS and OS/2 only: Specifies labeled transfer mode.
  8621.     See comments under RECEIVE /BINARY.
  8622.  
  8623.   /MOVE-TO:<directory>
  8624.     This tells C-Kermit to move each file that is successfully received to
  8625.     the given directory.  Files that are not successfully received are not
  8626.     moved.  By default, files are not moved.
  8627.  
  8628.   /PATHNAMES:{ABSOLUTE,RELATIVE,OFF,AUTO}
  8629.     Use this switch to override the current global SET RECEIVE PATHNAMES
  8630.     setting for this transfer only.  See Section 4.10.
  8631.  
  8632.   /RECURSIVE
  8633.     When used with the RECEIVE command, /RECURSIVE is simply a synonym
  8634.     for /PATHNAMES:RELATIVE.
  8635.  
  8636.   /RENAME-TO:<string>
  8637.     This tells C-Kermit to rename each file that is successfully received to
  8638.     the given string.  Files that are not successfully received are not
  8639.     renamed.  By default, files are not renamed.  The <string> can be a
  8640.     literal string, which is appropriate when only one file is being received,
  8641.     or it can contain one or more variables that are to be evaluated at the
  8642.     time each file is received, such as \v(filename), \v(filenumber),
  8643.     \v(ntime), \v(pid), \v(user), etc.  WARNING: if you give a literal string
  8644.     and more than one file arrives, each incoming file will be given the same
  8645.     name (but SET FILE COLLISION BACKUP or RENAME can be used to keep the
  8646.     incoming files from overwriting each other).
  8647.  
  8648.   /QUIET
  8649.     When receiving in local mode, this suppresses the file-transfer display.
  8650.  
  8651.   /TEXT
  8652.     Receives in text mode without affecting the global transfer mode.  See
  8653.     comments under RECEIVE /BINARY.
  8654.  
  8655. The /MAIL and /PRINT options are not available, but you can use /COMMAND
  8656. to achieve the same effect, as in these UNIX examples:
  8657.  
  8658.   r /command {mail kermit@columbia.edu}
  8659.   r /command lpr
  8660.  
  8661. In OS/2 or Windows, you can RECEIVE and print like this:
  8662.  
  8663.   receive prn
  8664.  
  8665. The CRECEIVE command now also accepts the same switches.
  8666.  
  8667. 4.8. Kermit Protocol Improvements
  8668.  
  8669. 4.8.1. Multiple Attribute Packets
  8670.  
  8671. C-Kermit 7.0 now sends more than one Attribute packet if a file's attributes
  8672. do not fit into a single packet of the negotiated length.  If a particular
  8673. attribute (such as file creation date-time) does not fit within the negotiated
  8674. length (which will only happen when the negotiated length is around 20 or
  8675. less), that attribute is not sent at all.
  8676.  
  8677. 4.8.2. Very Short Packets
  8678.  
  8679. There are certain situations where extremely short packets must be used;
  8680. 20 or 30 bytes at most.  This can happen when one or more devices along the
  8681. communication path have very small buffers and lack an effective means of
  8682. flow control.  Examples are sometimes cited involving radio modems.
  8683.  
  8684. When the maximum packet length is shorter than certain packets that would be
  8685. sent, those packets are either truncated or else broken up into multiple
  8686. packets.  Specifically:
  8687.  
  8688.  1. Parameter negotiation packets (I, S, and their ACKs) are truncated to
  8689.     the negotiated length.  Any parameters that do not fit are reset to
  8690.     their default values.  There is no provision in the Kermit protocol for
  8691.     fragmentation and reassembly of parameter strings.
  8692.  
  8693.  2. File header packets (containing the filename) are simply truncated.
  8694.     There is no provision in the Kermit protocol for fragmentation and
  8695.     reassembly of filenames.
  8696.  
  8697.  3. Attribute packets are fragmented and reassembled as described in 4.8.1
  8698.     without loss of data, except in case a field will not fit at all in
  8699.     the negotiated length (the longest attribute is usually the date and
  8700.     time of file creation/modification) because of the rule that attributes
  8701.     may not be broken across packets.
  8702.  
  8703.  4. Data packets and other packets are unaffected -- they can be as short
  8704.     as they need to be, within reason.
  8705.  
  8706. 4.9. Wildcard / File Group Expansion
  8707.  
  8708. "Wildcard" refers to the notation used in filenames to specify a group of
  8709. files by pattern matching.
  8710.  
  8711. 4.9.1. In UNIX C-Kermit
  8712.  
  8713. Prior to C-Kermit 7.0, C-Kermit was capable of expanding wildcard strings
  8714. containing only the "metacharacters" '*' and '?':
  8715.  
  8716. * Matches any sequence of zero or more characters.  For example: "ck*.c"
  8717.   matches all files whose names start with "ck" and end with ".c", including
  8718.   "ck.c".
  8719.  
  8720. ? Matches any single character.  For example, "ck?.c" matches all files whose
  8721.   names are exactly 5 characters long and start with "ck" and end with ".c".
  8722.   When typing commands at the prompt, you must precede any question mark to
  8723.   be used for matching by a backslash (\) to override the normal function of
  8724.   question mark, which is providing menus and file lists.
  8725.  
  8726. C-Kermit 7.0 adds the additional features that users of ksh, csh, and bash
  8727. are accustomed to:
  8728.  
  8729. [abc]
  8730.   Square brackets enclosing a list of characters matches any single
  8731.   character in the list.  Example: ckuusr.[ch] matches ckuusr.c and ckuusr.h.
  8732.  
  8733. [a-z]
  8734.   Square brackets enclosing a range of characters; the hyphen separates the
  8735.   low and high elements of the range.  For example, [a-z] matches any
  8736.   character from a to z.
  8737.  
  8738. [acdm-z]
  8739.   Lists and ranges may be combined.  This example matches a, c, d, or m
  8740.   through z.
  8741.  
  8742. {string1,string2,...}
  8743.   Braces enclose a list of strings to be matched.  For example:
  8744.   ck{ufio,vcon,cmai}.c matches ckufio.c, ckvcon.c, or ckcmai.c.  The strings
  8745.   may themselves contain metacharacters, bracket lists, or indeed, other
  8746.   lists of strings, but (when matching filenames) they may not contain
  8747.   directory separators.
  8748.  
  8749. Thus, the metacharacters in filenames (and in any other field that can be a
  8750. pattern, such as the IF MATCH pattern, SEND or GET exception lists, etc) are:
  8751.  
  8752.  * ? [ {
  8753.  
  8754. And within braces only, comma (,) is a metacharacter.
  8755.  
  8756. To include a metacharacter in a pattern literally, precede it with a backslash
  8757. '\' (or two if you are passing the pattern to a macro).  Examples:
  8758.  
  8759.   send a*b      ; Send all files whose names start with 'a' and end with 'b'.
  8760.   send a?b      ; Ditto, but the name must be exactly three characters long.
  8761.   send a[a-z]b  ; Ditto, but the second character must be a lowercase letter.
  8762.   send a[x\-z]b ; Ditto, except the second character must be 'x', '-', or 'y'.
  8763.   send a[ghi]b  ; Ditto, except the second character must be 'g', 'h', or 'i'.
  8764.   send a[?*]b   ; Ditto, except the second character must be '?' or '*'.
  8765.   send a[\?\*]b ; Same as previous.
  8766.   send *?[a-z]* ; All files with names containing at least one character
  8767.                 ; that is followed by a lowercase letter.
  8768.  
  8769. Or, more practically:
  8770.  
  8771.   send ck[cuw]*.[cwh]  ; Send the UNIX C-Kermit source files.
  8772.  
  8773. To refer to the C-Kermit sources files and makefile all in one filespec:
  8774.  
  8775.   {{makefile,ck[cuw]*.[cwh]}}
  8776.  
  8777. (NOTE: if the entire pattern is a {stringlist}, you must enclose it it TWO
  8778. pairs of braces, since the SEND command strips the outer brace pair, because
  8779. of the "enclose in braces if the filename contains spaces" rule).
  8780.  
  8781. If the makefile is called ckuker.mak:
  8782.  
  8783.   ck[cuw]*.{[cwh],mak}
  8784.  
  8785. (NOTE: double braces are not needed here since the pattern does not both
  8786. begin and end with a brace.)
  8787.  
  8788. To add in all the C-Kermit text files:
  8789.  
  8790.   ck[cuw]*.{[cwh],mak,txt}
  8791.  
  8792. All of these features can be used anywhere you would type a filename that
  8793. is allowed to contain wildcards.
  8794.  
  8795. When you are typing at the command prompt, an extra level of quoting is
  8796. required for the '?' character to defeat its regular function of producing a
  8797. list of files that match what you have typed so far, for example:
  8798.  
  8799.   send ck[cu]?
  8800.  
  8801. lists all the files whose names start with ckc and cku.  If you quote the
  8802. question mark, it is used as a pattern-matching character, for example:
  8803.  
  8804.   send ck\?[ft]io.c
  8805.  
  8806. sends all the file and communications i/o modules for all the platforms:
  8807. ckufio.c, ckutio.c, ckvfio.c, ckvtio.c, etc.
  8808.  
  8809. If, however, a filename actually contains a question mark and you need to
  8810. refer to it on the command line, you must use three (3) backslashes.  For
  8811. example, if the file is actually called ck?fio.c, you would use:
  8812.  
  8813.   send ck\\\?fio.c
  8814.  
  8815. Further notes on quoting:
  8816.  
  8817.  . A single backslash is sufficient for quoting a special character at the
  8818.    command prompt or in a command file.  However, when passing patterns to
  8819.    macros you'll need double backslashes, and when referring to these
  8820.    patterns within the macro, you'll need to use \fcontents(\%1) (see
  8821.    Section 1.11.5).  You should enclose macro argument references in
  8822.    braces in case grouped arguments were passed.  Example:
  8823.  
  8824.      define ismatch {
  8825.          xif match {\fcont(\%1)} {\fcont(\%2)} {
  8826.              end 0 MATCH
  8827.          } else {
  8828.              end 1 NO MATCH
  8829.          }
  8830.      }
  8831.      ismatch ab*yz a*\\**z           ; Backslash must be doubled
  8832.      ismatch {abc def xyz} *b*e*y*   ; Braces must be used for grouping
  8833.  
  8834.  . Watch out for possible conflicts between {} in filename patterns and
  8835.    {} used for grouping multiple words into a single field, when the pattern
  8836.    has outer braces.  For example, in:
  8837.  
  8838.      if match {abc xyz} {a* *z} echo THEY MATCH
  8839.  
  8840.    braces must be used to group "abc xyz" into a single string.  Kermit strips
  8841.    off the braces before comparing the string with the pattern.  Therefore:
  8842.  
  8843.      if match makefile {makefile,Makefile} echo THEY MATCH
  8844.  
  8845.    does not work, but:
  8846.  
  8847.      if match makefile {{makefile,Makefile}} echo THEY MATCH
  8848.  
  8849.    does.
  8850.  
  8851.  . If you use a pattern that has outer braces, like {*.txt,*.doc},
  8852.    in a field that accepts a pattern list (like SEND /EXCEPT:xxx), you'll
  8853.    need to add two extra sets of outer braces:
  8854.  
  8855.      send /except:{{{*.txt,*.doc}}} *.*
  8856.  
  8857. C-Kermit's new pattern matching capabilities are also used when C-Kermit is
  8858. in server mode, so now you can send requests such as:
  8859.  
  8860.   get ck[cuw]*.[cwh]
  8861.  
  8862. to a C-Kermit server without having to tell it to SET WILD SHELL first.
  8863. Previously this would have required:
  8864.  
  8865.   mget ckc*.c ckc*.w ckc*.h cku*.c cku*.w cku*.h ckw*.c ckw*.w ckw*.h
  8866.  
  8867. The new pattern matching features make SET WILD SHELL redundant, and barring
  8868. any objections, it will eventually be phased out.  (One possible reason for
  8869. retaining it would be as an escape mechanism when Kermit does not understand
  8870. the underlying file system.)
  8871.  
  8872. By the way, patterns such as these are sometimes referred to as "regular
  8873. expressions", but they are not quite the same.  In a true regular expression
  8874. (for example), "*" means "zero or more repetitions of the previous item", so
  8875. (for example), "([0-9]*)" would match zero or more digits in parentheses.  In
  8876. Kermit (and in most shells), this matches one digit followed by zero or more
  8877. characters, within parentheses.  Here are some hints:
  8878.  
  8879.  . Although you can't match any sequence of digits (or letters, etc), you
  8880.    can match (say) 1, 2, or 3 of them in row.  For example, the following
  8881.    pattern matches Kermit backup files (with backup numbers from 1 to 999):
  8882.  
  8883.      *.~{[1-9],[1-9][0-9],[1-9][0-9][0-9]}~
  8884.  
  8885.  . There is presently no NOT operator, so no way to match any character or
  8886.    string EXCEPT the one(s) shown.
  8887.  
  8888. In other wildcarding news...
  8889.  
  8890.  . You may now "send xxx" where "xxx" is a directory name, and this will send
  8891.    all the files from the directory xxx, as if you had typed "send xxx/*".
  8892.    You can also use the special shorthand "send ." to send all the files from
  8893.    the current directory.
  8894.  
  8895.  . To easily skip over backup files (the ones whose names end like .~22~)
  8896.    when sending, you can use SEND /NOBACKUP (see Section 4.0.6 for details).
  8897.  
  8898.  . When choosing Kermit to expand wildcards, rather than the shell, you can
  8899.    choose whether "dot files" -- files whose names begin with ".", which are
  8900.    normally "invisible" -- should be matched:
  8901.  
  8902.      SET WILD KERMIT /NO-MATCH-DOT-FILES (this is the default)
  8903.      SET WILD KERMIT /MATCH-DOT-FILES    (this allows matching of "." files)
  8904.  
  8905.    or include the /DOTFILES or /NODOTFILES switch on the command you are
  8906.    using, such as SEND or DIRECTORY.
  8907.  
  8908.  . Commands such as DIRECTORY and SEND allow recursive directory traversal.
  8909.    There are also new functions for this to use in scripts.  See Section
  8910.    4.11 for details.
  8911.  
  8912. When building file lists in UNIX, C-Kermit follows symbolic links.  Because of
  8913. this, you might encounter any or all of the following phenomena:
  8914.  
  8915.  . Multiple copies of the same file; e.g. one from its real directory and
  8916.    others from links to its real directory, if both the real directory and
  8917.    the links to it are in the wildcard expansion list.
  8918.  
  8919.  . A command might unexpectedly "hang" for a long time because an NFS link
  8920.    might not be responding, or the directory you are looking at contains
  8921.    a link to a huge directory tree (example: "directory /recursive /etc"
  8922.    when /etc/spool is a symlink to /var/spool, which is a large organization's
  8923.    incoming email directory, containing tens of thousands of subdirectories).
  8924.  
  8925. The size of the file list that Kermit can build is limited in most C-Kermit
  8926. implementations.  The limit, if any, depends on the implementation.  Use the
  8927. SHOW FEATURES command and look in the alphabetized options list for MAXWLD to
  8928. see the value.
  8929.  
  8930. 4.9.2. In Kermit 95
  8931.  
  8932. Kermit 95 1.1.18 and later uses the same pattern matching syntax as in UNIX,
  8933. but (as always) you will encounter numerous difficulties if you use backslash
  8934. (\) as the directory separator.  In any command where K95 parses filenames
  8935. itself (that is, practically any file-oriented command except RUN), you can
  8936. use forward slash (/) as the directory separator to avoid all the nasty
  8937. conflicts.
  8938.  
  8939. 4.9.3. In VMS, AOS/VS, OS-9, VOS, etc.
  8940.  
  8941. Platforms other than UNIX, Windows 95/98/NT, and OS/2 have their own
  8942. filename matching capabilities that are, in general, different from Kermit's
  8943. built-in ones and in any case might conflict with them.  For example, []
  8944. encloses directory names in VMS.
  8945.  
  8946. Nevertheless you can still use all the pattern-matching capabilities described
  8947. in Section 4.9.1 by loading a file list into an array (e.g. with
  8948. \ffiles(*,&a), see Section 4.11.3) and then using IF MATCH on the members.
  8949.  
  8950. 4.10. Additional Pathname Controls
  8951.  
  8952. In version 6.0 and earlier, C-Kermit's SET { SEND, RECEIVE } PATHNAMES command
  8953. had only ON and OFF as options.  In version 7.0, there are more choices:
  8954.  
  8955. SET SEND PATHNAMES OFF
  8956.   When sending a file, strip all disk/directory information from the name.
  8957.   Example: "send /usr/olga/letters/oofa.txt" sends the file as "oofa.txt".
  8958.   This applies to actual filenames, not to any as-name you might specify.
  8959.  
  8960. SET SEND PATHNAMES RELATIVE
  8961.   When sending a file, leave the pathname on as given.  For example, if your
  8962.   current directory is /usr/olga, "send letters/oofa.txt" sends the file as
  8963.   "letters/oofa.txt", not "/usr/olga/letters/oofa.txt" or "letters.txt".
  8964.  
  8965. SET SEND PATHNAMES ABSOLUTE
  8966.   When sending a file, convert its name to the full, absolute local pathname.
  8967.   For example, if your current directory is /usr/olga, "send letters/oofa.txt"
  8968.   sends the file as "/usr/olga/letters/oofa.txt".  NOTE: Even with this
  8969.   setting, device and/or node names are not included.  For example, in VMS,
  8970.   any node or device name is stripped; in Windows or OS/2, any disk letter
  8971.   is stripped.
  8972.  
  8973. SET RECEIVE PATHNAMES OFF
  8974.   When receiving a file, strip all disk/directory information from the name
  8975.   before attempting to store it.  This applies to incoming filename, not to
  8976.   any as-name you might specify.  Example: If a file arrives under the name
  8977.   "/usr/olga/letters/oofa.txt" it is stored simply as "oofa.txt" in your
  8978.   download directory or, if no download directory has been specified, in your
  8979.   current directory.
  8980.  
  8981. SET RECEIVE PATHNAMES RELATIVE
  8982.   When receiving a file, leave the pathname on as it appears in the incoming
  8983.   name, but if the incoming name appears to be absolute, make it relative to
  8984.   your current or download directory.  Examples:
  8985.  
  8986.     "oofa.txt" is stored as "oofa.txt".
  8987.  
  8988.     "letters/oofa.txt" is stored as "letters/oofa.txt"; the "letters"
  8989.     subdirectory is created if it does not already exist.
  8990.  
  8991.     "/usr/olga/letters/oofa.txt" is stored as "usr/olga/letters/oofa.txt"
  8992.     in your current or download directory, and the "usr", "usr/olga", etc,
  8993.     directories are created if they do not exist.
  8994.  
  8995. SET RECEIVE PATHNAMES ABSOLUTE
  8996.   The incoming filename is used as given.  Thus it cannot be stored unless the
  8997.   given path (if any) already exists or can be created.  In this case, node,
  8998.   device, or disk designations are NOT stripped, since they most likely
  8999.   were given explicitly by the user as an as-name, meant to be used as given.
  9000.  
  9001. SET RECEIVE PATHNAMES AUTO
  9002.   This is the default, and means RELATIVE if the sender tells me it is a
  9003.   recursive transfer, OFF otherwise.
  9004.  
  9005. Set FILE NAMES CONVERTED now also affects pathnames too.  When PATHNAMES are
  9006. RELATIVE or ABSOLUTE and FILE NAMES are CONVERTED, the file sender converts
  9007. its native directory-name format to UNIX format, and the file receiver
  9008. converts from UNIX format to its native one; thus UNIX format is the common
  9009. intermediate representation for directory hierarchies, as it is in the
  9010. ZIP/UNZIP programs (which is why ZIP archives are transportable among, UNIX,
  9011. DOS, and VMS).
  9012.  
  9013. Here's an example in which a file is sent from Windows to UNIX with relative
  9014. pathnames and FILE NAMES CONVERTED:
  9015.  
  9016.   Source name                Intermediate name      Destination Name
  9017.   C:\K95\TMP\OOFA.TXT        K95/TMP/OOFA.TXT       k95/tmp/oofa.txt
  9018.  
  9019. In a more complicated example, we send the same file from Windows to VMS:
  9020.  
  9021.   Source name                Intermediate name      Destination Name
  9022.   C:\K95\TMP\OOFA.TXT        K95/TMP/OOFA.TXT       [.K95.TMP]OOFA.TXT
  9023.  
  9024. (Note that disk letters and device designations are always stripped when
  9025. pathnames are relative).
  9026.  
  9027. As you can imagine, as more and more directory formats are considered, this
  9028. approach keeps matters simple: on each platform, Kermit must know only its
  9029. own local format and the common intermediate one.  In most cases, the receiver
  9030. can detect which format is used automatically.
  9031.  
  9032. 4.11. Recursive SEND and GET: Transferring Directory Trees
  9033.  
  9034. C-Kermit 7.0 in selected versions (UNIX, VMS, VOS, AOS/VS, Windows, and OS/2
  9035. at this writing) now permits the SEND command to traverse directories
  9036. "recursively" if you ask it to; that is, to send files from the current or
  9037. specified directory and all of its subdirectories too, and their
  9038. subdirectories, etc.  (Some other commands can do this too, including
  9039. DIRECTORY.)
  9040.  
  9041. This feature is new to UNIX, Windows, VOS, and OS/2.  VMS and AOS/VS have
  9042. always included "wildcard" or "template" characters that allow this, and in
  9043. this case, recursive directory traversal could happen behind Kermit's back,
  9044. i.e. Kermit does not have to do it itself (in VMS, the notation is "[...]"  or
  9045. "[directory...]"; in AOS/VS is "#").  In C-Kermit 7.0, however, SEND
  9046. /RECURSIVE is supported by C-Kermit itself for VMS.
  9047.  
  9048. 4.11.1. Command-Line Options
  9049.  
  9050. To descend a directory tree when sending files, use the -L command-line option
  9051. to indicate that the send operation is to be recursive, and include a name or
  9052. pattern to be sent.  When giving a pattern, you should enclose it in quotes to
  9053. prevent the shell from expanding it.  Examples:
  9054.  
  9055.   $ kermit -Ls "/usr/olga/*" # send all of Olga's files in all her directories
  9056.   $ kermit -Ls foo.txt       # send all foo.txt files in this directory tree
  9057.   $ kermit -Ls "*.txt"       # send all .txt files in this directory tree
  9058.   $ kermit -Ls "letters/*"   # send all files in the letters directory tree
  9059.   $ kermit -Ls letters       # send all files in the letters directory tree
  9060.   $ kermit -Ls "*"           # send all files in this directory tree
  9061.   $ kermit -Ls .             # UNIX only: send all files in this directory tree
  9062.   $ kermit -s .              # UNIX only: a filename of . implies -L
  9063.  
  9064. If you let the shell expand wildcards, Kermit only sends files whose names
  9065. match files in the current or given directory, because the shell replaces an
  9066. unquoted wildcard expression with the list of matching files -- and the shell
  9067. does not build recursive lists.  Note that the "." notation for the tree
  9068. rooted at the current directory is allowed only in UNIX, since in Windows and
  9069. OS/2, it means "*.*" (nonrecursive).
  9070.  
  9071. 4.11.2. The SEND /RECURSIVE Command
  9072.  
  9073. If you include the /RECURSIVE switch in a SEND (or MOVE, or similar) command,
  9074. it means to descend the current or specified directory tree searching for
  9075. files whose names match the given name or pattern.  Since this is not terribly
  9076. useful unless you also include pathnames with the outbound files, the
  9077. /RECURSIVE switch also includes an implicit /PATHNAMES:RELATIVE switch (which
  9078. you can undo by including an explicit /PATHNAMES switch after the /RECURSIVE
  9079. switch).
  9080.  
  9081. Examples:
  9082.  
  9083. SEND /RECURSIVE *
  9084.   Sends all of the files in the current directory and all the files in
  9085.   all of its subdirectories, and all of their subdirectories, etc, including
  9086.   their relative pathnames.  Empty directories are not sent.
  9087.  
  9088. SEND /RECURSIVE /PATHNAMES:ABSOLUTE *
  9089.   Sends all of the files in the current directory and all the files in
  9090.   all of its subdirectories, and all of their subdirectories, etc, including
  9091.   their absolute pathnames.
  9092.  
  9093. SEND /RECURSIVE /PATHNAMES:OFF *
  9094.   Sends all of the files in the current directory and all the files in
  9095.   all of its subdirectories, and all of their subdirectories, etc, without
  9096.   pathnames.
  9097.  
  9098. SEND /RECURSIVE /usr/olga/*
  9099.   Sends all of the files in the /usr/olga directory and all the files in
  9100.   all of its subdirectories, and all of their subdirectories, etc.
  9101.  
  9102. SEND /RECURSIVE /usr/olga  (or /usr/olga/)
  9103.   Same as above.  If the name is a directory name (with or without a
  9104.   trailing slash), its files are sent, and those of its subdirectories,
  9105.   and their subdirectories, etc (see section 4.9).
  9106.  
  9107. SEND /RECURSIVE /TEXT /usr/olga/*.txt
  9108.   As above, but only files whose names end with ".txt" are sent, and they
  9109.   are sent in text mode (as they would be by default anyway if SET FILE
  9110.   PATTERNS is ON or AUTO).
  9111.  
  9112. SEND .
  9113.   UNIX only: Send all the files in the current directory.
  9114.  
  9115. SEND /RECURSIVE .
  9116.   UNIX only: Sends all of the files in the current directory and all of its
  9117.   subdirectories, etc (section 4.9).
  9118.  
  9119. The /RECURSIVE switch is different from most other switches in that its effect
  9120. is immediate (but still local to the command in which it is given), because it
  9121. determines how filenames are to be parsed.  For example, "send *.txt" fails
  9122. with a parse error ("No files match") if there are no *.txt files in the
  9123. current directory, but "send /recursive *.txt" succeeds if there are ".txt"
  9124. files anywhere in the tree rooted at the current directory.
  9125.  
  9126. The /RECURSIVE switch also affects the file lists displayed if you type "?"
  9127. in a filename field.  "send ./?" lists the regular files in the current
  9128. directory, but "send /recursive ./?" lists the entire directory tree rooted
  9129. at the current directory.
  9130.  
  9131. 4.11.3. The GET /RECURSIVE Command
  9132.  
  9133. In a client/server setting, the client can also request a recursive
  9134. transfer with:
  9135.  
  9136.   GET /RECURSIVE [ other switches ] <remote-filespec> [ <local-spec> ]
  9137.  
  9138. In which remote file specification can be a directory name, a filename, a
  9139. wildcard, or any combination.  If the <local-spec> is not given (and PATHNAMES
  9140. are RELATIVE), incoming files and directories go into the current local
  9141. directory.  If <local-spec> is given and is a directory, it becomes the root
  9142. of the tree into which the incoming files and directories are placed.  If
  9143. <local-spec> has the syntax of a directory name (e.g. in UNIX it ends with /),
  9144. C-Kermit creates the directory and then places the incoming files into it.
  9145. If <local-spec> is a filename (not recommended), then all incoming files are
  9146. stored with that name with collisions handled according to the FILE COLLISION
  9147. setting.
  9148.  
  9149. Again, the normal method for transferring directory trees uses relative
  9150. pathnames, and this is the default when the sender has been given the
  9151. /RECURSIVE switch.  The action at the receiver depends on its RECEIVE
  9152. PATHNAMES setting.  The default is AUTO, meaning that if the sender tells
  9153. it to expect a recursive transfer, then it should automatically switch to
  9154. relative pathnames for this transfer only; otherwise it obeys the RECEIVE
  9155. PATHNAMES setting of OFF, ABSOLUTE, or RELATIVE.
  9156.  
  9157. What happens if a file arrives that has an absolute pathname, when the
  9158. receiver has been told to use only relative pathnames?  As a security
  9159. precaution, in this case the receiver treats the name as if it was relative.
  9160. For example, if a file arrives as:
  9161.  
  9162.   /usr/olga/oofa.txt
  9163.  
  9164. The receiver creates a "usr" subdirectory in its current directory, and
  9165. then an "olga" subdirectory under the "usr" subdirectory in which to store
  9166. the incoming file.
  9167.  
  9168. Suppose, however there is a sequence of directories:
  9169.  
  9170.   /usr/olga/a/b/c/d/
  9171.  
  9172. in which "a" contains nothing but a subdirectory "b", which in turn contains
  9173. nothing but a subdirectory "c", which in turn contains nothing but a
  9174. subdirectory "d", which contains nothing at all.  Thus there are no files in
  9175. the "/usr/olga/a/" tree, and so it is not sent, and therefore it is not
  9176. reproduced on the target computer.
  9177.  
  9178. 4.11.4. New and Changed Functions
  9179.  
  9180. C-Kermit 7.0 adds the following functions:
  9181.  
  9182. \ffiles(pattern[,&a])
  9183.   This function has been changed to match only regular files in the current
  9184.   or given directory, and to take an optional array name as a second argument
  9185.   (explained below).
  9186.  
  9187. \fdirectories(pattern[,&a])
  9188.   Returns the number of directories that match the given pattern.
  9189.   If the pattern does not include a directory, then the search is performed
  9190.   in the current directory.
  9191.  
  9192. \frfiles(pattern[,&a])
  9193.   Returns the number of files in the current or given directory and all of
  9194.   its subdirectories, and their subdirectories, etc, that match the given
  9195.   pattern.  Warning -- this one can take quite some time if performed at the
  9196.   root of a large directory tree.
  9197.  
  9198. \frdirectories(pattern[,&a])
  9199.   Returns the number of directories in the current or given directory and all
  9200.   of its subdirectories, and their subdirectories, etc, that match the given
  9201.   pattern.
  9202.  
  9203. Each of these functions builds up a list of files to be returned by the
  9204. \fnextfile() function, just as \ffiles() always has done.  (This can also
  9205. be done with the /ARRAY switch of the DIRECTORY command; see Sections 4.5.1
  9206. and 7.10).
  9207.  
  9208. Each of these functions can be given an array name as an optional second
  9209. argument.  If an array name is supplied, the array will contain the number of
  9210. files as its 0th element, and the filenames in elements 1 through last.  If
  9211. the array already existed, its previous contents are lost.  For example, if
  9212. the current directory contains two files, oofa.txt and foo.bar, then
  9213. "\ffiles(*,&a)" creates an array \&a[] with a dimension of 2, containing the
  9214. following elements:
  9215.  
  9216.  \&a[0] = 2
  9217.  \&a[1] = oofa.txt
  9218.  \&a[2] = foo.bar
  9219.  
  9220. If no files match the specification given in the first argument, the array
  9221. gets a dimension of 0, which is the same as undeclaring the array.
  9222.  
  9223. Note that the order in which the array is filled (and in which \fnextfile()
  9224. returns filenames) is indeterminate (but see Section 7.10.5).
  9225.  
  9226. Here's an example that builds and prints a list of all the file whose names
  9227. end in .txt in the current directory and all its descendents:
  9228.  
  9229.   asg \%n \frfiles(*.txt)
  9230.   declare \&a[\%n]
  9231.   for \%i 1 \%n 1 {
  9232.       asg \&a[\%i] \fnextfile()
  9233.       echo \flpad(\%i,4). "\&a[\%i]"
  9234.   }
  9235.  
  9236. Alternatively, using the array method, and then printing the filenames in
  9237. alphabetic order (see Sections 7.10.3 and 7.10.5):
  9238.  
  9239.   asg \%n \frfiles(*.txt,&a)
  9240.   sort &a
  9241.   for \%i 1 \%n 1 {
  9242.       echo \flpad(\%i,4). "\&a[\%i]"
  9243.   }
  9244.  
  9245. Or even more simply:
  9246.  
  9247.   asg \%n \frfiles(*.txt,&a)
  9248.   sort &a
  9249.   show array &a
  9250.  
  9251. As noted elsewhere, the file lists built by \ffiles(), \frfiles(), etc, are
  9252. now "safe" in the sense that SEND and other file-related commands can
  9253. reference \fnextfile() without resetting the list:
  9254.  
  9255.   set send pathnames relative
  9256.   for \%i 1 \frfiles(*.txt) 1 {
  9257.       asg \%a \fnextfile()
  9258.       echo Sending \%a...
  9259.       send \%a
  9260.       if fail break
  9261.   }
  9262.  
  9263. Copying to an array (as shown on p.398 of "Using C-Kermit" 2nd Ed) is no
  9264. longer necessary.
  9265.  
  9266. 4.11.5. Moving Directory Trees Between Like Systems
  9267.  
  9268. 4.11.5.1. UNIX to UNIX
  9269.  
  9270. Transferring a directory tree from one computer to another replicates the file
  9271. sender's arrangement of files and directories on the file receiver's computer.
  9272. Normally this is done using relative pathnames, since the user IDs might not
  9273. be identical on the two computers.  Let's say both computers are UNIX based,
  9274. running C-Kermit 7.0 or later.  On the sending computer (leaving out the
  9275. connection details, etc):
  9276.  
  9277.   C-Kermit> cd /usr/olga
  9278.   C-Kermit> send /recursive .
  9279.  
  9280. The /RECURSIVE switch tells C-Kermit to descend through the directory tree
  9281. and to include relative pathnames on outbound filenames.
  9282.  
  9283. On the receiving computer:
  9284.  
  9285.   C-Kermit> mkdir olgas-files           ; Make a new directory.
  9286.   C-Kermit> cd olgas-files              ; CD to it.
  9287.   C-Kermit> receive /recursive          ; = /PATHNAMES:RELATIVE
  9288.  
  9289. Each Kermit program recognizes that the other is running under UNIX and
  9290. switches to binary mode and literal filenames automatically.  Directories
  9291. are automatically created on the receiving system as needed.  File dates
  9292. and permissions are automatically reproduced from source to destination.
  9293.  
  9294. 4.11.5.2. VMS to VMS
  9295.  
  9296. To send recursively from VMS, simply include the /RECURSIVE switch, for
  9297. example at the sender:
  9298.  
  9299.   $ kermit
  9300.   C-Kermit> cd [olga]
  9301.   C-Kermit> send /recursive *.*;0
  9302.  
  9303. And at the receiver:
  9304.  
  9305.   C-Kermit> cd [.olga]
  9306.   C-Kermit> receive /recursive
  9307.  
  9308. The notation "..." within directory brackets in VMS means "this directory
  9309. and all directories below it"; the /RECURSIVE switch, when given to the
  9310. sender, implies the use of "..." in the file specification so you don't have
  9311. to include "..."; but it makes no difference if you do:
  9312.  
  9313.   $ kermit
  9314.   C-Kermit> send /recursive [olga...]*.*;0
  9315.  
  9316. And at the receiver:
  9317.  
  9318.   C-Kermit> cd [.olga]
  9319.   C-Kermit> receive /recursive
  9320.  
  9321. In either case, since both systems recognize each other as VMS, they switch
  9322. into LABELED transfer mode automatically.
  9323.  
  9324. 4.11.6. Moving Directory Trees Between Unlike Systems
  9325.  
  9326. There are several difficulties with recursive transfers between unlike
  9327. systems:
  9328.  
  9329.  . File formats can be different, especially text files character sets and
  9330.    record formats.  This can now be handled by using SET FILE PATTERN,
  9331.    SET FILE TEXT-PATTERNS, and SET FILE BINARY-PATTERNS (Section 4.3).
  9332.  
  9333.  . File naming conventions are different.  For example, one system might allow
  9334.    (and use) longer filenames than the other.  You can tell Kermit how to
  9335.    handle file names with the normal "set file names" and "set file
  9336.    collision" mechanisms.  Most modern Kermits are fairly tolerant of illegal
  9337.    filenames and should not fail simply because of an incoming filename;
  9338.    rather, it will do its best to convert it to a recognizable and unique
  9339.    legal filename.
  9340.  
  9341.  . Directory notations can be different, e.g. backslashes instead of slashes,
  9342.    brackets, parentheses, spaces, etc.  But this is now handled by converting
  9343.    pathnames to a standard format during transfer (Section 4.10).
  9344.  
  9345. So now, for the first time, it is possible to send directory trees among
  9346. any combination of UNIX, DOS, Windows, OS/2, VMS, AOS/VS, etc.  Here's an
  9347. example sending files from an HP-UX system (where text files are encoded in
  9348. the HP Roman8 character set) to a PC with K95 (where text files are encoded
  9349. in CP850):
  9350.  
  9351.  Sender:
  9352.   cd xxx                           ; CD to root of source tree
  9353.   set file type binary             ; Default transfer mode
  9354.   set file character-set hp-roman8 ; Local character set for text files
  9355.   set xfer character-set latin1    ; Transfer character set
  9356.   set file patterns on             ; Enable automatic file-type switching...
  9357.   set file binary-patterns *.Z *.gz *.o  ; based on these patterns...
  9358.   set file text-patterns *.txt *.c *.h   ; for binary and text files.
  9359.   send /recursive *                ; Send all the file in this directory tree
  9360.  
  9361.  Receiver:
  9362.   cd yyy                           ; CD to root of destination tree
  9363.   set file character-set cp850     ; Local character set for text files
  9364.   receive /pathnames:relative      ; Receive with pathnames
  9365.  
  9366.  Notes:
  9367.  . Replace "xxx" and "yyy" with the desired directories.
  9368.  . Replace the file character sets appropriately.
  9369.  . Change the patterns as needed (or just use the built-in default lists).
  9370.  . SEND /RECURSIVE also implies /PATHNAMES:RELATIVE.
  9371.  . The file sender tells the file receiver the transfer mode of each file.
  9372.  . The file sender tells the file receiver the transfer character set.
  9373.  . By default, destination file dates will be the same as on the source.
  9374.  . Many of the settings shown might already be set by default.
  9375.  . See sections 4.3, 4.10, and 4.15 for additional explanation.
  9376.  
  9377. If you are refreshing an existing directory on the destination computer,
  9378. use "set file collision update" or other appropriate file collision option
  9379. to handle filename collisions.
  9380.  
  9381. 4.12. Where Did My File Go?
  9382.  
  9383. Now that Kermit can be started by clicking on desktop icons (thus obscuring
  9384. the concept of "current directory"), and can have a download directory, and
  9385. can create directories for incoming files on the fly, etc, sometimes it is
  9386. easy to lose a file after transfer.  Of course, if you keep a transaction log:
  9387.  
  9388.   LOG TRANSACTIONS
  9389.  
  9390. it will record the fate and final resting place of each file.  But in case
  9391. you did not keep a log, the new command:
  9392.  
  9393.   WHERE
  9394.  
  9395. added in C-Kermit 7.0, gives you as much information as it has about the
  9396. location of the last files transferred, including the pathname reported by
  9397. the receiving Kermit, if any, when C-Kermit is the sender.  This information
  9398. was also added to SHOW FILE in somewhat less detail.
  9399.  
  9400. 4.13. File Output Buffer Control
  9401.  
  9402. (UNIX only).  The new command SET FILE OUTPUT lets you control how incoming
  9403. files are written to disk:
  9404.  
  9405. SET FILE OUTPUT BUFFERED [ <size> ]
  9406.   Chooses buffered file output; this is the default.  UNIX does its normal
  9407.   sort of disk buffering.  The optional <size> specifies Kermit's own file
  9408.   output buffer size, and therefore the frequency of disk accesses (write()
  9409.   system calls) -- the bigger the size, the fewer the disk accesses.
  9410.  
  9411. SET FILE OUTPUT UNBUFFERED [ <size> ]
  9412.   This forces each file output write() call to actually commit the data to
  9413.   disk immediately.  Choosing this option will usually slow file reception
  9414.   down.
  9415.  
  9416. SET FILE OUTPUT BLOCKING
  9417.   Write() calls should not return until they are complete.  This is the normal
  9418.   setting, and it lets Kermit detect disk-write errors immediately.
  9419.  
  9420. SET FILE OUTPUT NONBLOCKING
  9421.   Write() calls should return immediately.  This can speed up file reception,
  9422.   but also delay the detection of disk-write errors.
  9423.  
  9424. Experimentation with these parameters should be harmless, and might (or might
  9425. not) have a perceptible, even dramatic, effect on performance.
  9426.  
  9427. 4.14. Improved Responsiveness
  9428.  
  9429. In version 7.0, C-Kermit's file-transfer protocol engine has been tuned
  9430. for additional speed and responsiveness.
  9431.  
  9432.  . Binary-mode transfers over 8-bit connections, a very common case, are
  9433.    now handled in a special way that minimizes overhead.
  9434.  
  9435.  . SET TRANSFER CRC-CALCULATION is now OFF by default, rather than ON.
  9436.    (This affects only the overall per-transfer CRC, \v(crc16), not the
  9437.    per-packet CRCs)
  9438.  
  9439.  . Connection loss during file transfer is now detected immediately in most
  9440.    cases on Internet connections and on serial connections when CARRIER-WATCH
  9441.    is not set to OFF.
  9442.  
  9443. 4.15. DOUBLING AND IGNORING CHARACTERS FOR TRANSPARENCY
  9444.  
  9445. The following commands were added in 7.0, primarily to allow successful
  9446. file transfer through ARPAnet TACs and with Honeywell DPS6 systems, but can
  9447. be used in any setting where they might be needed:
  9448.  
  9449. SET SEND DOUBLE-CHAR { [ <char> [ <char> [ ... ] ] ], NONE }
  9450.   Tells C-Kermit to double the specified characters (use decimal notation)
  9451.   in packets that it sends.  For example, if you are sending files through
  9452.   a device that uses @ as an escape character, but allows you to send a
  9453.   single copy of @ through by doubling it, use "set send double 64".
  9454.  
  9455. SET RECEIVE IGNORE-CHAR [ <char> [ <char> [ ... ] ] ]
  9456.   Tells C-Kermit to ignore the specified character(s) in incoming packets.
  9457.   Use this, for example, when something between the sender and receiver is
  9458.   inserting linefeeds for wrapping, NULs for padding, etc.
  9459.  
  9460. 4.16. New File-Transfer Display Formats
  9461.  
  9462. SET TRANSFER DISPLAY { BRIEF, CRT, FULLSCREEN, NONE, SERIAL }
  9463.  
  9464. BRIEF is the new one.  This writes one line to the screen per file, showing
  9465. the file's name, transfer mode, size, the status of the transfer, and when the
  9466. transfer is successful, the effective data rate in characters per second (CPS).
  9467. Example:
  9468.  
  9469.  SEND ckcfn3.o (binary) (59216 bytes): OK (0.104 sec, 570206 cps)
  9470.  SEND ckcfns.o (binary) (114436 bytes): OK (0.148 sec, 772006 cps)
  9471.  SEND ckcmai.c (text) (79147 bytes): OK (0.180 sec, 438543 cps)
  9472.  SEND ckcmai.o (binary) (35396 bytes): OK (0.060 sec, 587494 cps)
  9473.  SEND ckcnet.o (binary) (62772 bytes): REFUSED
  9474.  SEND ckcpro.o (binary) (121448 bytes): OK (0.173 sec, 703928 cps)
  9475.  SEND ckcpro.w (text) (63687 bytes): OK (0.141 sec, 453059 cps)
  9476.  SEND makefile (text) (186636 bytes): OK (0.444 sec, 420471 cps)
  9477.  SEND wermit (binary) (1064960 bytes): OK (2.207 sec, 482477 cps)
  9478.  
  9479. Note that transfer times are now obtained in fractional seconds, rather than
  9480. whole seconds, so the CPS figures are more accurate (the display shows 3
  9481. decimal places, but internally the figure is generally precise to the
  9482. microsecond).
  9483.  
  9484. 4.17. New Transaction Log Formats
  9485.  
  9486. The new command:
  9487.  
  9488.   SET TRANSACTION-LOG { VERBOSE, FTP, BRIEF [ <separator> ] }
  9489.  
  9490. lets you choose the format of the transaction log.  VERBOSE (the default)
  9491. indicates the traditional format described in the book.  BRIEF and FTP are
  9492. new.  This command must be given prior to the LOG TRANSACTION command if a
  9493. non-VERBOSE type is desired.
  9494.  
  9495. 4.17.1. The BRIEF Format
  9496.  
  9497. BRIEF chooses a one-line per file format suitable for direct importation into
  9498. databases like Informix, Oracle, or Sybase, in which:
  9499.  
  9500.  . Each record has 8 fields.
  9501.  . Fields are separated by a non-alphanumeric separator character.
  9502.  . The default separator character is comma (,).
  9503.  . Any field containing the separator character is enclosed in doublequotes.
  9504.  . The final field is enclosed in doublequotes.
  9505.  
  9506. The fields are:
  9507.  
  9508.   1. Date in yyyymmdd format
  9509.   2. Time in hh:mm:ss format
  9510.   3. Action: SEND or RECV
  9511.   4. The local filename
  9512.   5. The size of the file
  9513.   6. The transfer mode (text, binary, image, labeled)
  9514.   7. The status of the transfer: OK or FAILED
  9515.   8. Additional status-dependent info, in doublequotes.
  9516.  
  9517. Examples:
  9518.  
  9519.   20000208,12:08:52,RECV,/u/olga/oofa.txt,5246,text,OK,"0.284sec 18443cps"
  9520.   20000208,12:09:31,SEND,/u/olga/oofa.exe,32768,binary,OK,"1.243sec 26362cps"
  9521.   20000208,12:10:02,SEND,"/u/olga/a,b",10130,text,FAILED,"Refused: date"
  9522.  
  9523. Note how the filename is enclosed in doublequotes in the final example,
  9524. because it contains a comma.
  9525.  
  9526. To obtain BRIEF format, you must give the SET TRANSACTION-LOG BRIEF command
  9527. before the LOG TRANSACTIONS command.  (If you give them in the opposite order,
  9528. a heading is written to the log by the LOG command.)
  9529.  
  9530. 4.17.2. The FTP Format
  9531.  
  9532. SET TRANSACTION-LOG FTP (available only in UNIX) chooses a format that is
  9533. compatible with the WU-FTPD (Washington University FTP daemon) log, and so can
  9534. be processed by any software that processes the WU-FTPD log.  It logs only
  9535. transfers in and out, both successful and failed (but success or failure is
  9536. not indicated, due to lack of a field in the WU-FTPD log format for this
  9537. purpose).  Non-transfer events are not recorded.
  9538.  
  9539. Unlike other logs, the FTP-format transaction log is opened in append mode
  9540. by default.  This allows you to easily keep a record of all your kermit
  9541. transfers, and it also allows the same log to be shared by multiple
  9542. simultaneous Kermit processes or (permissions permitting) users.  You can, of
  9543. course, force creation of a new logfile by specifying the NEW keyword after
  9544. the filename, e.g.
  9545.  
  9546.   log transactions oofa.log new
  9547.  
  9548. All records in the FTP-style log are in a consistent format.  The first field
  9549. is fixed-length and contains spaces; subsequent fields are variable length,
  9550. contain no spaces, and are separated by one or more spaces.  The fields are:
  9551.  
  9552. Timestamp
  9553.   This is an asctime-style timestamp, example: "Wed Sep 16 20:19:05 1999"
  9554.   It is always exactly 24 characters long, and the subfields are always in
  9555.   fixed positions.
  9556.  
  9557. Elapsed time
  9558.   The whole number of seconds required to transfer the file, as a string
  9559.   of decimal digits, e.g. "24".
  9560.  
  9561. Connection
  9562.   The name of the network host to which C-Kermit is connected, or the name
  9563.   of the serial device through which it has dialed (or has a direct
  9564.   connection), or "/dev/tty" for transfers in remote mode.
  9565.  
  9566. Bytes transferred
  9567.   The number of bytes transferred, decimal digits, e.g. "1537904".
  9568.  
  9569. Filename
  9570.   The name of the file that was transferred, e.g.
  9571.   "/pub/ftp/kermit/a/README.TXT".  If the filename contains any spaces or
  9572.   control characters, each such character is replaced by an underscore ('_')
  9573.   character.
  9574.  
  9575. Mode
  9576.   The letter 'b' if the file was transferred in binary mode, or 'a'
  9577.   if it was transferred in text (ASCII) mode.
  9578.  
  9579. Options
  9580.   This field always contains an underscore ('_') character.
  9581.  
  9582. Direction
  9583.   The letter 'o' if the file was transferred Out, and 'i' if the file was
  9584.   transferred In.
  9585.  
  9586. User class
  9587.   The letter 'r' indicates the file was transferred by a Real user.
  9588.  
  9589. User identification
  9590.   The ID of the user who transferred the file.
  9591.  
  9592. Server identification
  9593.   The string "kermit".  This distinguishes a Kermit transfer log
  9594.   record from a WU-FTPD record, which contains "ftp" in this field.
  9595.  
  9596. Authentication class
  9597.   The digit '1' if we know the user's ID on the client system,
  9598.   otherwise '0'.  Currently, always '0'.
  9599.  
  9600. Authenticated user
  9601.   If the authentication class is '1', this is the user's ID on the client
  9602.   system.  Otherwise it is an asterisk ('*').  Currently it is always an
  9603.   asterisk.
  9604.  
  9605. Examples:
  9606.  
  9607.   Thu Oct 22 17:42:48 1998 0 * 94 /usr/olga/new.x a _ i r olga kermit 0 *
  9608.   Thu Oct 22 17:51:29 1998 1 * 147899 /usr/olga/test.c a _ o r olga kermit 0 *
  9609.   Thu Oct 22 17:51:44 1998 1 * 235 /usr/olga/test.o b _ i r olga kermit 0 *
  9610.   Fri Oct 23 12:10:25 1998 0 * 235 /usr/olga/x.ksc a _ o r olga kermit 0 *
  9611.  
  9612. Note that an ftp-format transaction log can also be selected on the Kermit
  9613. command line as follows:
  9614.  
  9615.   kermit --xferfile:<filespec>
  9616.  
  9617. This is equivalent to:
  9618.  
  9619.   SET TRANSACTION-LOG FTP
  9620.   LOG TRANSACTIONS <filespec> APPEND
  9621.  
  9622. Conceivably it could be possible to have a system-wide shared Kermit log,
  9623. except that UNIX lacks any notion of an append-only file; thus any user who
  9624. could append to the log could also delete it (or alter it).  This problem
  9625. could be worked around using setuid/setgid tricks, but these would most likely
  9626. interfere with the other setuid/setgid tricks C-Kermit must use for getting
  9627. at dialout devices and UUCP logfiles.
  9628.  
  9629. 4.18. Unprefixing NUL
  9630.  
  9631. As of 6.1.193 Alpha.10, C-Kermit can finally send and receive file-transfer
  9632. packets in which NUL (ASCII 0) is unprefixed (no more NUL-terminated
  9633. packets!).  NUL is, of course, extremely prevalent in binary files such as
  9634. executables, and this has been a significant source of packet overhead.  For
  9635. example, when transferring itself (the SunOS C-Kermit executable) with minimal
  9636. prefixing and 9000-byte packets, we see:
  9637.  
  9638.   File size:                       1064960
  9639.   Packet chars with 0 prefixed:    1199629  overhead = 12.65%
  9640.   Packet chars with 0 unprefixed:  1062393  overhead = -0.03%
  9641.  
  9642. Transfer rates go up accordingly, not only because of the reduced amount of
  9643. i/o, but also because less computation is required on each end.
  9644.  
  9645. 4.19. Clear-Channel Protocol
  9646.  
  9647. Now that C-Kermit itself is capable of sending and receiving any byte at all
  9648. on a clear channel (section 4.18), it is, for the first time, in a position to
  9649. negotiate a clear channel with the other Kermit, giving it permission (but not
  9650. requiring it) to unprefix any and all characters that it knows are safe.  In
  9651. general this means all but the Kermit start-of-packet character (normally
  9652. Ctrl-A), Carriage Return (not only Kermit's end-of-packet character, but also
  9653. treated specially on Telnet NVT links), and IAC (255, also special to Telnet).
  9654.  
  9655. By default, C-Kermit will say it has a clear channel only if it has opened a
  9656. TCP socket.  Since the Kermit program on the far end of a TCP/IP connection
  9657. generally does not know it has a TCP/IP connection, it will not announce a
  9658. clear channel unless it has been told to do so.  The command is:
  9659.  
  9660.   SET CLEAR-CHANNEL { ON, OFF, AUTO }
  9661.  
  9662. AUTO is the default, meaning that the clear-channel status is determined
  9663. automatically from the type of connection.  ON means to announce a clear
  9664. channel, OFF means not to announce it.  Use SHOW STREAMING (Section 4.20)
  9665. to see the current CLEAR-CHANNEL status.  Synonym: SET CLEARCHANNEL.
  9666.  
  9667. CLEAR-CHANNEL is also set if you start C-Kermit with the -I switch (see
  9668. Section 4.20).
  9669.  
  9670. Whenever a clear channel is negotiated, the resulting control-character
  9671. unprefixing is "sticky"; that is, it remains in effect after the transfer so
  9672. you can use SHOW CONTROL to see what was negotiated.
  9673.  
  9674. You can also see whether a clear channel was negotiated in the STATISTICS
  9675. /VERBOSE Display.
  9676.  
  9677. The advantage of the clear channel feature is that it can make file transfers
  9678. go faster automatically.  The disadvantage would be file-transfer failures if
  9679. the channel is not truly clear, for example if C-Kermit made a Telnet
  9680. connection to a terminal server, and then dialed out from there; or if
  9681. C-Kermit made an Rlogin connection to host and then made a Telnet connection
  9682. from there to another host.  If a file transfer fails on a TCP/IP connection,
  9683. use SHOW CONTROL to check whether control characters became unprefixed as a
  9684. result of protocol negotiations, and/or SHOW STREAMING (Section 4.20) to see
  9685. if "clear-channel" was negotiated.  If this happened, use SET CLEAR-CHANNEL
  9686. OFF and SET PREFIXING CAUTIOUS (or whatever) to prevent it from happening
  9687. again.
  9688.  
  9689. 4.20. Streaming Protocol
  9690.  
  9691. A new Kermit protocol option called "streaming" was added in C-Kermit 7.0.
  9692. The idea is that if the two Kermit partners have a reliable transport (such as
  9693. TCP/IP or X.25) between them, then there is no need to send ACKs for Data
  9694. packets, or NAKs, since a reliable transport will, by definition, deliver all
  9695. packets in order and undamaged.  On such a connection, streaming cuts down not
  9696. only on Kermit program overhead (switching back and forth between reading and
  9697. sending packets), but also tends to make the underlying transport use itself
  9698. more efficiently (e.g. by defeating the Nagle algorithm and/or Delayed ACK
  9699. stratagem of the TCP layer).  Furthermore, it allows transfers to work
  9700. smoothly on extremely slow network congestions that would otherwise cause
  9701. timeouts and retransmissions, and even failure when the retry limit was
  9702. exceeded.
  9703.  
  9704. The trick is knowing when we can stream:
  9705.  
  9706.  a. If C-Kermit has opened a TCP socket or X.25 connection, it offers stream.
  9707.  
  9708.  b. If C-Kermit has been started with the -I (uppercase) option, or if it
  9709.     has been told to SET RELIABLE ON, it offers to stream.
  9710.  
  9711.  c. If C-Kermit is in remote mode, and has been told to SET RELIABLE AUTO
  9712.     (or ON), it always offers to stream, and also always agrees to stream,
  9713.     if the other Kermit offers.  Unless you take explicit actions to override
  9714.     the defaults, this allows the local Kermit (the one that made the
  9715.     connection, and so knows whether it's reliable) to control streaming.
  9716.  
  9717. (Note that an offer to stream also results in a Clear-Channel announcement if
  9718. CLEAR-CHANNEL is set to AUTO; see Section 4.19.)
  9719.  
  9720. When BOTH Kermits offer to stream, then they stream; otherwise they don't.
  9721. Thus streaming-capable Kermit programs interoperate automatically and
  9722. transparently with nonstreaming ones.  If the two Kermits do agree to stream,
  9723. you'll see the word "STREAMING" on the fullscreen file-transfer display in the
  9724. Window Slots field.  You can also find out afterwards with the STATISTICS or
  9725. SHOW STREAMING commands.
  9726.  
  9727.   WARNING: Automatic choice of streaming is based on the assumption of a
  9728.   "direct" end-to-end network connection; for example, a Telnet or Rlogin
  9729.   connection from host A to host B, and transferring files between A and
  9730.   B.  However, if your connection has additional components -- something
  9731.   "in the middle" (B) that you have made a network connection to, which
  9732.   makes a separate connection to the destination host (C), then you don't
  9733.   really have a reliable connection, but C-Kermit has no way of knowing
  9734.   this; transferring files between A and C will probably fail.  In such
  9735.   cases, you'll need to tell the *local* C-Kermit to "set reliable off"
  9736.   before transferring files (it does no good to give this command to the
  9737.   remote Kermit since the local one controls the RELIABLE setting).
  9738.  
  9739. Streaming is like using an infinite window size, with no timeouts and no
  9740. tolerance for transmission errors (since there shouldn't be any).  It relies
  9741. on the underlying transport for flow control, error correction, timeouts, and
  9742. retransmission.  Thus it is very suitable for use on TCP/IP connections,
  9743. especially slow or bursty ones, since Kermit's packet timeouts won't interfere
  9744. with the transfer -- each packet takes as long to reach its destination as it
  9745. takes TCP to deliver it.  If TCP can't deliver the packet within its own
  9746. timeout period (over which Kermit has no control), it signals a fatal error.
  9747. Just like FTP.
  9748.  
  9749. Streaming goes much faster than non-streaming when a relatively small packet
  9750. length is used, and it tends to go faster than non-streaming with even the
  9751. longest packet lengths.  The Kermit window size is irrelevant to streaming
  9752. protocol, but still might affect performance in small ways since it can result
  9753. in different paths through the code.
  9754.  
  9755. The definition of "reliable transport" does not necessarily demand 8-bit and
  9756. control-character transparency.  Streaming can work with parity and/or
  9757. control-character prefixing just as well (but not as fast) as without them;
  9758. in such cases you can leave RELIABLE set to ON, but set CLEARCHANNEL and/or
  9759. PARITY appropriately.
  9760.  
  9761. Maximum performance -- comparable to and often exceeding FTP -- is achieved on
  9762. socket-to-socket connections (in which the considerable overhead of the
  9763. terminal driver and Telnet or Rlogin server is eliminated) with long packets
  9764. and the new "brief" file-transfer display (Section 4.16).
  9765.  
  9766. 4.20.1. Commands for Streaming
  9767.  
  9768. SET RELIABLE { ON, OFF, AUTO }
  9769.   SET RELIABLE ON tells Kermit that it has a reliable transport.
  9770.   SET RELIABLE OFF tells Kermit the transport is not reliable.
  9771.   SET RELIABLE AUTO tells Kermit that it should SET RELIABLE ON whenever
  9772.   it makes a reliable connection (e.g. TELNET or SET HOST on a TCP/IP or
  9773.   X.25 network), and when in remote mode it should believe the transport is
  9774.   reliable if the other Kermit says it is during Kermit protocol negotiation.
  9775.  
  9776. AUTO is the default; the Kermit program that makes the connection knows
  9777. whether it is reliable, and tells the remote Kermit.
  9778.  
  9779. The RELIABLE setting has several effects, including:
  9780.  
  9781.  . It can affect the timeouts used during normal ACK/NAK protocol.
  9782.  . It can affect the clear-channel announcement.
  9783.  . It can affect streaming.
  9784.  
  9785. If you TELNET or SET HOST somewhere, this includes an implicit SET RELIABLE ON
  9786. command.  The -I command-line option is equivalent to SET RELIABLE ON.
  9787.  
  9788. Since SET RELIABLE ON (and -I) also implies SET CLEAR CHANNEL ON, you might
  9789. find that in certain cases you need to tell Kermit that even though the
  9790. connection is reliable, it doesn't have a clear channel after all:
  9791.  
  9792.   SET CLEAR-CHANNEL OFF
  9793.   SET PREFIXING CAUTIOUS ; or whatever...
  9794.  
  9795. You can control streaming without affecting the other items with:
  9796.  
  9797.   SET STREAMING { ON, OFF, AUTO }
  9798.  
  9799. AUTO is the default, meaning streaming will occur if Kermit has made a TCP/IP
  9800. connection or if RELIABLE is ON (or it was started with the -I command line
  9801. option).  OFF means don't stream; ON means offer to stream no matter what.
  9802.  
  9803. 4.20.2. Examples of Streaming
  9804.  
  9805. Here we look at the use and behavior of streaming on several different kinds
  9806. of connections, and compare its performance with non-streaming transfers.
  9807.  
  9808. 4.20.2.1. Streaming on Socket-to-Socket Connections
  9809.  
  9810. Here we get streaming automatically when both Kermit programs are capable of
  9811. it, since they both make socket connections.  For example, on the far end:
  9812.  
  9813.   C-Kermit> set host * 3000
  9814.   C-Kermit> server
  9815.  
  9816. and on the near end:
  9817.  
  9818.   C-Kermit> set host foo.bar.xyz.com 3000
  9819.   (now give SEND and GET command)
  9820.  
  9821. All subsequent file transfers use streaming automatically.
  9822.  
  9823. Here are the results from 84 trials, run on a production network,
  9824. disk-to-disk, in which a 1-MB binary file (the SunOS C-Kermit Sparc
  9825. executable) was sent from a Sun Sparc-10 with SunOS 4.1.3 to an IBM Power
  9826. Server 850 with AIX 4.1, socket-to-socket, over a 10Mbps 10BaseT Ethernet,
  9827. using minimal control-character unprefixing, window sizes from 10 to 32, and
  9828. packet sizes from 1450 to 9010:
  9829.  
  9830.                 Streaming    Nonstreaming
  9831.   Max CPS         748955        683354
  9832.   Min CPS         221522        172491
  9833.   Mean CPS        646134        558680
  9834.   Median CPS      678043        595874
  9835.   Std Dev         101424        111493
  9836.  
  9837. Correlations:
  9838.  
  9839.   CPS and window size:   -0.036
  9840.   CPS and packet length:  0.254
  9841.   CPS and streaming:      0.382
  9842.  
  9843. Note that the relationship between streaming and throughput is significantly
  9844. stronger than that between CPS and window size or packet length.
  9845.  
  9846. Also note that this and all other performance measurements in this section
  9847. are snapshots in time; the results could be much different at other times when
  9848. the load on the systems and/or the network is higher or lower.
  9849.  
  9850. In a similar socket-to-socket trial, but this time over a wide-area TCP/IP
  9851. connection (from New York City to Logan, Utah, about 2000 miles), the
  9852. following results were obtained:
  9853.  
  9854.                 Streaming    Nonstreaming
  9855.   Max CPS         338226        318203
  9856.   Min CPS         191659        132314
  9857.   Mean CPS        293744        259240
  9858.   Median CPS      300845        273271
  9859.   Std Dev          41914         52351
  9860.  
  9861. Correlations:
  9862.  
  9863.   CPS and window size:    0.164
  9864.   CPS and packet length:  0.123
  9865.   CPS and streaming:      0.346
  9866.  
  9867. 4.20.2.2. Streaming on Telnet Connections
  9868.  
  9869. In this case the local copy of Kermit is told to TELNET or SET HOST, and so it
  9870. knows it has a reliable connection and -- unless it has been told not to --
  9871. will offer to stream, and the other Kermit program, since it has STREAMING set
  9872. to AUTO, agrees.
  9873.  
  9874. Since we have a reliable connection, we'll also get control-character
  9875. unprefixing automatically because of the new clear-channel protocol (Section
  9876. 4.19).
  9877.  
  9878. Any errors that occur during streaming are fatal to the transfer.  The
  9879. message is "Transmission error on reliable link".  Should this happen:
  9880.  
  9881.  a. Check the remote Kermit's flow control setting (SHOW COMMUNICATIONS).
  9882.     If it is NONE, change it to XON/XOFF, or vice versa.  If it is XON/XOFF
  9883.     (or you just changed it to XOFF/XOFF), make sure the file sender is
  9884.     prefixing the XON and XOFF characters.  In the most drastic case, use
  9885.     "set prefix all" to force prefixing of all control characters.
  9886.  
  9887.  b. The remote Telnet server might chop off the 8th bit.  In that case, tell
  9888.     C-Kermit to "set parity space".  Or, you might be able to force the
  9889.     Telnet to allow eight-bit data by telling C-Kermit to "set telopt binary
  9890.     request accept" -- that is, request the Telnet server to enter binary
  9891.     mode, and accept binary-mode bids from the server.
  9892.  
  9893.  c. The remote Telnet server might have a buffering limitation.  If a and b
  9894.     dont' cure the problem, tell the file receiver to "set receive
  9895.     packet-length 1000" (or other number -- use the largest one that works).
  9896.     This too, is no different from the non-streaming case (more about this
  9897.     in Section 4.20.2.3).
  9898.  
  9899. And remember you can continue interrepted binary-mode transfers where they
  9900. left off with the RESEND (= SEND /RECOVER) command.
  9901.  
  9902. Here are the figures for the same 84 trials between the same Sun and IBM
  9903. hosts as in 4.20.2.1, on the same network, but over a Telnet connection rather
  9904. than socket-to-socket:
  9905.  
  9906.                   Streaming    Nonstreaming
  9907.   Max CPS         350088        322523
  9908.   Min CPS          95547        173152
  9909.   Mean CPS        321372        281830
  9910.   Median CPS      342604        291469
  9911.   Std Dev          40503         29948
  9912.  
  9913. Correlations:
  9914.  
  9915.   CPS and window size:    0.001
  9916.   CPS and packet length:  0.152
  9917.   CPS and streaming:      0.128
  9918.  
  9919. Here the effect is not as emphatic as in the socket-to-socket case, yet on
  9920. the whole streaming tends to be beneficial.
  9921.  
  9922. Additional measurements on HP-UX using C-Kermit 7.0 Beta.06:
  9923.  
  9924.                   Windowing     Streaming
  9925.   HP-UX 8->8      not tested       14Kcps
  9926.   HP-UX 8->9      not tested       76Kcps
  9927.   HP-UX 8->10      36Kcps          66Kcps
  9928.   HP-UX 9->9      not tested      190Kcps
  9929.   HP-UX 9->10     160Kcps         378Kcps
  9930.  
  9931. 4.20.2.3. Streaming with Limited Packet Length
  9932.  
  9933. The IRIX telnet server (at least the ones observed in IRIX 5.3 and 6.2) does
  9934. not allow Kermit to send packets longer than 4096 bytes.  Thus when sending
  9935. from IRIX C-Kermit when it is on the remote end of a Telnet connection, the
  9936. packet length must be 4K or less.  Trials in this case (in which packet
  9937. lengths range from 1450 to 4000) show a strong advantage for streaming, which
  9938. would be evident in any other case where the packet length is restricted, and
  9939. stronger the shorter the maximum packet length.
  9940.  
  9941.                   Streaming    Nonstreaming
  9942.   Max CPS         426187        366870
  9943.   Min CPS         407500        276517
  9944.   Mean CPS        415226        339168
  9945.   Median CPS      414139        343803
  9946.   Std Dev           6094         25851
  9947.  
  9948. Correlations:
  9949.  
  9950.   CPS and window size:    0.116
  9951.   CPS and packet length:  0.241
  9952.   CPS and streaming:      0.901
  9953.  
  9954. 4.20.2.4. Streaming on Dialup Connections
  9955.  
  9956. Here "dialup" refers to a "direct" dialup connection, not a SLIP or PPP
  9957. connection, which is only a particular kind of TCP/IP connection.
  9958.  
  9959. Attempt this at your own risk, and then only if (a) you have error-correcting
  9960. modems, and (b) the connections between the modems and computers are also
  9961. error-free, perfectly flow-controlled, and free of interrupt conflicts.
  9962. Streaming can be used effectively and to fairly good advantage on such
  9963. connections, but remember that the transfer is fatal if even one error is
  9964. detected (also remember that should a binary-mode transfer fail, it can be
  9965. recovered from the point of failure with RESEND).
  9966.  
  9967. To use streaming on an unreliable connection, you must tell both Kermits that
  9968. the connection is reliable:
  9969.  
  9970.   kermit -I
  9971.  
  9972. or:
  9973.  
  9974.   C-Kermit> set reliable on
  9975.  
  9976. In this case, it will probably be necessary to prefix some control characters,
  9977. for example if your connection is through a terminal server that has an escape
  9978. character.  Most Cisco terminal servers, for example, require Ctrl-^ (30, as
  9979. well as its high-bit equivalent, 158) to be prefixed.  To unprefix these,
  9980. you'll need to defeat the "clear channel" feature:
  9981.  
  9982.   C-Kermit> set reliable on
  9983.   C-Kermit> set clear-channel off
  9984.   C-Kermit> set prefixing none
  9985.   C-Kermit> set control prefix 1 13 30 158 ; and whatever else is necessary
  9986.  
  9987. Dialup trials were done using fixed large window and packet sizes.  They
  9988. compare uploading and downloading of two common types of files, with and
  9989. without streaming.  Configuration:
  9990.  
  9991.   HP-9000/715/33 -- 57600bps, RTS/CTS -- USR Courier V.34 -- V.34+V.42,
  9992.   31200bps -- USR V.34+ Rackmount -- 57600bps, RTS/CTS -- Cisco terminal
  9993.   server -- Solaris 2.5.1.  Packet size = 8000, Window Size = 30, Control
  9994.   Character Unprefixing Minimal (but including the Cisco escape character).
  9995.  
  9996. Since this is not a truly reliable connection, a few trials failed when a bad
  9997. packet was received (most likely due to UART overruns); the failure was
  9998. graceful and immediate, and the message was informative.  The results of ten
  9999. successful trials uploading and downloading the two files with and without
  10000. streaming are:
  10001.  
  10002.             Streaming..
  10003.             Off    On
  10004.    Upload   5194   5565   txt (= C source code, 78K)
  10005.             3135   3406   gz  (= gzip file, compressed, 85K)
  10006.  Download   5194   5565   txt
  10007.             3041   3406   gz
  10008.  
  10009. Each CPS figure is the mean of 10 results.
  10010.  
  10011. A brief test was also performed on a LAT-based dialout connection from a VAX
  10012. 3100 with VMS 5.5 to a USR Courier V.34 connected to a DECserver 700 at 19200
  10013. bps.  The 1-MB Sparc executable downloaded from a Sun to the VAX at 1100cps
  10014. without streaming and 1900cps with streaming, using 8000-byte packets, 30
  10015. window slots, and minimal prefixing in both cases.
  10016.  
  10017. 4.20.2.5. Streaming on X.25 Connections
  10018.  
  10019. We have only limited access to X.25 networks.  One trial was performed in
  10020. which the 1MB Solaris 2.4 Sparc executable was transferred over a SunLink X.25
  10021. connection; nothing is known about the actual physical connection.  With a
  10022. packet length of 8000 and a window size of 30, the file transferred at 6400
  10023. cps (using a maximum of 6 window slots).  With the same packet length, but
  10024. with streaming, it transferred without mishap at 6710 cps, about 5% faster.
  10025.  
  10026. 4.20.3. Streaming - Preliminary Conclusions
  10027.  
  10028. The results vary with the particular connection, but are good overall.
  10029. Although numerous lower-level tricks can be used to improve performance on
  10030. specific platforms or connection methods, streaming occurs at a high,
  10031. system-independent level of the Kermit protocol and therefore can apply to all
  10032. types of platforms and (reliable) connections transparently.
  10033.  
  10034. 4.21. The TRANSMIT Command
  10035.  
  10036. Prior to C-Kermit 7.0, the TRANSMIT command transmitted in text or binary
  10037. mode according to SET FILE TYPE { TEXT, BINARY }.  But now that binary mode
  10038. is likely to be the default for protocol transfers, it is evident that this
  10039. not also an appropriate default for TRANSMIT, since binary-mode TRANSMIT is
  10040. a rather specialized and tricky operation.  Therefore, TRANSMIT defaults to
  10041. text mode always, regardless of the FILE TYPE setting.
  10042.  
  10043. C-Kermit 7.0 expands the capabilities of the TRANSMIT command by adding the
  10044. following switches (see Section 1.5).  The new syntax is:
  10045.  
  10046.   TRANSMIT [ switches... ] filename
  10047.  
  10048. Zero or more switches may be included:
  10049.  
  10050. /PIPE
  10051.   When /PIPE is included, "filename" is interpreted as a system command
  10052.   or program whose output is to be sent.  Synonym: /COMMAND.  Example:
  10053.  
  10054.     transmit /pipe finger
  10055.  
  10056.   You may enclose the command in braces, but you don't have to:
  10057.  
  10058.     xmit /pipe {ls -l | sort -r +0.22 -0.32 | head}
  10059.  
  10060. /BINARY
  10061.   Transmits the file (or pipe output) in binary mode.
  10062.  
  10063. /TEXT
  10064.   Transmits the file (or pipe output) in line-oriented text mode.
  10065.   Current FILE CHARACTER-SET and TERMINAL CHARACTER-SET selections govern
  10066.   translation.  Default.
  10067.  
  10068. /TRANSPARENT
  10069.   Specifies text mode without character-set translation, no matter what the
  10070.   FILE and TERMINAL CHARACTER-SET selections are.
  10071.  
  10072. /NOWAIT
  10073.   This is equivalent to SET TRANSMIT PROMPT 0, but for this TRANSMIT command
  10074.   only.  Applies only to text mode; it means to not wait for any kind of
  10075.   echo or turnaround character after sending a line before sending the next
  10076.   line.  (Normally Kermit waits for a linefeed.)
  10077.  
  10078. When TRANSMIT ECHO is ON, C-Kermit tries to read back the echo of each
  10079. character that is sent.  Prior to C-Kermit 7.0, 1 second was allowed for each
  10080. echo to appear; if it didn't show up in a second, the TRANSMIT command would
  10081. fail.  Similarly for the TRANSMIT PROMPT character.  However, with today's
  10082. congested Internet connections, etc, more time is often needed:
  10083.  
  10084. SET TRANSMIT TIMEOUT <number>
  10085.   Specifies the number of seconds to wait for an echo or the prompt character
  10086.   when TRANSMIT PROMPT is nonzero; the default wait is 1 second.  If you
  10087.   specify 0, the wait is indefinite.  When a timeout interval of 0 is
  10088.   specified, and a desired echo or prompt does not show up, the TRANSMIT
  10089.   command will not terminate until or unless you interrupt it with Ctrl-C;
  10090.   use SET TRANSMIT TIMEOUT 0 with caution.
  10091.  
  10092. Note: to blast a file out the communications connection without any kind of
  10093. synchronization or timeouts or other manner of checking, use:
  10094.  
  10095.   SET TRANSMIT ECHO OFF
  10096.   SET TRANSMIT PROMPT 0 (or include the /NOWAIT switch)
  10097.   SET TRANSMIT PAUSE 0
  10098.   TRANSMIT [ switches ] <filename>
  10099.  
  10100. In this case, text-file transmission is not-line oriented and large blocks
  10101. can be sent, resulting in a significant performance improvement over
  10102. line-at-at-time transmission.  Successful operation depends (even more than
  10103. usual for the TRANSMIT command!) on a clean connection with effective flow
  10104. control.
  10105.  
  10106. For details on TRANSMIT and character sets, see Section 6.6.5.4.
  10107.  
  10108. 4.22. Coping with Faulty Kermit Implementations
  10109.  
  10110. Kermit protocol has been implemented in quite a few third-party commercial,
  10111. shareware, and freeware software packages, with varying degrees of success.
  10112. In most cases operation is satisfactory but slow -- only the bare minimum
  10113. subset of the protocol is available -- short packets, no sliding windows,
  10114. no attributes, etc.  In other cases, the implementation is incorrect,
  10115. resulting in failures at the initial negotiation stage or corrupted files.
  10116.  
  10117. C-Kermit 7.0 and Kermit 95 1.1.18 include some new defense mechanisms to
  10118. help cope with the most common situations.  However, bear in mind there is
  10119. only so much we can do in such cases -- the responsibility for fixing the
  10120. problem lies with the maker of the faulty software.
  10121.  
  10122. 4.22.1. Failure to Accept Modern Negotiation Strings
  10123.  
  10124. The published Kermit protocol specification states that new fields can be
  10125. added to the parameter negotiation string.  These are to be ignored by any
  10126. Kermit implementation that does not understand them; this is what makes the
  10127. Kermit protocol extensible.  Unfortunately, some Kermit implementations become
  10128. confused (or worse) when receiving a negotiation string longer than the one
  10129. they expect.  You can try working around such problems by telling Kermit to
  10130. shorten its negotiation string (and thus disable the corresponding new
  10131. features):
  10132.  
  10133.   SET SEND NEGOTIATION-STRING-MAX-LENGTH number
  10134.  
  10135. Try a number like 10.  If that doesn't work, try 9, 8, 7, 6, and so on.
  10136.  
  10137. 4.22.2. Failure to Negotiate 8th-bit Prefixing
  10138.  
  10139. The published Kermit protocol specification states that 8th-bit prefixing
  10140. (which allows transfer of 8-bit data over a 7-bit connection) occurs if the
  10141. file sender puts a valid prefix character (normally "&") in the 8th-bit-prefix
  10142. field of the negotiation string, and the receiver puts either a letter "Y" or
  10143. the same prefix character.  At least one faulty Kermit implementation exists
  10144. that does not accept the letter "Y".  To force C-Kermit / K-95 to reply with
  10145. the other Kermit's prefix character rather than a "Y", give the following
  10146. (invisible) command:
  10147.  
  10148.   SET Q8FLAG ON
  10149.  
  10150. Use SET Q8FLAG OFF to restore the normal behavior.
  10151.  
  10152. 4.22.3. Corrupt Files
  10153.  
  10154. Refer to Section 4.22.2.  Some Kermit implementations mistakenly interpret the
  10155. "Y" as a prefix character.  Then, whenever a letter Y appears in the data, the
  10156. Y and the character that follows it are replaced by a garbage character.  At
  10157. this writing, we are not sure if there is any solution, but try "set send
  10158. negotiation-string-max-length 6" and/or "set q8flag on".
  10159.  
  10160. File corruption can also occur when control characters within the file data
  10161. are sent without prefixing, as at least some are by default in C-Kermit 7.0
  10162. and K-95.  Some Kermit implementations do not handle incoming "bare" control
  10163. characters.  To work around, "set prefixing all".
  10164.  
  10165. 4.22.4. Spurious Cancellations
  10166.  
  10167. The Kermit protocol specification states that if an ACK to a Data packet
  10168. contains X in its data field, the transfer of the current file is canceled,
  10169. and if it contains a Z, the entire transfer is canceled.  At least one
  10170. overzealous Kermit implementation applies this rule to non-Data packets as
  10171. well, the typical symptom being that any attempt to transfer a file whose name
  10172. begins with X or Z results in cancellation.  This is because the file receiver
  10173. typically sends back the name under which it stored the file (which might not
  10174. be the same as the name it was sent with) in the ACK to the File Header
  10175. packet.  This is information only and should not cause cancellation.  To work
  10176. around the problem, use:
  10177.  
  10178.   SET F-ACK-BUG { ON, OFF }
  10179.  
  10180. ON tells Kermit not to send back the filename in the ACK to the file header
  10181. packet as it normally would do (OFF puts Kermit back to normal after using ON).
  10182.  
  10183. A variation on the this bug occurs in an obscure Kermit program for MUMPS:
  10184. When this Kermit program sends a file called (say) FOO.BAR, it requires that
  10185. the ACK to its F packet contain exactly the same name, FOO.BAR.  However,
  10186. C-Kermit likes to send back the full pathname, causing the MUMPS Kermit to
  10187. fail.  SET F-ACK-BUG ON doesn't help here.  So a separate command has been
  10188. added to handle this situation:
  10189.  
  10190.   SET F-ACK-PATH { ON, OFF }
  10191.  
  10192. Normally it is ON (regardless of the SET SEND PATHNAMES setting).  Use
  10193. SET F-ACK-PATH OFF to instruct Kermit to send back only the filename without
  10194. the path in the ACK to the F packet.
  10195.  
  10196. 4.22.5. Spurious Refusals
  10197.  
  10198. Some Kermit implementations, notably PDP-11 Kermit 3.60 and earlier, have bugs
  10199. in their handling of Attribute packets that can cause unwarranted refusal of
  10200. incoming files, e.g. based on date or size.  This can be worked around by
  10201. telling one or both of the Kermit partners to:
  10202.  
  10203.   SET ATTRIBUTES OFF
  10204.  
  10205. 4.22.6. Failures during the Data Transfer Phase
  10206.  
  10207. This can be caused by control-character unprefixing (Section 4.22.3), and
  10208. fixed by:
  10209.  
  10210.   SET PREFIXING ALL
  10211.  
  10212. It can also have numerous other causes, explained in Chapter 10 of "Using
  10213. C-Kermit": the connection is not 8-bit transparent (so use "set parity space"
  10214. or somesuch), inadequate flow control, etc.  Consult the manual.
  10215.  
  10216. 4.22.7. Fractured Filenames
  10217.  
  10218. At least one well-known PC-based communications package negotiates data
  10219. compression, which (according to the protocol specification) applies to both
  10220. the filename and the file data, but then fails to decompress the filename.
  10221. Example: C-Kermit sends a file called R000101.DAT (where 000101 might be
  10222. non-Y2K-wise YYMMDD notation), and the package in question stores the files
  10223. as R~#0101.DAT.  Workaround: Tell C-Kermit to SET REPEAT COUNTS OFF.
  10224.  
  10225. 4.22.8. Bad File Dates
  10226.  
  10227. At least one well-known PC-based communications package negotiates the
  10228. passing of file timestamps from sender to receiver, but when it is sending
  10229. files, it always gives them a timestamp of 1 February 1970.  Workaround:
  10230. tell C-Kermit to SET ATTRIBUTE DATE OFF.  You don't get the file's real date,
  10231. but you also don't get 1 Feb 1970; instead the file gets the current date
  10232. and time.
  10233.  
  10234. 4.23. File Transfer Recovery
  10235.  
  10236. Prior to C-Kermit 7.0, RESEND (SEND /RECOVER) and REGET (GET /RECOVER) refused
  10237. to work if FILE TYPE was not BINARY or the /BINARY switch was not included.
  10238. Now these commands include an implied /BINARY switch, meaning they set the
  10239. file type to binary for the duration of the command automatically.
  10240.  
  10241. In the client/server arrangement, this also forces the server into binary
  10242. mode (if it is C-Kermit 7.0 or greater, or K95 1.1.18 or greater) so the
  10243. recovery operation proceeds, just as you asked and expected.
  10244.  
  10245. BUT...  Just as before, the results are correct only under the following
  10246. conditions:
  10247.  
  10248.  . If the prior interrupted transfer was also in binary mode; or:
  10249.  
  10250.  . If the prior transfer was in text mode and the other computer was
  10251.    a "like platform" (e.g. UNIX-to-UNIX, Windows-to-Windows, DOS-to-Windows)
  10252.    AND there was no character-set translation (i.e. TRANSFER CHARACTER-SET
  10253.    was TRANSPARENT).
  10254.  
  10255. Note that these circumstances are more likely to obtain in C-Kermit 7.0,
  10256. in which:
  10257.  
  10258.  . The default FILE TYPE in C-Kermit 7.0 is BINARY.
  10259.  
  10260.  . The default FILE INCOMPLETE setting is AUTO, which means KEEP if the
  10261.    transfer is in binary mode, DISCARD otherwise.
  10262.  
  10263.  . C-Kermit 7.0, Kermit 95 1.1.17, and MS-DOS Kermit 3.15 and later can
  10264.    recognize "like platforms" and switch into binary mode automatically.
  10265.    Transfers between like platforms are always binary unless character-set
  10266.    translation has been requested, and then is still binary for all files
  10267.    whose names match a binary pattern, unless the automatic mechanisms
  10268.    have been disabled (with a /TEXT switch, or with SET TRANSFER MODE
  10269.    MANUAL).
  10270.  
  10271.  . SEND /BINARY and GET /BINARY always force binary-mode transfers,
  10272.    even when FILE TYPE is TEXT, even when TRANSFER MODE is AUTOMATIC,
  10273.    even when PATTERNS are ON and the file's name matches a text pattern.
  10274.  
  10275. But also note that the automatic client/server transfer-mode adjustments
  10276. do not work with versions of C-Kermit prior to 7.0 or K95 prior to 1.1.16.
  10277.  
  10278. If the prior transfer was in text mode:
  10279.  
  10280.  . If text-mode transfers between the two platforms are "length-changing"
  10281.    (as they are between UNIX -- which terminates text lines with LF -- and
  10282.    DOS or Windows -- which terminates text lines with CRLF), the recovered
  10283.    file will be corrupt.
  10284.  
  10285.  . If text-mode transfers between the two platforms are not length-changing,
  10286.    but character-set translation was active in the prior transfer, the result
  10287.    will be a file in which the first part has translated characters and the
  10288.    second part does not.
  10289.  
  10290. But in C-Kermit 7.0 and K95 1.1.18 and later, incompletely transferred text
  10291. files are not kept unless you change the default.  But if you have done this,
  10292. and you have an incompletely transferred text file, you'll need to:
  10293.  
  10294.  . Transfer the whole file again in text mode, or:
  10295.  
  10296.  . Use SEND /STARTING-AT: to recover the transfer at the correct point;
  10297.    but you have to find out what that point is, as described in the
  10298.    manual.
  10299.  
  10300. Kermit has no way of knowing whether the previous transfer was in text or
  10301. binary mode so it is your responsibility to choose the appropriate recovery
  10302. method.
  10303.  
  10304. If you use C-Kermit to maintain parallel directories on different computers,
  10305. using SET FILE COLLISION to transfer only those files that changed since last
  10306. time, and the files are big enough (or the connection slow enough) to require
  10307. SEND /RECOVER to resume interrupted transfers, you should remember that SEND
  10308. /RECOVER (RESEND) overrides all FILE COLLISION settings.  Therefore you
  10309. should use SEND /RECOVER (RESEND) only on the file that was interrupted, not
  10310. the file group.  For example, if the original transfer was initiated with:
  10311.  
  10312.   SEND *
  10313.  
  10314. and was interrupted, then after reestablishing your connection and starting
  10315. the Kermit receiver with SET FILE COLLISION UPDATE on the remote end, use the
  10316. following sequence at the sender to resume the transfer:
  10317.  
  10318.   SEND /RECOVER <name-of-interrupted-file>
  10319.  
  10320. and then:
  10321.  
  10322.   SEND *
  10323.  
  10324. (In C-Kermit 7.0 and later, \v(filename) contains the name of the file
  10325. most recently transferred, as long you have not EXITed from Kermit or
  10326. changed directory, etc.
  10327.  
  10328. 4.24. FILE COLLISION UPDATE Clarification
  10329.  
  10330. In UNIX, file modification dates are used when comparing the file date with
  10331. the date in the attribute packet.  In VMS, however, the file creation date
  10332. is used.  These two policies reflect the preferences of the two user
  10333. communities.
  10334.  
  10335. Also, remember that the file date/time given in the attribute packet is the
  10336. local time at the file sender.  At present, no timezone conversions are
  10337. defined in or performed by the Kermit protocol.  This is primarily because
  10338. this feature was designed at a time when many of the systems where Kermit runs
  10339. had no concept of timezone, and therefore would be unable to convert (say,
  10340. to/from GMT or UTC or Zulu time).
  10341.  
  10342. As a consequence, some unexpected results might occur when transferring files
  10343. across timezones; e.g. commands on the target system that are sensitive to
  10344. file dates might work (UNIX "make", backups, etc).
  10345.  
  10346. Timezone handling is deferred for a future release.
  10347.  
  10348. 4.25. Autodownload Improvements
  10349.  
  10350. Refer to pages 164-165 of "Using C-Kermit" about the hazards of autodownload
  10351. when C-Kermit is "in the middle".  As of C-Kermit 7.0, no more hazards.  If
  10352. C-Kermit has TERMINAL AUTODOWNLOAD ON and it detects a packet of the current
  10353. protocol type (Kermit or Zmodem), it "erases" the visual aspect of the packet
  10354. that would be seen by the terminal (or, more to the point, the emulator, such
  10355. as K95).  This way, only C-Kermit goes into RECEIVE mode, and not also the
  10356. terminal emulator through which C-Kermit is accessed.  And therefore, it is no
  10357. longer necessary to SET TERMINAL AUTODOWNLOAD OFF to prevent multiple Kermits
  10358. from going into receive mode at once, but of course it is still necessary to
  10359. ensure that, when you have multiple Kermits in a chain, that the desired one
  10360. receives the autodownload.
  10361.  
  10362. The defaults have not been changed; Kermit 95 still has autodownload ON by
  10363. default, and C-Kermit has it OFF by default.
  10364.  
  10365.  
  10366. (5) CLIENT/SERVER
  10367.  
  10368. 5.0. Hints
  10369.  
  10370. If you use SET SERVER GET-PATH to set up your server, and the GET-PATH does
  10371. not include the server's current directory, clients can become quite confused.
  10372. For example, "remote dir oofa.txt" shows a file named oofa.txt, but "get
  10373. oofa.txt" fails.  In this situation, you should either DISABLE DIR or make
  10374. your GET-PATH include the current directory.
  10375.  
  10376. 5.1. New Command-Line Options
  10377.  
  10378. The -G command-line option is like -g (GET), except the incoming file is
  10379. sent to standard output rather than written to disk.
  10380.  
  10381. The -I option ("Internet") is used to tell a remote C-Kermit program that you
  10382. are coming in  via Internet Telnet or Rlogin and therefore have a reliable
  10383. connection.  The -I option is equivalent to SET RELIABLE ON and SET FLOW
  10384. NONE.
  10385.  
  10386. The -O option ("Only One") tells C-Kermit to enter server mode but then exit
  10387. after the first client operation.
  10388.  
  10389. See section 9.3 for details.
  10390.  
  10391. 5.2. New Client Commands
  10392.  
  10393. BYE and FINISH no longer try to do anything if a connection is not active.
  10394. Thus a sequence like "hangup" followed by "bye" or "finish" will no longer get
  10395. stuck in a long timeout-and-retransmission cycle, nor will it try to open a
  10396. new connection.
  10397.  
  10398. REMOTE EXIT
  10399.   Similar to FINISH, except it ensures that the Kermit server program exits
  10400.   back to the operating system or shell prompt.  (FINISH would return it to
  10401.   its interactive prompt if it was started in interactive mode, and would
  10402.   cause it to exit if it entered server mode via command-line option.)  When
  10403.   C-Kermit is to be the server, you can use { ENABLE, DISABLE } EXIT to
  10404.   control the client's access to this feature.
  10405.  
  10406. REMOTE MKDIR <directory-name>
  10407.   Tells the client to ask the server to create a directory with the given
  10408.   name, which can be absolute or relative.  The syntax of the directory name
  10409.   depends on the Kermit server (see next section); in all cases, it can be in
  10410.   the syntax of the system where the server is running (UNIX, VMS, DOS, etc)
  10411.   but newer servers also accept UNIX syntax, no matter what the underlying
  10412.   platform.  The server will not execute this command if (a) it does not
  10413.   understand it, (b) a DISABLE MKDIR command has been given, or (c) a DISABLE
  10414.   CWD command has been given; otherwise, the command is executed, but will
  10415.   fail if the directory can not be created, in which cases most servers will
  10416.   attempt to return a message giving the reason for failure.  The REMOTE MKDIR
  10417.   command succeeds if the remote directory is created, or if it already exists
  10418.   and therefore does not need to be created, and fails otherwise.
  10419.  
  10420. REMOTE RMDIR <directory-name>
  10421.   Tells the client to ask the server to remove (delete) a directory with the
  10422.   given name.  The same considerations apply as for REMOTE MKDIR.
  10423.  
  10424. REMOTE SET FILE INCOMPLETE { DISCARD, KEEP, AUTO }
  10425.   Previously this was only available in its earlier form, REMOTE SET
  10426.   INCOMPLETE (no FILE).  The earlier form is still available, but invisible.
  10427.   Also, AUTO was added, meaning KEEP if in binary mode, DISCARD otherwise.
  10428.  
  10429. REMOTE SET TRANSFER MODE { AUTOMATIC, MANUAL }
  10430.   Tells the client to ask the server to set the given file-transfer mode.
  10431.   Automatic means (roughly): if the client and the server are running on the
  10432.   same kind of computer (e.g. both are on UNIX), then use binary mode
  10433.   automatically; if the system types are different, use some other method
  10434.   to automatically determine text or binary mode, such as filename pattern
  10435.   matching.  MANUAL means, in this context, obey the client's FILE TYPE
  10436.   setting (TEXT or BINARY).  Synonym: REMOTE SET XFER MODE ...
  10437.  
  10438. [ REMOTE ] QUERY KERMIT function(args...)
  10439.   Prior to C-Kermit 7.0, the arguments were not evaluated locally.  Thus it
  10440.   was not possible to have the server run the function with client-side
  10441.   variables as arguments.  Now:
  10442.     define \%a oofa.*
  10443.     remote query kermit files(\%a)    ; Client's \%a
  10444.     remote query kermit files(\\%a)   ; Server's \%a
  10445.  
  10446. [ REMOTE ] LOGIN [ <user> [ <password ] ]
  10447.   LOGIN is now a synonym for REMOTE LOGIN.
  10448.  
  10449. LOGOUT
  10450.   This command, when given in local mode, is equivalent to REMOTE LOGOUT.
  10451.   When given at the IKSD prompt, it logs out the IKSD.  When given at the
  10452.   C-Kermit prompt when it has no connection, it does nothing.
  10453.  
  10454. Note that in C-Kermit 7.0, the REMOTE (or R) prefix is not required for QUERY,
  10455. since there is no local QUERY command.  The new top-level QUERY command does
  10456. exactly what REMOTE QUERY (RQUERY) does.
  10457.  
  10458. All REMOTE commands now have single-word shortcuts:
  10459.  
  10460.  Shortcut   Full Form
  10461.   RASG       REMOTE ASSIGN
  10462.   RCD        REMOTE CD
  10463.   RCOPY      REMOTE COPY
  10464.   RDEL       REMOTE DELETE
  10465.   RDIR       REMOTE DIRECTORY
  10466.   REXIT      REMOTE EXIT
  10467.   RHELP      REMOTE HELP
  10468.   RHOST      REMOTE HOST
  10469.   RPWD       REMOTE PWD
  10470.   RSET       REMOTE SET
  10471.   etc.
  10472.  
  10473. The R prefix is not applied to LOGIN because there is already an RLOGIN
  10474. command with a different meaning.  It is not applied to LOGOUT either, since
  10475. LOGOUT knows what to do in each case, and for symmetry with LOGIN.
  10476.  
  10477. 5.2.1. Remote Procedure Definitions and Calls
  10478.  
  10479. This is nothing new, but it might not be obvious...  REMOTE ASSIGN and REMOTE
  10480. QUERY may be used to achieve remote procedure execution.  The remote procedure
  10481. can be defined locally or remotely.
  10482.  
  10483. A remote procedure call is accomplished as noted in the previous section:
  10484.  
  10485.   [ remote ] query kermit function-name(args...)
  10486.  
  10487. This invokes any function that is built in to the Kermit server, e.g.:
  10488.  
  10489.   [ remote ] query kermit size(foo.bar)
  10490.  
  10491. returns the size of the remote file, foo.bar.
  10492.  
  10493. Now note that C-Kermit includes an \fexecute() function, allowing it to
  10494. execute any macro as if it were a built-in function.  So suppose MYMACRO
  10495. is the name of a macro defined in the server.  You can execute it from
  10496. the client as follows (the redundant "remote" prefix is omitted in the
  10497. remaining examples):
  10498.  
  10499.   query kermit execute(mymacro arg1 arg2...)
  10500.  
  10501. The return value, if any, is the value of the RETURN command that terminated
  10502. execution of the macro, for example:
  10503.  
  10504.   define addtwonumbers return \feval(\%1+\%2)
  10505.  
  10506. The client invocation would be:
  10507.  
  10508.   query kermit execute(addtwonumbers 3 4)
  10509.   7
  10510.  
  10511. The result ("7" in this case) is also assigned to the client's \v(query)
  10512. variable.
  10513.  
  10514. To execute a remote system command or command procedure (shell script, etc)
  10515. use:
  10516.  
  10517.   query kermit command(name args...)
  10518.  
  10519. Finally, suppose you want the client to send a macro to the server to be
  10520. executed on the server end.  This is done as follows:
  10521.  
  10522.   remote assign macroname definition
  10523.   query kermit execute(macroname arg1 arg2...)
  10524.  
  10525. Quoting is required if the definition contains formal parameters.
  10526.  
  10527. 5.3. New Server Capabilities
  10528.  
  10529. 5.3.1. Creating and Removing Directories
  10530.  
  10531. The C-Kermit 7.0 server responds to REMOTE MKDIR and REMOTE RMDIR commands.
  10532. The directory name may be in either the native format of the server's
  10533. computer, or in UNIX format.  For example, a server running on VMS with a
  10534. current directory of [IVAN] can accept commands from the client like:
  10535.  
  10536.   remote mkdir olga         ; Makes [IVAN.OLGA] (nonspecific format)
  10537.   remote mkdir .olga        ; Makes [IVAN.OLGA] (VMS format without brackets)
  10538.   remote mkdir olga/        ; Makes [IVAN.OLGA] (UNIX relative format)
  10539.   remote mkdir /ivan/olga   ; Makes [IVAN.OLGA] (UNIX absolute format)
  10540.   remote mkdir [ivan.olga]  ; Makes [IVAN.OLGA] (VMS absolute format)
  10541.   remote mkdir [.olga]      ; Makes [IVAN.OLGA] (VMS relative format)
  10542.  
  10543. 5.3.1.1. Creating Directories
  10544.  
  10545. If a directory name is given that contains more than one segment that does not
  10546. exist, the server attempts to create all the segments.  For example, if the
  10547. client says:
  10548.  
  10549.   REMOTE MKDIR letters/angry
  10550.  
  10551. a "letters" subdirectory is created in the server's current directory if it
  10552. does not already exist, and then an "angry" subdirectory is created beneath
  10553. it, if it does not already have one.  This can repeated to any reasonable
  10554. depth:
  10555.  
  10556.   REMOTE MKDIR a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/z/y/z
  10557.  
  10558. 5.3.1.2. Removing Directories
  10559.  
  10560. When attempting to execute a REMOTE RMDIR, the server can remove only a single
  10561. directory, not an entire sequence or tree.  The system service that is called
  10562. to remove the directory generally requires not only that the server process
  10563. has write delete access, but also that the directory contain no files.
  10564.  
  10565. In the future, a REMOTE RMDIR /RECURSIVE command (and the accompanying
  10566. protocol) might be added.  For now, use the equivalent REMOTE HOST command(s),
  10567. if any.
  10568.  
  10569. 5.3.2. Directory Listings
  10570.  
  10571. Directory listings are generated by C-Kermit itself, rather than by running
  10572. the underlying system's directory command.  Some control over the listing
  10573. format can be obtained with the SET OPTIONS DIRECTORY command (Section 4.5.1).
  10574. The following options affect listings sent by the server: /[NO]HEADING,
  10575. /[NO]DOTFILES, and /[NO]BACKUP.  In UNIX and VMS, the listing is always sorted
  10576. by filename.  There is, at present, no protocol defined for the client to
  10577. request listing options of the server; this might be added in the future.
  10578.  
  10579. The server's directory listings are in the following format:
  10580.  
  10581. Protection or permissions:
  10582.   In UNIX and OS-9, this is a 10-character field, left adjusted.  In VMS it
  10583.   is a 22-character field, left-adjusted.  In each case, the protection /
  10584.   permission codes are shown in the server platform's native format.  In
  10585.   other operating systems, this field is not shown.
  10586.  
  10587. Size in bytes:
  10588.   This is always a 10-character field.  The file's size is shown as a decimal
  10589.   number, right adjusted in the field.  If the file is a directory and its
  10590.   size can not be obtained, the size is shown as "<DIR>".  Two blanks follow
  10591.   this field.
  10592.  
  10593. Date:
  10594.   Always in yyyy-mm-dd hh:mm:ss numeric format, and therefore 19 characters
  10595.   long.   If the file's date/time can't be obtained, zeros (0) are shown for
  10596.   all the digits.  This field is followed by two blanks.
  10597.  
  10598. Filename:
  10599.   This field extends to the end of the line.  Filenames are shown relative
  10600.   to the server's current directory.  In UNIX, symbolic links are shown as
  10601.   they are in an "ls -l" listing as "linkname -> filename".
  10602.  
  10603. In UNIX and VMS, listings are returned by the server in alphabetical order of
  10604. filename.  There are presently no other sort or selection options.
  10605.  
  10606. However, since these are fixed-field listings, all fields can be used as
  10607. sort keys by external sort programs.  Note, in particular, that the format
  10608. used for the date allows a normal lexical on that field to achieve the date
  10609. ordering.  For example, let's assume we have a UNIX client and a UNIX server.
  10610. In this case, the server's listing has the date in columns 22-40, and thus
  10611. could be sorted by the UNIX sort program using "sort +0.22 -0.40" or in
  10612. reverse order by "sort +0.22 -0.40r".
  10613.  
  10614. Since the UNIX client can pipe responses to REMOTE commands through filters,
  10615. any desired sorting can be accomplished this way, for example:
  10616.  
  10617.   C-Kermit> remote directory | sort +0.22 -0.40
  10618.  
  10619. You can also sort by size:
  10620.  
  10621.   C-Kermit> remote directory | sort +0.11 -0.19
  10622.  
  10623. You can use sort options to select reverse or ascending order.  "man sort"
  10624. (in UNIX) for more information.  And of course, you can pipe these listings
  10625. through any other filter of your choice, such as grep to skip unwanted lines.
  10626.  
  10627. 5.4. Syntax for Remote Filenames with Embedded Spaces
  10628.  
  10629. C-Kermit and K95, when in server mode, assume that any spaces in the file
  10630. specification in an incoming GET command are filename separators.  Thus if
  10631. the client gives a command like:
  10632.  
  10633.   get {oofa.txt oofa.bin}
  10634.  
  10635. or, equivalently:
  10636.  
  10637.   mget oofa.txt oofa.bin
  10638.  
  10639. the server tries to send the two files, oofa.txt and oofa.bin.  But what if
  10640. you want the server to send you a file named, say:
  10641.  
  10642.   D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL
  10643.  
  10644. How does the server know this is supposed to be one file and not seven?
  10645. In this case, you need to the send file name to the server enclosed in either
  10646. curly braces:
  10647.  
  10648.   {D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}
  10649.  
  10650. or ASCII doublequotes:
  10651.  
  10652.   "D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL"
  10653.  
  10654. The method for doing this depends on your client.  If your client is C-Kermit
  10655. 7.0, any recent version of Kermit 95, or MS-DOS Kermit 3.16, then you have
  10656. to enclose the name in braces just so the client can parse it, so to send
  10657. braces or doublequotes to the server, you must put them inside the first,
  10658. outside pair of braces.  And you also need to double the backslashes to
  10659. prevent them from being interpreted:
  10660.  
  10661.   get {{D:\\HP OfficeJet 500\\Images\\My Pretty Picture Dot PCL}}
  10662.   get {"D:\\HP OfficeJet 500\\Images\\My Pretty Picture Dot PCL"}
  10663.  
  10664. To get around the requirement to double backslashes in literal filenames,
  10665. of course you can also use:
  10666.  
  10667.   set command quoting off
  10668.   get {{D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}}
  10669.   get {"D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL"}
  10670.   set command quoting on
  10671.  
  10672. If you are giving a "kermit" command to the UNIX shell, you have to observe
  10673. the shell's quoting rules, something like this:
  10674.  
  10675.   kermit -ig "{D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}"
  10676.  
  10677. Here, the quotes go on the outside so UNIX will pass the entire filename,
  10678. spaces, braces, and all, as a single argument to Kermit, and the backslashes
  10679. are not doubled because (a) the UNIX shell ignores them since they are in a
  10680. quoted string, and (b) Kermit ignores them since the interactive command parser
  10681. is not activated in this case.
  10682.  
  10683. 5.5. Automatic Orientation Messages upon Directory Change
  10684.  
  10685. C-Kermit 7.0, when acting as a server, can send an orientation message to
  10686. the client whenever the server directory changes.  For example, when the
  10687. client gives a REMOTE CD command, the server sends the contents of the
  10688. new directory's "Read Me" file to the client's screen.  The following commands
  10689. govern this feature:
  10690.  
  10691. SET SERVER CD-MESSAGE FILE <name>
  10692.   Given to the servr, allows the message-file name to be specified at runtime.
  10693.   A list of names to look for can be given in the following format:
  10694.  
  10695.     {{name1}{name2}{name3}{...}}
  10696.  
  10697.   e.g. SET SERVER CD-MESSAGE FILE {{./.readme}{README.TXT}{READ.ME}}
  10698.  
  10699. REMOTE SET SERVER CD-MESSAGE { ON, OFF }
  10700.   Given to the client, lets the client control whether the server sends
  10701.   automatic CD messages.
  10702.  
  10703. SHOW SERVER
  10704.   Given to server, includes CD-Message status.
  10705.  
  10706. The default CD message file name is system dependent.  SHOW CD or SHOW SERVER
  10707. displays the list.  Also see Section 4.5.2.
  10708.  
  10709. 5.6. New Server Controls
  10710.  
  10711. DISABLE ENABLE
  10712.   Allows the server to configured such that DISABLEd features can not be
  10713.   re-enabled by any means -- e.g. if the client is somehow able to get the
  10714.   server into command mode.  Once DISABLEd, ENABLE can not be re-ENABLEd.
  10715.  
  10716. SET SERVER IDLE-TIMEOUT <seconds>
  10717.   This was available previously in Kermit 95 only.  Now it can be used in
  10718.   C-Kermit also to specify a maximum number of seconds the server is allowed
  10719.   to be idle before exiting server mode.  0 seconds means no idle timeout.
  10720.   In C-Kermit (but not K-95), SET SERVER TIMEOUT and SET SERVER IDLE-TIMEOUT
  10721.   are mutually exclusive -- you can have one or the other (or neither), but
  10722.   not both.  (Server timeouts are for the benefit of primitive Kermit clients
  10723.   that are not capable of timing out on their own; to our knowledge, no such
  10724.   clients are still in circulation.)
  10725.  
  10726. SET SERVER KEEPALIVE { ON, OFF }
  10727.   (See next section).
  10728.  
  10729. 5.7. Timeouts during REMOTE HOST Command Execution
  10730.  
  10731. Prior to C-Kermit 7.0, the C-Kermit server would block waiting for output
  10732. from a system command invoked via REMOTE HOST from the client.  If the system
  10733. command took a long time to execute, the client would time out and send NAK
  10734. packets.  If the command took too long, the client would reach its retry limit
  10735. and give up.  Even if it didn't, the NAKs would cause unnecessary
  10736. retransmissions.
  10737.  
  10738. In version 7.0, the C-Kermit server (VMS and select()-capable UNIX versions
  10739. only), sends "keepalive packets" (empty data packets) once per second while
  10740. waiting for the system command to complete.  This procedure should be entirely
  10741. transparent to the Kermit client, and should prevent the unwanted timeouts and
  10742. NAKs.  When C-Kermit 7.0 itself (or K95 1.1.18) is the client, it prints dots
  10743. to show the keepalive packets.
  10744.  
  10745. The keepalive feature can be turned off and on with:
  10746.  
  10747.   SET SERVER KEEPALIVE { ON, OFF }
  10748.  
  10749. Normally it should be on.  Turn it off it if causes trouble with the client,
  10750. or if it seems to slow down the server (as it might on some platforms under
  10751. certain circumstances).
  10752.  
  10753.  
  10754. (6) INTERNATIONAL CHARACTER SETS
  10755.  
  10756. Support for several new single-byte character sets was added in C-Kermit
  10757. 7.0.  Unicode / ISO 10646 is not yet supported, but is a high priority for
  10758. forthcoming releases.
  10759.  
  10760. 6.0. ISO 8859-15 Latin Alphabet 9
  10761.  
  10762. To accommodate the Euro currency symbol, and to correct several other
  10763. longstanding problems with ISO Latin Alphabet 1, ISO 8859-15 Latin Alphabet 9
  10764. was issued in May 1998.  It is supported by C-Kermit 7.0 as a transfer
  10765. character set, a file character set, and a terminal character set.
  10766. Translations that preserve the new characters are available between Latin-9
  10767. and several other sets including:
  10768.  
  10769.   PC Code Page 858         (Western European languages, similar to CP850)
  10770.   Windows Code Page 1252   (Western European languages, similar to Latin-1)
  10771.   Windows Code Page 1250   (Eastern European languages, similar to Latin-2)
  10772.  
  10773. The Latin-9 transfer character set also allows for the OE digraph character,
  10774. used primarily in French, to be preserved in transfers involving the DEC MCS
  10775. or NeXT character sets.
  10776.  
  10777. The Euro character is also present in the Universal Character Set, described
  10778. in Section 6.6.
  10779.  
  10780. 6.1. The HP-Roman8 Character Set
  10781.  
  10782. The HP-Roman8 character set is supported in C-Kermit 6.0 but was omitted from
  10783. Table VII-4 due to lack of space.  See Appendix III below.
  10784.  
  10785. 6.2. Greek Character Sets
  10786.  
  10787. Greek character sets were added in 6.1:
  10788.  
  10789.   SET FILE CHARACTER-SET { CP869, ELOT927, GREEK-ISO }
  10790.   SET TRANSFER CHARACTER-SET { GREEK-ISO }
  10791.  
  10792. GREEK-ISO is ISO 8859-7, which the same as ELOT 928.
  10793.  
  10794. The new Greek character sets are listed in Appendix III.
  10795.  
  10796. 6.3. Additional Latin-2 Character Sets
  10797.  
  10798. The following have been added as FILE and TERMINAL CHARACTER-SETs:
  10799.  
  10800. MAZOVIA-PC
  10801.   A PC code page used in Poland, equivalent to CP437, but with 18
  10802.   substitutions needed for Polish.
  10803.  
  10804. CP1250
  10805.   The Windows Latin 2 Code Page.  Equivalent to ISO 8859-2, but with
  10806.   different encoding.
  10807.  
  10808. 6.4. Additional Cyrillic Character Sets
  10809.  
  10810. The following have been added as FILE and TERMINAL CHARACTER-SETs:
  10811.  
  10812. BULGARIA-PC
  10813.   This is the Cyrillic PC code page used in Bulgaria, where it is called
  10814.   Code Page 856.  It is attributed to a company called DATEC, Inc, but CP856
  10815.   is not a proper designation, since it refers to a Hebrew Code Page (see
  10816.   the IBM Registry).
  10817.  
  10818. CP855
  10819.   This PC Code Page
  10820.   contains all the Cyrillic letters that are also in ISO 8859-5, and is
  10821.   therefore useful for non-Russian Cyrillic text (Ukrainian, Belorussian,
  10822.   etc), unlike CP866, which has a smaller repertoire of Cyrillic letters.
  10823.  
  10824. CP1251
  10825.   The Windows Cyrillic Code Page.  Equivalent to CP855, but with different
  10826.   encoding.
  10827.  
  10828. KOI8R
  10829.   An extension to "Old KOI-8" that adds upper and lower case Cyrillic letter
  10830.   Io (looks like Roman E with diaeresis) plus a selection of box-drawing
  10831.   characters to columns 8 through 11, which are vacant in original Old KOI-8.
  10832.   KOI8-R is used for the Russian language.  It is specified in RFC 1489.
  10833.  
  10834. KOI8U
  10835.   A similar extension of Old KOI-8, but for Ukrainian.  It is specified in
  10836.   RFC 2319.
  10837.  
  10838. 6.5. Automatic Character-Set Switching
  10839.  
  10840. Prior to version 7.0, C-Kermit's file character-set always had to be set
  10841. explicitly.  In 7.0 and later, it is set automatically when:
  10842.  
  10843.  a. This feature is enabled (as it is unless you disable it).
  10844.  
  10845.  b. An incoming text-mode transfer includes a transfer-character-set
  10846.     announcer and you have not previously given a SET FILE CHARACTER-SET
  10847.     command.  In this case, C-Kermit switches to an appropriate file
  10848.     character set.  For example, on an HP-UX workstation, an incoming
  10849.     Latin-1 file automatically selects HP-Roman8 for the local copy of
  10850.     the file; in Data General AOS/VS, it would select DG International.
  10851.  
  10852.  c. You give a SET TRANSFER CHARACTER-SET command without having
  10853.     previously specified a FILE CHARACTER-SET.  An appropriate file
  10854.     character-set is chosen automatically.
  10855.  
  10856. In addition, when you give a SET FILE CHARACTER-SET command, the appropriate
  10857. transfer character-set is automatically chosen, to be used when you are
  10858. sending files (but this does not override the one announced by the sender
  10859. when you are receiving files).
  10860.  
  10861. You might not agree about what is "appropriate", so of course you can disable
  10862. or change all of the above actions.
  10863.  
  10864. You can disable (or re-enable) the new automatic character-set switching
  10865. feature in each direction separately:
  10866.  
  10867. SET RECEIVE CHARACTER-SET-SELECTION { AUTOMATIC, MANUAL }
  10868.   AUTOMATIC is the default, causing the behavior described above when an
  10869.   incoming file arrives.   Choose MANUAL to defeat this behavior and force
  10870.   your current FILE CHARACTER-SET setting to be used, no matter what it is.
  10871.   Note that SET RECEIVE CHARACTER-SET MANUAL does not disable recognition
  10872.   of the incoming transfer character-set announcer, and translation from the
  10873.   corresponding character-set to your current file character-set.  To disable
  10874.   that, use SET ATTRIBUTE CHARACTER-SET OFF.
  10875.  
  10876. SET SEND CHARACTER-SET-SELECTION { AUTOMATIC, MANUAL }
  10877.   Again AUTOMATIC is the default, causing the behavior described above when
  10878.   you give a SET { FILE, TRANSFER } CHARACTER-SET command.  Use MANUAL to
  10879.   allow you to specify the transfer and file character-sets independently.
  10880.  
  10881. SHOW CHARACTER-SETS
  10882.   Tells settings of { SEND, RECEIVE } CHARACTER-SET-SELECTION.
  10883.  
  10884. Normally, however, it is more convenient to leave automatic switching active,
  10885. and change any associations that are not appropriate for your application,
  10886. area, or country.  The commands are:
  10887.  
  10888. SHOW ASSOCIATIONS
  10889.   This command lists all the associations in each direction: for each possible
  10890.   transfer character-set, it lists the associated file character-set, and
  10891.   vice versa.  These are two separate and independent lists.
  10892.  
  10893. ASSOCIATE TRANSFER-CHARACTER-SET <name1> [ <name2> ]
  10894.   Changes the association for the transfer character-set <name1> to be the
  10895.   file character-set <name2>.  If <name2> is omitted, automatic switching is
  10896.   disabled for this transfer character-set only.
  10897.  
  10898. ASSOCIATE FILE-CHARACTER-SET <name1> [ <name2> ]
  10899.   Changes the association for the file character-set <name1> to be the
  10900.   transfer character-set <name2>.  If <name2> is omitted, automatic switching
  10901.   is disabled for this file character-set only.
  10902.  
  10903. 6.6. UNICODE
  10904.  
  10905. C-Kermit 7.0 adds support for Unicode, the Universal Character Set, for:
  10906.  
  10907.  . File Transfer (SEND, RECEIVE, GET, etc)
  10908.  . Terminal connection (CONNECT)
  10909.  . Unguarded file capture (LOG SESSION)
  10910.  . Unguarded file transmission (TRANSMIT)
  10911.  . Local file character-set conversion (TRANSLATE)
  10912.  
  10913. C-Kermit is not, however, a "Unicode application" in the sense that its
  10914. commands, messages, or user interface are Unicode.  Rather, it is "Unicode
  10915. aware" in its ability to handle and convert Unicode text in the course of file
  10916. transfer and terminal connection, and you can also use Kermit to convert local
  10917. files between Unicode and other character sets.
  10918.  
  10919. TLA's:
  10920.  
  10921.   BMP - Base Multilingual Plane
  10922.   BOM - Byte Order Mark
  10923.   CJK - Chinese, Japanese, and Korean
  10924.   ISO - International Standards Organization
  10925.   TLA - Three-Letter Acronym
  10926.   UCS - Universal Character Set
  10927.   UTF - UCS Transformation Format
  10928.  
  10929. Unicode and ISO 10646 are the coordinated and compatible corporate and
  10930. international standards for the Universal Character Set (UCS).  Unlike
  10931. single-byte and even most multibyte character sets, the UCS can represent all
  10932. characters in every existing writing system.  A flat plain-text file encoded
  10933. in some form of UCS can contain any mixture of English, Spanish, Italian,
  10934. German, Hebrew, Arabic, Greek, Russian, Armenian, Georgian, Japanese, Chinese,
  10935. Korean, Vietnamese, Tibetan, Hindi, Bengali, Tamil, Thai, Ethiopic, and so on,
  10936. plus scientific and mathematical notation, as well as texts in Runes, Ogham,
  10937. Glagolitic, and other historic scripts.
  10938.  
  10939. The UCS already covers these scripts and many more, but it's an evolving
  10940. standard with efforts underway to accommodate even more languages and writing
  10941. systems.  Support is growing for native UCS use on many platforms and in many
  10942. applications.  The goal of the framers of the UCS is for it to replace ASCII,
  10943. the ISO Latin Alphabets, ISCII, VISCII, the Chinese, Japanese, and Korean
  10944. (CJK) multibyte sets, etc, as well as the many private character sets in use
  10945. today, in other words to become *the* Universal Character Set.
  10946.  
  10947. Until that time, however, conversions between existing sets and the UCS will
  10948. be necessary when moving text between platforms and applications.  Now Kermit
  10949. can help.
  10950.  
  10951. 6.6.1. Overview of Unicode
  10952.  
  10953. For a more complete picture, please visit:
  10954.  
  10955.   http://www.unicode.org/
  10956.  
  10957. and access the various online introductions, FAQs, technical reports, and
  10958. other information.  For greater depth, order the latest version of the
  10959. published Unicode Standard.  The following overview contains a great many
  10960. oversimplifications and perhaps an opinion or two.
  10961.  
  10962. At present, the UCS is a 16-bit (2-byte) character set, but with provisions to
  10963. grow to a 4-byte set.  UCS-2 refers to the two-byte set, also called the Base
  10964. Multilingual Plane (BMP), in which each character has 16 bits, and therefore
  10965. there are 2^16 = 65536 possible characters.  The first 128 characters are the
  10966. same as US ASCII (C0 control characters and DEL included), the next 32 are the
  10967. C1 control characters of ISO 6429, and the next 96 are the Right Half of ISO
  10968. 8859-1 Latin Alphabet 1.  The remaining tens of thousands of characters are
  10969. arranged newly for the UCS, usually (but not always) in sections corresponding
  10970. to existing standards, such as ISO Latin/Cyrillic, often plus additional
  10971. characters not appearing in the existing standards due to lack of space (or
  10972. other reasons).
  10973.  
  10974. ISO 10646 allows for additional planes, e.g. for Egyptian hieroglyphics or
  10975. ancient (or other esoteric) CJK characters, but these planes are not yet
  10976. defined and so we will say nothing more about them here, except that their use
  10977. will require the 4-byte form of UCS, called UCS-4, in some form (more about
  10978. "forms" in Section 6.6.2).
  10979.  
  10980. Unicode and ISO 10646 are constantly under revision, mainly to add new
  10981. characters.  The Unicode revision is denoted by a version number, such as 1.0,
  10982. 1.1, 2.0, 3.0.  The ISO 10646 standard revision is identified by Edition (such
  10983. as ISO 10646-1 1993), plus reference to any amendments.  The first versions of
  10984. these standards included encodings for Korean Hangul syllables (Jamos); these
  10985. encodings were changed in version 1.1 of Unicode and by Amendment 5 to ISO
  10986. 10646-1.  The Unicode Technical Committee and the ISO acknowledge that this
  10987. was a bad thing to do, and promise never change encodings or character names
  10988. again, since this poses serious problems for conformance and data interchange.
  10989.  
  10990. A UCS-2 value is customarily written like this:
  10991.  
  10992.   U+xxxx
  10993.  
  10994. where "xxxx" represents four hexadecimal digits, 0-9 and A-F.  For example,
  10995. U+0041 is "A", U+00C1 is A-acute, U+042F is uppercase Cyrillic "Ya", U+FB4F is
  10996. Hebrew Ligature Alef Lamed, and U+FFFD is the special character that means
  10997. "not a character".
  10998.  
  10999. Most characters from widely-used alphabetic writing systems such as the West
  11000. European ones, Cyrillic, Greek, Hebrew, Vietnamese, etc, are available in
  11001. "precomposed" form; for example Uppercase Latin Letter A with Acute Accent is
  11002. a single character (as it is in Latin-1).  However, the UCS also permits
  11003. composition of a base character with one or more nonspacing diacritics.  This
  11004. means the same character can be represented in more than one way, which can
  11005. present problems in many application areas, including transfer and
  11006. character-set conversion of text.
  11007.  
  11008. Conversion from ASCII or Latin-1 to UCS-2 text is "trivial": simply insert a
  11009. NUL (0) byte before each ASCII or Latin-1 byte.  Converting in the reverse
  11010. direction (provided the UCS-2 file contains only U+0000 to U+00FF) is equally
  11011. simple (if we ignore the issue of composition): remove every second (NUL)
  11012. byte.  Conversion of other character sets to and from UCS, however, requires
  11013. tables or algorithms specific to each set.  Nevertheless, the relatively
  11014. transparent upwards compatibility from ASCII and Latin-1, in which a very
  11015. large share of the world's textual data is encoded, gives the UCS an entree
  11016. onto existing platforms.
  11017.  
  11018. But the 2-byte format and the preponderance of NUL and other control bytes in
  11019. UCS-2 text pose problems for current applications and transmission methods.
  11020. And to make matters worse, different hardware platforms store UCS-2 characters
  11021. in different byte order.  Thus a UCS-2 file transferred by FTP (or accessed
  11022. via NFS, etc) between two computers with different architecture might have its
  11023. bytes in the wrong order (or worse; see Section 6.6.5.1).
  11024.  
  11025. 6.6.2. UCS Byte Order
  11026.  
  11027. Consider the number 1.  In an 8-bit byte, this would be represented by the
  11028. following series of 0- and 1-bits:
  11029.  
  11030.   +-----------------+
  11031.   | 0 0 0 0 0 0 0 1 |
  11032.   +-----------------+
  11033.  
  11034. Therefore in a 16-bit "word" the representation might be:
  11035.  
  11036.   +-----------------+-----------------+
  11037.   | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 1 |
  11038.   +-----------------+-----------------+
  11039.  
  11040. Now consider the number 256, which is 2 to the 8th power.  The binary
  11041. representation is 100000000 (1 followed by 8 zeros).  256 would go into a
  11042. 16-bit word like this:
  11043.  
  11044.   +-----------------+-----------------+
  11045.   | 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0 |
  11046.   +-----------------+-----------------+
  11047.  
  11048. When a computer works this way, it is said to be Big Endian, meaning it puts
  11049. the most signicant (biggest) byte first (on the "left") in a 16-bit word, and
  11050. the least significant byte second (on the right).
  11051.  
  11052. However, some other computers have the opposite arrangement, called Little
  11053. Endian, in which 1 is:
  11054.  
  11055.   +-----------------+-----------------+
  11056.   | 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0 |
  11057.   +-----------------+-----------------+
  11058.  
  11059. and 256 is:
  11060.  
  11061.   +-----------------+-----------------+
  11062.   | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 1 |
  11063.   +-----------------+-----------------+
  11064.  
  11065. Computers such as Sparc, MIPS, PA-RISC, and PowerPC are Big Endian, whereas
  11066. the PC and the Alpha are Little Endian.  Endianness has never been an issue
  11067. with 7- or 8-bit characters, but it is with UCS characters.  It can be a
  11068. tricky business to share or transfer a UCS-2 file between two different kinds
  11069. of computers.
  11070.  
  11071. To alleviate (but not entirely solve) the problem, UCS-2 files are supposed to
  11072. begin with the Unicode character U+FEFF, Zero-Width No-Break Space (ZWNBS).
  11073. This is a kind of "no-op" (note: any such assertion must normally be qualified
  11074. with many "but ifs" and "excepts" which are omitted here in the interest of
  11075. brevity).  If the bytes are reversed the ZWNBS becomes U+FFFE, which is not
  11076. (and never will be) a defined UCS character.  U+FEFF at the beginning of a UCS
  11077. file is therefore called a Byte Order Mark, or BOM.
  11078.  
  11079. Any application that creates a UCS-2 (or UTF-16, or UCS-4) file should include
  11080. a BOM, and any application that reads one should test for a BOM, and if one is
  11081. found, infer the byte order from it.  This is a convention, however -- not a
  11082. standard or a requirement -- and applications vary in their ability to handle
  11083. BOMs and "backwards" UCS-2 files.
  11084.  
  11085. Note that a BOM is useful only at the beginning of a file.  If you append one
  11086. UCS-2 file to another, and both have BOMs, the internal BOM is no longer a
  11087. BOM.  And if the byte orders of the two files differ, then either the first
  11088. part or the second will be backwards.  (Various other undesirable effects
  11089. might also occur, not discussed here.)
  11090.  
  11091. 6.6.2. UCS Transformation Formats
  11092.  
  11093. UCS textual data can be modified in various ways for transmission or storage.
  11094. Any officially sanctioned method of doing this is called a UCS Transformation
  11095. Format, or UTF.  One such method, called UTF-16, is essentially identical with
  11096. UCS-2 except that it designates certain code values as "escape sequences"
  11097. (called surrogate pairs) to access characters in other planes without having
  11098. to use full UCS-4.  We won't discuss UTF-16 further here, since at the moment
  11099. there are no other planes.  Several other UTF's (such as UTF-1, UTF-2, and
  11100. UTF-7) have fallen into disuse and are not discussed here.  The most important
  11101. transformation format today is UTF-8.
  11102.  
  11103. UTF-8, so called because it "serializes" UCS-2 data into a stream of 8-bit
  11104. bytes, is designed to allow the UCS to work with present-day communications
  11105. gear, computers, and software.  The most important properties of UTF-8 are
  11106. that byte order is constant (no byte swapping) and all (7-bit) ASCII
  11107. characters represent themselves.  Therefore conversion between ASCII and UTF-8
  11108. is no conversion at all, and applications or platforms (such as Plan 9 from
  11109. Bell Labs) that use UTF-8 "for everything" can still run traditional
  11110. ASCII-only applications and be accessed from them.  In particular, unlike
  11111. UCS-2, ASCII characters are not padded with NUL bytes.  But also unlike UCS-2,
  11112. there is no transparency for Latin-1 or any other non-ASCII character set.
  11113. Every non-ASCII UCS-2 character is represented by a sequence of 2 or 3 UTF-8
  11114. bytes.  Thus UTF-8 is more compact than UCS-2 for text containing a
  11115. preponderance of ABC's (or other ASCII characters), about the same as UCS-2
  11116. for other alphabetic scripts (Cyrillic, Roman, Greek, etc), and larger than
  11117. UCS-2 for Chinese, Japanese, and Korean.
  11118.  
  11119. The UTF-8 uncoding of the UCS has been adopted by the Internet as the
  11120. preferred character set for new applications, and is gradually being
  11121. retrofitted into traditional applications like FTP (RFC 2640).
  11122.  
  11123. 6.6.3. Conformance Levels
  11124.  
  11125. Although the Unicode and ISO 10646 standards both describe the same character
  11126. set, these standards differ in many ways, including their stated requirements
  11127. for conformance and their classification of conformance levels.
  11128.  
  11129. Kermit has always abided by ISO character-set standards, including ISO
  11130. character-set designation and invocation methods.  In adapting Unicode,
  11131. therefore, we had to choose from among the available ISO designations which,
  11132. in turn, correspond with ISO 10646 conformance levels.  At present, Kermit
  11133. claims the lowest conformance level, 1, meaning (roughly) that it does not
  11134. handle combining forms and it does not handle Korean Hangul Jamos (just as,
  11135. at present, it does not handle Korean in general).  Note that ISO 10646
  11136. Conformance Levels 1 and 2 sidestep the issue of the code changes for Korean
  11137. Hangul by announcing non-support for Hangul regardless of encoding.
  11138.  
  11139. ISO 10646 Conformance Level 1 is approximately equivalent to Unicode
  11140. Normalization Form C (described in Unicode Technical Report 15, incorporated
  11141. into Unicode 3.0).
  11142.  
  11143. As noted in Section 6.6.2, Kermit does not claim to support UTF-16 at the
  11144. present time, hence the UCS-2 nomenclature.  Kermit treats surrogates just as
  11145. if they were any other UCS-2 characters, rather than as escapes to other
  11146. planes, which means that (except when converting between UCS-2 and UTF-8) they
  11147. are translated to "error" characters, since (a) no other planes are defined
  11148. yet (and if they were, no other character sets supported by Kermit would
  11149. encode their characters), and (b) no valid surrogate character corresponds to
  11150. any other UCS-2 character.
  11151.  
  11152. A minor yet significant aspect of Unicode 3.0 and some recent perturbation of
  11153. ISO 10646-1 (probably Amendment 18, "Symbols and Other Characters") is the
  11154. addition of the Euro Sign at U+20AC.  As noted in Section 6.0, Kermit's "Euro
  11155. compliance" includes conversion between Latin Alphabet 9 and various PC code
  11156. pages.  Text can also be converted between UCS-2 or UTF-8 and any other
  11157. Euro-compliant character set (Latin-9, CP858, CP1250, CP1252) without loss of
  11158. the Euro Sign.
  11159.  
  11160. 6.6.4. Relationship of Unicode with Kermit's Other Character Sets
  11161.  
  11162. Kermit's character sets are divided into two groups: single-byte sets (such
  11163. as Roman, Hebrew, Cyrillic, Greek) and multibyte (various Japanese sets).  The
  11164. two groups are distinct since one normally would not expect to convert Kanji
  11165. ideograms to Roman (or other) letters, or vice versa.
  11166.  
  11167. Unicode character-set conversion works with both groups, but obviously the
  11168. result depends on the repertoires of the source and destination character-sets
  11169. both including the characters in the file.  For example, you can translate a
  11170. Hungarian text file between Latin-2 and Unicode, but not between (say) Unicode
  11171. and Latin/Greek.  By the same token you can convert Japanese text from
  11172. Shift-JIS or EUC or JIS-7 to Unicode and back, but you can't convert the same
  11173. file to (say) Latin-1 if it contains Japanese characters.
  11174.  
  11175.   JIS-7 is equivalent to DEC Kanji and ISO-2022-JP except that the latter
  11176.   two do not support halfwidth Katakana.  Kermit treats all three of these
  11177.   sets the same way, i.e. as JIS-7.
  11178.  
  11179. As noted, Kermit presently does not handle combining diacritics, and so will
  11180. not correctly convert UCS files that use them into a single-byte character
  11181. set.  For example, if a UCS file contains Latin Capital Letter A (U+0041)
  11182. followed by Combining Acute Accent (U+0301), the result will be a
  11183. two-character sequence, A followed by another character.  This is what is
  11184. meant by Conformance Level 1.  (The situation grows worse with multiple
  11185. diacritics, since they can occur in any order.)
  11186.  
  11187. A higher level of conformance is possible, in which "canonical equivalances"
  11188. are handled via algorithms and databases, at some (perhaps considerable) cost
  11189. in performance, since a fair amount of additional code must be executed for
  11190. every character during data transfer (database lookup, sorting of combining
  11191. sequences into canonical order, etc).  This can be added in future releases if
  11192. there is a need (but in many cases, pre- and postpostprocessing might be a
  11193. better option).
  11194.  
  11195. Within these constraints, Kermit converts between the UCS and its other
  11196. character sets.  For example, a mixture of Russian and English (and/or Dutch,
  11197. or Latin) text can bet converted between the UCS and ISO Latin/Cyrillic or
  11198. KOI-8.  But since Kermit does not presently support Arabic character-set
  11199. conversion, the new availability of UCS conversion does not mean that Kermit
  11200. can convert from Arabic UCS text to some other character set, because Kermit
  11201. does not support any other character set that includes Arabic.  Ditto for
  11202. Thai, Armenian, Georgian, Tibetan, Chinese, Korean, etc.  However, Kermit CAN
  11203. convert Arabic (or any other script) between UCS-2 and UTF-8.
  11204.  
  11205. Considering Cyrillic more carefully, note that the UCS also contains numerous
  11206. Cyrillic characters not found in any of the Cyrillic sets (ISO Latin/Cyrillic,
  11207. KOI8, CP866, etc) that Kermit supports; characters needed for Abkhasian,
  11208. Yakut, Tatar, Bashkir, Altaic, Old Church Slavonic, etc; UCS text containing
  11209. any of these historic or "extended" Cyrillic characters can not be converted
  11210. to any of Kermit's current single-byte Cyrillic sets without loss.  The
  11211. situation is similar for Greek, Hebrew, etc, and even worse for Japanese
  11212. since Unicode contains thousands of Kanjis that are lacking from the Japanese
  11213. character sets based on JIS X 0208, such as EUC-JP, JIS-7, and Shift-JIS.
  11214.  
  11215. In general, when converting from UCS to a single-byte set, there is always the
  11216. possibility of data loss, just as there is when converting from any larger set
  11217. to a smaller one.  For example, if a UCS file contains Devanagari characters,
  11218. these characters will be lost when converting to (say) Latin-1, just as Roman
  11219. vowels with acute accents are lost when converting from Latin-1 (an 8-bit set)
  11220. to German ISO 646 (a 7-bit set).
  11221.  
  11222. 6.6.5. Kermit's Unicode Features
  11223.  
  11224. C-Kermit can convert between UCS-2 or UTF-8 and any of its other character
  11225. sets, and also between UCS-2 and UTF-8.  When converting between UCS-2 or
  11226. UTF-8 and a non-Unicode character set (such as Latin-1), the UCS Line
  11227. Separator (LS, U+2028) and Paragraph Separator (PS, U+2029) characters are
  11228. converted to the appropriate line terminator (CR, LF, or CRLF).  When
  11229. converting from a non-Unicode set to UCS-2 or UTF-8, however, line terminators
  11230. are not converted to LS or PS.  This is in accordance with the recommendations
  11231. of Unicode Technical Report #13.
  11232.  
  11233. When C-Kermit starts, it tests the native byte order of the computer.  You can
  11234. see the result in the SHOW FEATURES or SHOW FILE display.  It's also available
  11235. in the variable \v(byteorder): 0 means Big Endian, 1 means Little Endian.
  11236.  
  11237. When UCS-2 is involved in file transfer or translation, the following commands
  11238. tell C-Kermit what to do about byte order:
  11239.  
  11240. SET FILE UCS BYTE-ORDER { BIG-ENDIAN, LITTLE-ENDIAN }
  11241.   This is for reading UCS-2 files that don't have a BOM, and also for
  11242.   writing UCS-2 files.  If this command is not given, the machine's native
  11243.   byte order is used when writing UCS-2 files, and also when reading UCS-2
  11244.   files that don't have a BOM.
  11245.  
  11246. SET FILE UCS BOM { ON, OFF }
  11247.   This setting is used when creating UCS-2 files.  A BOM is added at the
  11248.   beginning by default.  Use OFF to not add the BOM.  This command has
  11249.   no affect when writing files.
  11250.  
  11251. COPY /SWAP-BYTES <sourcefile> <destinationfile>
  11252.   Use this for fixing a UCS-2 file whose bytes are in the wrong order.
  11253.  
  11254. Use SHOW FILE to display the FILE UCS settings.
  11255.  
  11256. Please note, again, that C-Kermit's user interface, including its script
  11257. language, is not internationalized in any way.  String comparisons, case
  11258. conversion, and so on, work only for US ASCII (comparisons for equality work
  11259. with other sets, but not lexically-greater-or-less-than or caseless
  11260. comparisons; even comparisons for equality can fail when composed characters
  11261. or byte order are involved).  String functions such as \findex() and
  11262. \fsubstring() that reference byte positions do just that; they won't work with
  11263. UTF-8 text that contains any non-ASCII characters, and they will not work with
  11264. UCS-2 text at all since they use C strings internally, which are
  11265. NUL-terminated.  These are just a few examples to illustrate that neither
  11266. Unicode nor any other character-set beyond ASCII is supported at the
  11267. user-interface, command, or scripting level in this version of C-Kermit.
  11268.  
  11269. 6.6.5.1. File Transfer
  11270.  
  11271. Kermit supports both UCS-2 and UTF-8 as file and transfer character sets
  11272. in text-mode file transfer.
  11273.  
  11274. To select UCS-2 or UTF-8 as a file character-set, use:
  11275.  
  11276.   SET FILE CHARACTER-SET { UCS2, UTF8 }
  11277.  
  11278. If you want to send a UCS-2 text file (or save an incoming file in UCS-2
  11279. format), tell Kermit to:
  11280.  
  11281.   SET FILE CHARACTER-SET UCS2
  11282.  
  11283. and if you want to send a UTF-8 text file (or store an incoming file in
  11284. UTF-8 format), tell Kermit to:
  11285.  
  11286.   SET FILE CHARACTER-SET UTF8
  11287.  
  11288. When sending UCS-2 files, Kermit determines the byte order from the BOM, if
  11289. there is one (and if there is a BOM, it is stripped, i.e. not sent).  If there
  11290. is no BOM, the byte order is the one specified in the most recent SET FILE UCS
  11291. BYTE-ORDER command, if any, otherwise the computer's native byte order is
  11292. assumed.  When storing incoming files as UCS-2, the byte order is according
  11293. SET FILE UCS BYTE-ORDER, if given, otherwise the native one; a BOM is written
  11294. according to SET FILE UCS BOM.
  11295.  
  11296. A transfer character-set should be chosen that includes all of the characters
  11297. in the source file.  So, for example, if you are sending a UCS-2 file
  11298. containing only German-language text, your transfer character-set can be
  11299. Latin-1, Latin-2, Latin-9, UCS-2, or UTF-8.  But if you are sending a file
  11300. that contains a combination of Hebrew and Greek, your transfer character-set
  11301. must be UCS-2 or UTF-8 if you don't want to lose one script or the other.
  11302. Furthermore, the transfer character-set must be one that is supported by the
  11303. receiving Kermit program.  Since UCS support is new, it is possible that the
  11304. other Kermit program (if it supports character sets at all) does not support
  11305. it, but does support single-byte sets such as Latin-1, Latin/Cyrillic, etc.
  11306.  
  11307. To select UCS-2 or UTF-8 as a transfer character-set, use:
  11308.  
  11309.   SET TRANSFER CHARACTER-SET { UCS2, UTF8 }
  11310.  
  11311. It is up to the receiving Kermit program to convert the transfer format to its
  11312. own local format, if necessary.  If it does not understand the UTF-8 or UCS-2
  11313. transfer character-set, and your file can not be adequately represented by any
  11314. single-byte transfer character-set (such as Latin-1 or Latin/Cyrillic) then,
  11315. if UTF-8 format is acceptable on the receiving computer, use UTF-8 as the
  11316. transfer character-set, with the receiver told to "set unknown-char keep", or
  11317. with the sender told to "set attribute char off".  If you want the file to be
  11318. stored in UCS-2 format at the receiver, send it it binary mode if the source
  11319. file is also UCS-2, or else use the TRANSLATE command (next section) to
  11320. convert it to UCS-2 first, then send it in binary mode.  You should not use
  11321. UCS-2 as a transfer character-set in text-mode transfers to Kermit programs
  11322. that don't support it, because they are likely to corrupt the result the same
  11323. way FTP would (see the final paragraph of this section).
  11324.  
  11325. When UCS-2 is the transfer character set, it always goes into Kermit packets
  11326. in Big Endian format, with no BOM.  As always, the transfer character-set is
  11327. announced by the sender to the receiver.  The announcement for UCS-2 is "I162"
  11328. (ISO Registration 162 = UCS-2 Level 1) and by definition it is Big Endian (the
  11329. standards say that when UCS-2 is serialized into bytes, the order must be Big
  11330. Endian).  The announcement for UTF-8 is "I190" (UTF-8 Level 1).
  11331.  
  11332. When receiving a file whose transfer character-set is UCS-2 or UTF-8, you must
  11333. choose the appropriate file character set for the result.  There is no way
  11334. Kermit can do this for you automatically, since UCS data can be in any script
  11335. at all, or any combination.
  11336.  
  11337. In general, UTF-8 or UCS-2 should be chosen as a transfer character-set if the
  11338. source file is also encoded in some form of UCS and it contains more than one
  11339. script.  But there are other situations where where UTF-8 or UCS-2 offer
  11340. advantages.  For example, suppose the source file is on a NeXTstation and the
  11341. destination file is on VMS.  Both the NeXT and the DEC Multinational character
  11342. sets include the French OE digraph, but Latin-1 does not.  Therefore French
  11343. words containing this character might not arrive intact when Latin-1 is the
  11344. transfer character-set, but will with UTF-8 or UCS-2, since the UCS includes
  11345. the OE digraph (but so does Latin-9).
  11346.  
  11347. UCS-2 should be chosen as a transfer character-set only for Japanese text
  11348. files that contain a large preponderance of Kanji, since in this case (and
  11349. only this case) UCS-2 (two bytes per Kanji) is more efficient than UTF-8
  11350. (threeábytes per Kanji).  The same will be true for Chinese and Korean when
  11351. they are supported by Kermit.  UCS-2 should never be used as a transfer
  11352. character-set with a transfer partner that does not support UCS-2 since this
  11353. can cause file corruption (see last paragraph in this section).
  11354.  
  11355. Note that Kermit's repeat-count compression is 100% ineffective for UCS-2,
  11356. and is also ineffective for multibyte characters in UTF-8 and EUC-JP; this is
  11357. because repeat-compression is a transport-level mechanism that operates on
  11358. a per-byte basis; it has no knowledge of the distinction between a byte and
  11359. a character.
  11360.  
  11361. When C-Kermit starts, it sets up associations (Section 6.5) for incoming files
  11362. whose transfer character sets are UCS-2 or UTF-8 appropriately for the
  11363. platform so that the file character-set for the incoming file is UCS-2 in
  11364. Windows and UTF-8 elsewhere.  Otherwise, C-Kermit does not make any default
  11365. associations for UCS-2 or UTF-8, but of course you may add or change
  11366. associations to suit your needs and preferences by including the appropriate
  11367. ASSOCIATE commands in your Kermit startup file.  For example, if you are a PC
  11368. user and deal only with text written in Greek and English, you can:
  11369.  
  11370.   ASSOCIATE TRANSFER-CHARACTER-SET UTF8 CP869
  11371.   ASSOCIATE TRANSFER-CHARACTER-SET UCS2 CP869
  11372.   ASSOCIATE FILE-CHARACTER-SET CP869 UTF8
  11373.  
  11374. Note that when file transfer involves conversion between a single-byte
  11375. character set and UCS-2 or UTF-8, the file-transfer thermometer and estimated
  11376. time left might be inaccurate, since they are based on the source file size,
  11377. not the transfer encoding.  This is purely a cosmetic issue and does not
  11378. effect the final result.  (And is not, strictly speaking, a bug; Kermit
  11379. protocol presently includes no method for the sender to furnish an "estimated
  11380. transfer size" to the receiver, and in any case any such guess could be as
  11381. far off as the file size, given the many other factors that come into play,
  11382. such as compression and prefixing).
  11383.  
  11384. A caution about FTP and UCS-2.  As noted previously, if you transfer a UCS-2
  11385. file with FTP in binary mode between two computers with opposite Endianness,
  11386. the result will have its bytes in the wrong order.  However, if you use FTP to
  11387. transfer a UCS-2 file in "ascii" (text) mode to ANY computer, even if it is
  11388. identical to yours, the result will be corrupted because FTP's line-terminator
  11389. conversions do not account for UCS-2.  The same holds when sending from a
  11390. UCS-aware Kermit program to an older Kermit program in text mode with a
  11391. transfer character-set of UCS-2.  So use UCS-2 as a transfer character-set
  11392. ONLY with a UCS-2-aware Kermit partner.
  11393.  
  11394. 6.6.5.2. The TRANSLATE Command
  11395.  
  11396. In Kermit versions that have Unicode support included, TRANSLATE now always
  11397. goes through Unicode; that is, the source set is converted to UCS-2 and thence
  11398. to the target set.  This is a major improvement, since in prior releases,
  11399. C-Kermit had to pick the "most appropriate" transfer character-set as the
  11400. intermediate set, and this would result in the loss of any characters that the
  11401. source and target sets had in common but were lacking from the intermediate
  11402. set (for example the OE digraph when translating from NeXT to DEC MCS through
  11403. Latin-1).  This never happens when Unicode is the intermediate set because
  11404. Unicode is a superset of all other character sets supported by Kermit.  A more
  11405. dramatic example would be translation between Cyrillic PC code page 866 and
  11406. KOI8-R (Section 6.4); formerly all the line- and box-drawing characters would
  11407. be lost (since ISO 8859-5 does not have any); now the ones that these two sets
  11408. have in common are preserved.
  11409.  
  11410. UCS-2 and UTF-8 are now both supported as source-file and destination-file
  11411. character sets by C-Kermit's TRANSLATE command, for example:
  11412.  
  11413.   translate oofa.txt ucs2 latin1 oofa-l1.txt
  11414.  
  11415. translates oofa.txt from UCS-2 to Latin-1, storing the result as oofa-l1.txt
  11416. Similarly:
  11417.  
  11418.   translate oofa.txt utf8 latin1 oofa-l1.txt
  11419.   translate oofa.txt latin1 ucs2 oofa-ucs2.txt
  11420.   translate oofa.txt latin1 utf8 oofa-utf8.txt
  11421.   translate oofa.txt ucs2 utf8 oofa-utf8.txt
  11422.   translate oofa.txt utf8 ucs2 oofa-ucs2.txt
  11423.  
  11424. Treatment of the UCS-2 BOM is exactly the same as for file transfer.  Note
  11425. that if a UCS-2 source file is in the "wrong" byte order and lacks a BOM, and
  11426. you don't tell Kermit about it with SET FILE UCS BYTE-ORDER, the result of the
  11427. translation is total gibberish.  Recall that you can use COPY /SWAP-BYTES to
  11428. switch the byte order of an errant UCS-2 file (or any other file for that
  11429. matter, if you can think of a reason to).  Also note that:
  11430.  
  11431.   translate oofa.txt ucs2 ucs2 new.txt
  11432.  
  11433. Produces a result in the native (or SET FILE UCS) byte-order as long as
  11434. oofa.txt has a BOM.
  11435.  
  11436. As a side benefit of the Unicode work, the TRANSLATE command now works
  11437. for the first time also for all Japanese character sets that Kermit supports.
  11438. In other words, if you have a Japanese text file in any of the following
  11439. encodings:
  11440.  
  11441.   EUC-JP
  11442.   Shift-JIS
  11443.   JIS-7
  11444.   UCS-2
  11445.   UTF-8
  11446.  
  11447. You can use the TRANSLATE command to convert to any other encoding from the
  11448. same list.
  11449.  
  11450. 6.6.5.3. Terminal Connection
  11451.  
  11452. The CONNECT command now allows UTF-8 as a local or remote terminal
  11453. character-set:
  11454.  
  11455.   SET TERMINAL CHARACTER-SET { ..., UTF8 } { ..., UTF8 }
  11456.   SET TERMINAL REMOTE-CHARACTER-SET { ..., UTF8 }
  11457.   SET TERMINAL LOCAL-CHARACTER-SET { ..., UTF8 }
  11458.  
  11459. (Recall that Kermit's terminal character-set has two "ends" -- the set used
  11460. on the host to which Kermit is connected, and the set used on the local
  11461. keyboard and screen.)
  11462.  
  11463. UCS-2 is not supported as a terminal character-set (either end) since (a) it
  11464. is not used that way anywhere to our knowledge, and (b) the problems of
  11465. Endianness and the high likelihood of loss of synchronization make it
  11466. impractical.  (Telecommunications is byte-oriented; if one byte, or any odd
  11467. number of bytes, is lost because of buffer overruns, circuit resets, etc (or
  11468. likewise if a burst of noise appears that takes the guise of an odd number of
  11469. bytes), the byte order of the subsequent data stream will be backwards; unlike
  11470. UTF-8 and traditional byte-based character sets, UCS-2 is not "self
  11471. synchronizing".)
  11472.  
  11473. UTF-8 does not have byte-order or synchronization problems and is growing in
  11474. popularity as a terminal character set as well as in other application areas.
  11475. It allows a single terminal session to use multiple scripts (Roman, Cyrillic,
  11476. Greek, etc) without ISO 2022 character-set switching (which terminal emulators
  11477. like Kermit 95 can handle but few host applications understand or use), and
  11478. meshes nicely with the Unicode screen fonts that are beginning to appear.
  11479.  
  11480. UTF-8 was first used in Plan 9 and soon will be available in Linux.  It will
  11481. probably spread from there (Unicode in some form is, of course, also used in
  11482. Windows NT, but only internally -- not for access from outside).
  11483.  
  11484. To use UTF-8 or any other character set that uses 8-bit bytes in your terminal
  11485. session, be sure to tell C-Kermit to:
  11486.  
  11487.   SET TERMINAL BYTESIZE 8
  11488.   SET COMMAND BYTESIZE 8
  11489.   SET PARITY NONE
  11490.  
  11491. (or use the shortcut command, EIGHTBIT, which does all three at once).
  11492.  
  11493. In a setup where your local Kermit program uses a single-byte character set
  11494. such as PC Code Page 850 and the remote host uses UTF-8:
  11495.  
  11496.   SET TERM CHAR UTF8 CP850
  11497.  
  11498. or:
  11499.  
  11500.   SET TERM REMOTE CHAR UTF8
  11501.   SET TERM LOCAL CHAR CP850
  11502.  
  11503. all works as expected.  UTF-8 text on the remote displays correctly on your
  11504. screen, and when you type CP850 characters, they are translated to UTF-8
  11505. sequences for transmission, and the echo from the host is translated from
  11506. UTF-8 back to CP850.  Telnet negotiations and autodownload take place before
  11507. any character-set translation and work as before.  The session log (if text
  11508. mode was selected for it) contains only the local terminal character-set.
  11509. And so on.
  11510.  
  11511. Kermit merely supplies translations from UTF-8 to your local terminal
  11512. character-set (this includes treating UTF-8 Line Separator and Paragraph
  11513. separator as CRLF).  However, Kermit does does not, at present, perform
  11514. "canonicalization" of composed sequences, nor does it automatically execute
  11515. bidirectionality algorithms for display of mixed-direction text (e.g. Hebrew
  11516. and English).  Such presentation issues, like all others in the terminal-host
  11517. regime, are left to the host.
  11518.  
  11519. By the way, C-Kermit also allows UTF-8 to be the local end of the terminal
  11520. character-set, but so far this code is not tested, since we don't have a UTF-8
  11521. console or terminal to work with.  However, it can be stated without doubt
  11522. that C-Kermit's key mapping will not work for UTF-8 values, since (a) the key
  11523. map is indexed by 8-bit byte values and (b) C-Kermit reads keystrokes a byte
  11524. at a time (these comments do not apply to K95, which has direct access to the
  11525. keyboard and can read "wide" keycodes and uses them to index a "wide" keymap).
  11526.  
  11527. Restrictions: As noted, the CONNECT command does not support UCS-2 as a REMOTE
  11528. TERMINAL character-set.  Neither does it support the Japanese sets EUC-JP,
  11529. JIS-7, and Shift-JIS.  Support for the Japanese sets (and possibly Chinese and
  11530. Korean too) might be added in a future release.  Since the TRANSMIT command
  11531. (next section) uses the same REMOTE TERMINAL character-sets as the CONNECT
  11532. command, it has the same restrictions.
  11533.  
  11534. 6.6.5.4. The TRANSMIT Command
  11535.  
  11536. As described in Chapter 15 of "Using C-Kermit" and Section 4.21 of this
  11537. document, the TRANSMIT command can be used to upload a file without protocol,
  11538. more or less as if you were typing it on your keyboard while connected to the
  11539. host.  When TRANSMITting in text mode, the file's character set is converted
  11540. to the host's unless you have SET TERMINAL CHARACTER-SET TRANSPARENT, or you
  11541. include the new TRANSMIT switch, /TRANSPARENT.
  11542.  
  11543. Before C-Kermit 7.0, the file character-set was assumed to be the same as the
  11544. local end of the terminal character-set, and the TRANSMIT command used the
  11545. same translations as the CONNECT command, ignoring the file character-set.
  11546.  
  11547. In C-Kermit 7.0, that assumption (a poor one to begin with) can no longer be
  11548. made, since UCS-2 can be a file character-set but not a terminal
  11549. character-set.  So now the file's character-set is given by your most recent
  11550. SET FILE CHARACTER-SET command.  The host's character set is the remote end of
  11551. your most recent SET TERMINAL CHARACTER-SET command:
  11552.  
  11553.   SET TERMINAL CHARACTER-SET <remote-set> [ <local-set> ]
  11554.  
  11555. or:
  11556.  
  11557.   SET TERMINAL REMOTE-CHARACTER-SET <remote-set>
  11558.  
  11559. The TRANSMIT command converts each source-file character from the FILE
  11560. character-set to the REMOTE TERMINAL character-set, and then transmits the
  11561. translated characters according to your SET TRANSMIT preferences (Chapter 15).
  11562.  
  11563. If you have SET TRANSMIT ECHO ON, and the host is echoing the transmitted
  11564. characters, the echos are converted from the remote terminal character-set to
  11565. the local terminal character-set.
  11566.  
  11567.   [ A picture would help... ]
  11568.  
  11569. Confused?  Let's work through an example.  Suppose your local computer is a
  11570. NeXTstation, on which text files are encoded in the NeXT character set, and
  11571. that the remote computer is a Data General AViiON, which uses the Data General
  11572. International character set.  Further suppose that you are logged in to the
  11573. NeXT from a VT220 terminal which uses the DEC Multinational character set.
  11574.  
  11575. You need to convert the file from NeXT encoding to DG encoding and convert the
  11576. echoes from DG encoding to DEC encoding.  So on the NeXT, tell C-Kermit to:
  11577.  
  11578.   eightbit
  11579.   set file character-set next
  11580.   set term character-set dg-international dec-mcs
  11581.   transmit /text nextdata.txt
  11582.  
  11583. (This assumes you have some sort of collection process already set up on the
  11584. Data General, such as a text editor or the venerable "cat > foo".  The
  11585. EIGHTBIT command is equivalent to SET TERMINAL BYTESIZE 8, SET COMMAND
  11586. BYTESIZE 8, SET PARITY NONE.)
  11587.  
  11588. To further complicate matters, suppose your local terminal character set is
  11589. the same as the remote one, so you don't need terminal character-set
  11590. translation, but you need to TRANSMIT a file that is in a different character
  11591. set and you want it translated to the host set.  In this case, use SET TERM
  11592. CHARACTER-SET to actually specify the character set used on each end, rather
  11593. than specifying TRANSPARENT:
  11594.  
  11595.   eightbit
  11596.   set file character-set ucs2
  11597.   set term character-set latin1 latin1
  11598.   transmit /text ucs2data.txt
  11599.  
  11600. The distinction between:
  11601.  
  11602.   SET TERMINAL CHARACTER-SET xxx yyy
  11603.  
  11604. (where xxx and yyy are the same set) and:
  11605.  
  11606.   SET TERMINAL CHARACTER-SET TRANSPARENT
  11607.  
  11608. is new to C-Kermit 7.0, but affects only the TRANSMIT command.
  11609.  
  11610. The TRANSMIT command currently does nothing special with UCS-2/UTF-8 Line and
  11611. Paragraph Separator characters; more experience is required to find out how
  11612. these behave in a genuine Unicode terminal-host setting.
  11613.  
  11614. Restrictions: As noted, the TRANSMIT command translates from the FILE
  11615. character-set to the REMOTE TERMINAL character-set.  This rules out
  11616. translations to any character set that is not supported as a REMOTE TERMINAL
  11617. character-set, such as UCS-2, EUC-JP, JIS-7, and Shift-JIS.
  11618.  
  11619. 6.6.5.5. Summary of Kermit Unicode Commands
  11620.  
  11621. Specifying file character-set and byte order:
  11622.   SET FILE CHARACTER-SET { ..., UCS2, UTF8 }
  11623.   REMOTE SET FILE CHARACTER-SET { ..., UCS2, UTF8 } (See next section)
  11624.   SET FILE UCS BOM { ON, OFF }
  11625.   SET FILE UCS BYTE-ORDER { BIG-ENDIAN, LITTLE-ENDIAN }
  11626.  
  11627. Specifying the transfer character-set:
  11628.   SET TRANSFER CHARACTER-SET { ..., UCS-2, UTF-8 }
  11629.   REMOTE SET TRANSFER CHARACTER-SET { ..., UCS-2, UTF-8 }
  11630.  
  11631. Specifying the terminal character-set:
  11632.   SET TERMINAL CHARACTER-SET { ..., UTF8 } { ..., UTF8 }
  11633.   SET TERMINAL REMOTE-CHARACTER-SET { ..., UTF8 }
  11634.   SET TERMINAL LOCAL-CHARACTER-SET { ..., UTF8 }
  11635.  
  11636. Displaying settings:
  11637.   SHOW FILE
  11638.   SHOW TRANSFER
  11639.   SHOW TERMINAL
  11640.   SHOW CHARACTER-SETS
  11641.  
  11642. Commands that use these settings include:
  11643.   SEND, RECEIVE, GET, etc.
  11644.   CONNECT
  11645.   TRANSMIT
  11646.   LOG SESSION
  11647.  
  11648. Converting files:
  11649.   TRANSLATE <infile> { ..., UCS-2, UTF-8 } { ..., UCS-2, UTF-8 } <outfile>
  11650.   COPY /SWAP-BYTES <infile> <outfile>
  11651.  
  11652. 6.7. Client/Server Character-Set Switching
  11653.  
  11654. A simple mechanism has been added to allow the client to change the server's
  11655. FILE CHARACTER-SET:
  11656.  
  11657. REMOTE SET FILE CHARACTER-SET <name>
  11658.   The client asks the server to change its file character-set to the one
  11659.   given.  The <name> must match one of the server's file character-set names.
  11660.   For convenience, C-Kermit uses its own file character-set keyword list for
  11661.   parsing this command so you can use ? for help and Tab or Esc for completion.
  11662.   However, since the server might have a different repertoire (or even use
  11663.   different names for the same sets), C-Kermit accepts any string you supply
  11664.   and sends it to the server.  The server, if it supports this command
  11665.   (C-Kermit 7.0 and K95 1.1.18 do), sets its file character-set as requested,
  11666.   and also disables automatic character-set switching (Section 6.5).  If the
  11667.   server does not support this command or if it does not support the given
  11668.   character set, the REMOTE SET FILE CHARACTER-SET command fails.
  11669.  
  11670. Here's an example that sends a Japanese text file encoded in Shift-JIS to
  11671. a server using every combination of Kermit's Japanese-capable file and
  11672. transfer character sets:
  11673.  
  11674. dcl \&x[] = euc ucs2 utf8             ; transfer character-sets
  11675. dcl \&y[] = eu uc ut                  ; 2-letter abbreviations for them
  11676. dcl \&f[] = shift euc jis7 ucs2 utf8  ; file character-sets
  11677. dcl \&g[] = sj eu j7 uc ut            ; 2-letter abbreviations
  11678.  
  11679. set file char shift-jis               ; local file character-set is Shift-JIS
  11680. for \%i 1 \fdim(&x) 1 {               ; for each transfer character-set...
  11681.     set xfer char \&x[\%i]            ; set it
  11682.     for \%j 1 \fdim(&f) 1 {           ; for each remote file character-set...
  11683.     remote set file char \&f[\%j] ; set it
  11684.         if fail exit 1 SERVER REJECTED CHARSET
  11685.         send /text meibo-sj.html meibo-sj-\&y[\%i]-\&g[\%j].txt ; send the file
  11686.         if fail exit 1 TRANSFER FAILED
  11687.     }
  11688. }
  11689.  
  11690. The Kermit-370 server does not support REMOTE SET FILE CHARACTER-SET, but
  11691. since it supports REMOTE KERMIT commands, you can get the same effect with
  11692. REMOTE KERMIT SET FILE CHARACTER-SET <name>.
  11693.  
  11694.  
  11695. (7) SCRIPT PROGRAMMING
  11696.  
  11697. (Also see Section 2.8, Scripting Local Programs.)
  11698.  
  11699. 7.0. Bug Fixes
  11700.  
  11701. The following script programming bugs were fixed in C-Kermit 7.0:
  11702.  
  11703.  . IF EXIST and IF DIRECTORY were fixed to properly strip braces from around
  11704.    their arguments, so "if directory {C:\Program Files}", etc, would work as
  11705.    expected.  However, this means that if the file or directory name is
  11706.    actually enclosed in braces, the braces must be doubled.
  11707.  
  11708.  . The READ command did not fail if the READ file wasn't open; now it does.
  11709.  
  11710.  . The READ command refused to read the last or only line of a file if it did
  11711.    not end with a proper line terminator; now it does.
  11712.  
  11713.  . The END command, when given from within a SWITCH statement, did not exit
  11714.    from the current macro or command file; instead it just terminated the
  11715.    SWITCH.
  11716.  
  11717. 7.1. The INPUT Command
  11718.  
  11719. 7.1.1. INPUT Timeouts
  11720.  
  11721. The description of the INPUT command on page 422 fails to mention the
  11722. following two points about the timeout (which apply to C-Kermit 6.0 and later):
  11723.  
  11724.  1. "INPUT -1 text" (or "INPUT \%x text", where \%x is any variable whose
  11725.     value is -1 or less) means "wait forever".  This form of the INPUT command
  11726.     fails only if it is interrupted, since it will never time out.
  11727.  
  11728.  2. INPUT 0 performs a nonblocking read of material that has already arrived
  11729.     but has not yet been read, and succeeds immediately if the target string
  11730.     is found, or fails immediately if it is not found.
  11731.  
  11732. The same points apply to MINPUT.  REINPUT ignores its timeout parameter.
  11733.  
  11734. 7.1.2. New INPUT Controls
  11735.  
  11736. The following new INPUT controls were added in version 7.0:
  11737.  
  11738. SET INPUT AUTODOWNLOAD { ON, OFF }
  11739.   Explained in section 7.7.
  11740.  
  11741. SET INPUT CANCELLATION { ON, OFF }
  11742.   This governs whether an INPUT command can be canceled by "pressing any key"
  11743.   on the keyboard.  Normally it can be, in which case the INPUT command fails
  11744.   immediately and \v(instatus) is set to 2, indicating interruption.  SET INPUT
  11745.   CANCELLATION OFF disables keyboard cancellations; thus if the search text is
  11746.   not encountered, the INPUT command will run for its entire timeout interval.
  11747.   SET INPUT CANCELLATION OFF does not disable interruption by Ctrl-C, however;
  11748.   every command needs an emergency exit.  (If you really want to disable
  11749.   interruption by Ctrl-C, use SET COMMAND INTERRUPTION OFF.)
  11750.  
  11751. Also see Section 7.2 for any new variables related to INPUT.
  11752.  
  11753. 7.1.3. INPUT with Pattern Matching
  11754.  
  11755. C-Kermit 7.0 allows INPUT, MINPUT, and REINPUT targets to be a pattern
  11756. (explained in Sections 1.19 and 4.9).  This solves a long-standing problem
  11757. illustrated by the following scenario: a certain company has a bank of TCP/IP
  11758. modem servers, with hostnames server1, server2, server3, and so on.  Each
  11759. server's prompt is its name, followed by a colon (:), for example "Server72:".
  11760. Without INPUT patterns, it would be rather difficult to wait for the prompt.
  11761. The brute force approach:
  11762.  
  11763.   minput 20 Server1: Server2: Server3: ... (enumerating each one)
  11764.  
  11765. is subject to failure whenever a new server is added.  A more subtle approach:
  11766.  
  11767.   input 20 Server
  11768.   if fail ...
  11769.   input 2 :
  11770.  
  11771. is liable to false positives, e.g. "Welcome to the XYZ Corp Modem Server.
  11772. Please read the following message:"...
  11773.  
  11774. With patterns, you can match the prompt with "Server*:" (which doesn't solve
  11775. the "false positives" problem, but certainly is more compact than the brute
  11776. force method), or with more specific patterns such as "Server[1-9]:" and
  11777. "Server[1-9][0-9]:", or equivalently:
  11778.  
  11779.   Server{[1-9],[1-9][0-9]}:
  11780.  
  11781. meaning the word "Server" followed by a single digit (1-9) or by two digits
  11782. representing a number from 1 to 99, followed by a colon.
  11783.  
  11784. INPUT pattern matching has been added in a way that does not interfere with
  11785. existing scripts.  No new commands or switches are used.  The simple rule is:
  11786. if an INPUT search target is the argument of the (new) \fpattern() function,
  11787. it is a pattern.  Otherwise it is taken literally, as before.  For example:
  11788.  
  11789.   input 5 a*b
  11790.  
  11791. searches for an 'a' followed by an asterisk ('*'), followed by a 'b'.  But:
  11792.  
  11793.   input 5 \fpattern(a*b)
  11794.  
  11795. searches for an 'a' followed by anything at all up to and including the first
  11796. 'b'.  This means that any search target to INPUT, MINPUT, or REINPUT can be a
  11797. pattern or a literal string, and in particular that MINPUT can accommodate any
  11798. mixture of patterns and literal strings.
  11799.  
  11800. In selecting patterns, note that:
  11801.  
  11802.  . A leading '*' is always implied so there is no need to include one.
  11803.  . A trailing '*' is meaningless and ignored.
  11804.  . A '*' by itself matches the first character that arrives.
  11805.  
  11806. A syntax note: If your pattern is a selection list, meaning a list of
  11807. alternatives separated by commas and enclosed in braces, then the outer braces
  11808. will be stripped by various levels of parsers, so you must include three of
  11809. each:
  11810.  
  11811.   input 10 \fpattern({{{abc,mno,xyz}}})
  11812.  
  11813. Note that this is equivalent to:
  11814.  
  11815.   minput 10 abc mno xyz
  11816.  
  11817. except for the setting of the \v(minput) variable.
  11818.  
  11819. And a caution: INPUT pattern matching has a limitation that you probably never
  11820. noticed with literal-string matching, namely that there is a limit on the size
  11821. of the match.  For example, if the pattern is "a*b", the match will succeed
  11822. if the 'a' and 'b' are not separated by more than (say) 8K bytes, but will
  11823. fail if they are farther apart than that.  In such cases, it better to use
  11824. two INPUTs (e.g. "input 10 a" and then "input 100 b").
  11825.  
  11826. 7.1.4. The INPUT Match Result
  11827.  
  11828. The result of any INPUT, MINPUT, or REINPUT command, no matter whether the
  11829. search targets are patterns or literal strings, is available in the new
  11830. \v(inmatch) variable.  For example:
  11831.  
  11832.   minput 10 cat \fpattern([dh]og)
  11833.   if success echo MINPUT matched "\v(inmatch)"
  11834.  
  11835. This is especially useful when a pattern was matched, since it makes the
  11836. string that matched the pattern available to Kermit; there would be no way
  11837. to get it otherwise.
  11838.  
  11839. After an INPUT command, you can view all the INPUT-related variables by
  11840. typing "show variables in" (abbreviate as "sho var in"), which shows the
  11841. values of all built-in variables whose names start with "in".
  11842.  
  11843. 7.2. New or Improved Built-In Variables
  11844.  
  11845. \v(blockcheck) - Current BLOCK-CHECK setting, 1, 2, 3, or 4.  4 is the
  11846.                  code for BLANK-FREE-2.
  11847.  
  11848. \v(byteorder)  - The machine's byte order: 0 = Big Endian, 1 = Little Endian.
  11849.  
  11850. \v(cmdbufsize) - The length of the command buffer, which is the maximum
  11851.                  size for a macro, a command, a variable, or anything else
  11852.                  in C-Kermit's script language.
  11853.  
  11854. \v(ctty)       - The device name of C-Kermit's controlling (login) terminal.
  11855.  
  11856. \v(filename)   - Described in Sections 4.1 and 4.2.
  11857. \v(filenumber) - Described in Sections 4.1 and 4.2.
  11858.  
  11859. \v(filespec)   - As of C-Kermit 7.0, contains fully qualified filenames rather
  11860.                  than (usually) relative ones.
  11861.  
  11862. \v(return)     - Now holds the END <n> value of the macro that most recently
  11863.                  returned, in case END was used rather than RETURN.
  11864.  
  11865. \v(editor)     - Pathname of preferred text editor
  11866. \v(editopts)   - Command-line options for editor
  11867. \v(editfile)   - File most recently edited
  11868.  
  11869. \v(browser)    - Pathname of preferred Web browser
  11870. \v(browsopts)  - Command-line options for Web browser
  11871. \v(browsurl)   - URL most recently given to Web browser
  11872.  
  11873. \v(dialtype)   - Type of call most recently placed (see section 2.1.11).
  11874.  
  11875. \v(kbchar)     - The character, if any, that was typed at the keyboard to
  11876.                  to interrupt the most recent PAUSE, SLEEP, WAIT, MSLEEP,
  11877.                  or INPUT command; empty if the most recent such command was
  11878.                  not interrupted from the keyboard.
  11879.  
  11880. \v(lockdir)    - UNIX only - The name of the UUCP lockfile directory, if
  11881.                  known, otherwise "(unknown)".
  11882.  
  11883. \v(lockpid)    - UNIX only - PID of process that owns the communication port
  11884.                  that you tried to open with a SET LINE command that failed
  11885.                  because the port was in use, otherwise empty.  This variable
  11886.                  is set with every SET LINE command.
  11887.  
  11888. \v(cx_time)    - If no connection (SET HOST, SET LINE, DIAL, TELNET, etc)
  11889.                  is active, this is 0.  If a connection is active, this is
  11890.                  the number of seconds since the connection was made.
  11891.  
  11892. \v(hwparity)   - If hardware parity is in effect, this variable gives its
  11893.                  value, such as "even" or "odd" (in which case, the \v(parity)
  11894.                  variable will be "none").  Otherwise this variable is empty.
  11895.  
  11896. \v(serial)     - Current serial port settings in 8N1 format (Section 2.10).
  11897.  
  11898. \v(errno)      - In UNIX, the current value of the C runtime errno variable,
  11899.                  which is quite volatile (meaning that often an "interesting"
  11900.                  error code can be overwritten by some other library call or
  11901.                  system service that sets errno before you have a chance to
  11902.                  look at it).
  11903.                  In VMS, the error code returned by the system or library
  11904.                  call that most recently failed (success codes are not saved).
  11905.                  Not available in other operating systems.
  11906.  
  11907. \v(errstring)  - The UNIX or VMS system error message that corresponds to
  11908.                  \v(errno).  Not available in other OS's.
  11909.                  Also see \ferrstring().
  11910.  
  11911. \v(setlinemsg) - The error message, if any, from the most recent SET LINE,
  11912.                  SET PORT, SET HOST, TELNET, or other connection-making
  11913.                  command.  This is not necessarily the same as \v(errstring)
  11914.                  since these commands might fail without generating a system
  11915.                  error code, for example (in UNIX) because a lockfile existed
  11916.                  indicating the device was assigned by another user.
  11917.  
  11918. \v(exitstatus) - The exit status C-Kermit would return if it exited now.
  11919.  
  11920. \v(pexitstat) -  The exit status of the inferior process most recently invoked
  11921.                  by C-Kermit (by RUN, !, REDIRECT, SEND /COMMAND, etc).  In
  11922.                  VMS, this code can be given to \ferrstring() to get the
  11923.                  corresponding error message (in UNIX, program/command return
  11924.                  codes are not the same as system error codes).  Not available
  11925.                  in operating systems other than UNIX and VMS.  See section
  11926.                  4.2.5 for details.
  11927.  
  11928. \v(inmatch)    - The incoming string of characters, if any, that matched the
  11929.                  most recent INPUT, REINPUT, or MINPUT command.
  11930.  
  11931. \v(intime)     - The number of milliseconds (thousandths of seconds) it took
  11932.                  for the most recent INPUT command to find its match, or -1
  11933.                  if no INPUT command has been given yet.  If the INPUT command
  11934.                  timed out, the value is approximately equal to 1000 times the
  11935.                  INPUT timeout.  If INPUT failed for some other reason, the
  11936.                  value is undefined (\v(instatus) gives INPUT completion
  11937.                  status).  If your version of C-Kermit is built without
  11938.                  high-precision floating-point timers, this number will always
  11939.                  be a multiple of 1000.
  11940.  
  11941. \v(inwait)     - The number of seconds specified as the timeout in the most
  11942.                  recent INPUT command.
  11943.  
  11944. \v(dialsuffix)   Dialing suffix for use during PDIAL sequence; see Section
  11945.                  2.1.10.
  11946.  
  11947. \v(pid)       -  UNIX, VMS, and K95 only.  C-Kermit's primary process ID,
  11948.                  numeric, decimal.  If you want to show it in hex, use
  11949.                  \fn2hex(\v(pid)).  If you want to show it in octal, use
  11950.                  \fn2octal(\v(pid)).
  11951.  
  11952. \v(printer)    - Current printer name or SET PRINTER value.
  11953.  
  11954. \v(p_ctl)      - Control prefix char
  11955. \v(p_8bit)     - 8-bit prefix char (if parity not none)
  11956. \v(p_rpt)      - Repeat prefix char (if repeat compression enabled)
  11957.  
  11958. \v(herald)     - Kermit's version herald
  11959.  
  11960. \v(test)       - Kermit's test version, if any, or 0 if this is not a test
  11961.                  version.  Typical values for test versions are "Alpha.03"
  11962.                  or "Beta.14".
  11963.  
  11964. \v(sendlist)   - The number of entries in the SEND-LIST, 0 if none.  Note:
  11965.                  entries do not necessarily correspond to files, since an
  11966.                  entry might contain wildcards.  Also note that the value does
  11967.                  not go back to 0 after the files in the list are sent.  To
  11968.                  reset this variable, use CLEAR SEND-LIST.  The purpose of
  11969.                  this variable is to determine if a SEND command, when given
  11970.                  without any filenames, will be legal.  Example:
  11971.                    xif \v(sendlist) { send } else { send oofa.txt }
  11972.  
  11973. \v(trigger)    - If the most recent CONNECT session was terminated
  11974.                  automatically by a trigger, this variable contains the
  11975.                  trigger value.
  11976.  
  11977. \v(ty_ln)      - TYPE line number (during TYPE)
  11978. \v(ty_lc)      - TYPE line count  (after TYPE)
  11979. \v(ty_mc)      - TYPE match count (after TYPE)
  11980.  
  11981. \v(xferstat)   - Status of most recent file
  11982.           -1: No transfer yet
  11983.            0: Succeeded
  11984.            1: Failed
  11985.  
  11986. \v(xfermsg)    - If the most recent file transfer failed, this is the reason.
  11987.                  If it succeeded, \v(xfermsg) is an empty string.
  11988.  
  11989. \v(tftime)     - Total elapsed time of most recent file transfer operation,
  11990.                  in seconds.
  11991.  
  11992. \v(textdir)    - Directory that holds (or is supposed to hold) Kermit text
  11993.                  files such as installation instructions, release notes,
  11994.                  update notes, read-me files, "beware" files, etc.
  11995.  
  11996. \v(name)       - The name with which the Kermit program was invoked, e.g.
  11997.                  "kermit", "wermit", "k95", "k2", etc (see section 9.1).
  11998.  
  11999. \v(osname)     - Name of operating system on computer where C-Kermit is
  12000.                  running, obtained at runtime (from uname or equivalent).
  12001.  
  12002. \v(osversion)  - Version of operating system on computer where C-Kermit is
  12003.                  running, obtained at runtime (from uname or equivalent).
  12004.  
  12005. \v(osrelease)  - Release of operating system on computer where C-Kermit is
  12006.                  running, obtained at runtime (from uname or equivalent).
  12007.  
  12008. \v(model)      - The specific hardware model of the computer where C-Kermit
  12009.                  is running, if known.
  12010.  
  12011. \v(math_pi)    - The value of Pi (see Section 7.23)
  12012. \v(math_e)     - The value of e  (see Section 7.23)
  12013. \v(math_precision) - How many significant digits in a floating-point number.
  12014.  
  12015. \v(f_count)    - Result of the most recent FILE COUNT (FCOUNT) command.
  12016. \v(f_error)    - Numeric error code of most recent FILE command.
  12017. \v(f_max)      - Maximum number of files open simultaneously.
  12018.  
  12019. The math constants are given in the precision of underlying computer's
  12020. floating-point arithmetic.
  12021.  
  12022. Note the distinction between \v(osname)-\v(osversion) and \v(platform); the
  12023. latter refers to the platform for which and/or upon which C-Kermit was built,
  12024. as opposed to the one on which it is actually running.  Also note that each
  12025. operating system can, and probably will, interpret and fill in the os*
  12026. variables differently, or not at all.
  12027.  
  12028. The SHOW VARIABLES command now accepts a variable name, prefix, or pattern:
  12029.  
  12030.   show variables         Shows all variables.
  12031.   show variables t       Shows all variables that start with "t".
  12032.   show variables *ver*   Shows all variables whose names contain "ver".
  12033.   show variables *ver    Ditto (an implied "*" is appended).
  12034.  
  12035. 7.3. New or Improved Built-In Functions
  12036.  
  12037. The following new file-i/o functions are explained in Section 1.22.
  12038.  
  12039.   \f_status(channel)           Status of file open on channel
  12040.   \f_pos(channel)              Read/write (byte) pointer of given file
  12041.   \f_line(channel)             Current line of file
  12042.   \f_handle(channel)           Handle of file
  12043.   \f_eof(channel)              Whether given file is at EOF
  12044.   \f_getchar(channel)          Read a char from given file
  12045.   \f_getline(channel)          Read a line from given file
  12046.   \f_getblock(channel,n)       Read a block from given file
  12047.   \f_putchar(channel,c)        Write a char to given file
  12048.   \f_putline(channel,string)   Write a line to given file
  12049.   \f_putblock(channel,string)  Write a block to given file
  12050.  
  12051. The following new date-time-related functions are explained in Section 1.6:
  12052.  
  12053.   \fday()                Returns day of week of given date
  12054.   \fnday()               Returns numeric day of week of given date
  12055.   \ftime()               Returns time portion of given date-time
  12056.   \fntime()              Converts time to seconds since midnight
  12057.   \fn2time()             Converts seconds since midnight to hh:mm:ss
  12058.   \fcvtdate(date-time)   Converts free-format date to yyyymmdd hh:mm:ss
  12059.   \fdayofyear(date-time) Converts date to yyyyddd (day-of-year) format
  12060.   \fdoy(date-time)       Synonym for \fdayofyear()
  12061.   \fdoy2date(dayofyear)  Converts yyyyddd to yyyymmdd
  12062.   \fmjd(date-time)       Converts free-format date to Modified Julian Date
  12063.   \fmjd2date(mjd)        Converts modified Julian date to yyyymmdd
  12064.  
  12065. The new floating-point arithmetic functions are explained in Section 7.23.  f1
  12066. and f2 are floating-point (real) numbers; d is the number of decimal places to
  12067. show:
  12068.  
  12069.   \ffpabsolute(f1,d)     Absolute value of f1
  12070.   \ffpadd(f1,f2,d)       f1 + f1
  12071.   \ffpcosine(f1,d)       Cosine of f1
  12072.   \ffpdivide(f1,f2,d)    f1 divided by f2
  12073.   \ffpexp(f1,d)          e to the f1 power
  12074.   \ffpint(f1)            Integer part of f1
  12075.   \ffplog10(f1,d)        Log base 10 of f1
  12076.   \ffplogn(f1,d)         Natural log of f1
  12077.   \ffpmaximum(f1,f2,d)   Maximum of f1 and f2
  12078.   \ffpminimum(f1,f2,d)   Minimum of f1 and f2
  12079.   \ffpmodulus(f1,f2,d)   Modulus of f1 and f2
  12080.   \ffpmultiply(f1,f2,d)  Product of f1 and f2
  12081.   \ffpraise(f1,f2,d)     Raise f1 to power f2
  12082.   \ffpround(f1,d)        Round f1 to d places
  12083.   \ffpsine(f1,d)         Sine of f1
  12084.   \ffpsqrt(f1,d)         Square root of f1
  12085.   \ffpsubtract(f1,f2,d)  f2 - f1
  12086.   \ffptangent(f1,d)      Tangent of f1
  12087.  
  12088. Integer number functions:
  12089.  
  12090. \fabsolute(n)
  12091.   Absolute value of integer n.
  12092.  
  12093. \frandom(n)
  12094.   Returns a random integer between 0 and n-1.
  12095.  
  12096. \fradix(s,n1,n2)
  12097.   If the string s is an integer in radix n1, the result is the same number
  12098.   expressed in radix n2, where n1 and n2 may be any number from 2 through 36,
  12099.   expressed as decimal numbers, or variables (etc) that evaluate to decimal
  12100.   numbers.  For the source and result, the digits of any radix, r, are the
  12101.   first r characters in the sequence 0-9,a-z (case doesn't matter for the
  12102.   letters).  The string s may have a sign, + or -; if it starts with a minus
  12103.   (-) sign, the result also has a minus sign.
  12104.  
  12105. The \fradix() function does not work with floating-point numbers.  It does not
  12106. reveal the internal storage format of a number; for example, \fradix(-1,10,16)
  12107. is -1, not something like FFFFFFFFFF.  If all three arguments are not given,
  12108. or if n1 or n2 are not numbers between 2 and 36 inclusive, or s is not a
  12109. number in radix n1, an error occurs and the empty string is returned.
  12110. \fradix() also does not offer extended-precision arithmetic; number values are
  12111. limited to those expressed as a long integer in the architecture of the
  12112. underlying computer, usually 32 or 64 bits.  If you give it an argument whose
  12113. absolute value is larger than can be held in an unsigned long, the result is
  12114. -1.
  12115.  
  12116. The next four are shorthand functions for decimal/hexadecimal and
  12117. decimal/octal number conversion:
  12118.  
  12119. \fn2hex(n)
  12120.   Returns the hexadecimal (base 16) representation of the integer n.  This is
  12121.   different from \fhexify(s), which treats its argument as a string rather
  12122.   than a number.  The result is always left-padded with 0's to make its
  12123.   length even.  Examples:
  12124.     \n2hex(0)   = "00"                    \fhexify(0)   = "30"
  12125.     \n2hex(255) = "ff"                    \fhexify(255) = "323535"
  12126.     \n2hex(256) = "0100"                  \fhexify(256) = "323536"
  12127.  
  12128. \fhex2n(x)
  12129.   Converts hexadecimal number x to decimal equivalent decimal number.
  12130.   This is the inverse of \fn2hex().  Equivalent to \fradix(s,16,10).
  12131.  
  12132. \fn2octal(n)
  12133.   Returns the octal (base 8) representation of the number n.  Examples:
  12134.   \n2octal(0) = "0"
  12135.   \n2oct(255) = "377"
  12136.   \n2oct(256) = "400"
  12137.   Equivalent to \fradix(n,10,8).
  12138.  
  12139. \foct2n(n)
  12140.   Returns the decimal representation of the given octal number, n.  The
  12141.   inverse of \fn2octal().  Equivalent to \fradix(n,8,10).
  12142.  
  12143. String functions:
  12144.  
  12145. \s(name[n:m])
  12146.   Equivalent to \fsubstring(\m(name),n,m) (Section 7.24).
  12147.  
  12148. \:(name[n:m])
  12149.   Equivalent to \fsubstring(name,n,m) (where "name" is any \-quantity)
  12150.   (Section 7.24).
  12151.  
  12152. \fleft(s,n)
  12153.   The leftmost n characters of string s; equivalent to \fsubstring(s,1,n).
  12154.  
  12155. \fstripx(string,char)
  12156.   Returns the part of the string up to the rightmost occurrence, if any, of
  12157.   the given character.  The default character is period (.)  Examples:
  12158.     \fstripx(foo/bar,/)                 = "foo"
  12159.     \fstripx(foo/bar/baz,/)             = "foo/bar"
  12160.     \fstripx(autoexec.bat,.)            = "autoexec"
  12161.     \fstripx(autoexec.bat)              = "autoexec"
  12162.     \fstripx(fstripx(foo/bar/baz,/),/)  = "foo"
  12163.  
  12164. \flop(string,character)
  12165.   Returns the portion of the string starting after the first occurrence of
  12166.   the given character.  The default character is period (.)  Examples:
  12167.     \flop(autoexec.bat)                 = "bat"
  12168.     \flop(baz.foo/bar)                  = "foo/bar"
  12169.     \flop(baz.foo/bar,/)                = "bar
  12170.  
  12171. \fstripn(string,n)
  12172.   Returns the string with n characters removed from the end.  Example:
  12173.   \fstripn(12345678,3)                  = "12345"
  12174.  
  12175. (For more discussion of \fstripx(), \fstripn(), and \flop() see section 4.2.3).
  12176.  
  12177. \fb64encode(s)
  12178.   Returns the Base-64 encoding of the string s.
  12179.  
  12180. \fb64decode(s)
  12181.   Returns the decoding of the Base-64 string s.  Fails if s is not a Base-64
  12182.   string, or if its length is not a multiple of 4.  Note that if any of the
  12183.   result bytes are null (0), the result string stops there.  There is no way
  12184.   to represent strings that contain null bytes in C-Kermit (the same is true
  12185.   for \funhexify()).
  12186.  
  12187. \fword(s1,n,s2,s3)
  12188.   Extracts word number n from string s1.  By default, a "word" is any sequence
  12189.   of ASCII letters or digits; n is 1-based.  If n is omitted, "1" is used.
  12190.   Examples:
  12191.  
  12192.     \fword(one two three)    = "one"
  12193.     \fword(one two three,1)  = "one"
  12194.     \fword(one two three,2)  = "two"
  12195.     \fword(one two three,3)  = "three"
  12196.  
  12197.   and:
  12198.  
  12199.     \fword(\v(dialresult),2) = "31200"
  12200.  
  12201.   is "31200" if \v(dialresult) is (e.g.) "CONNECT 31200/ARQ/V32/LAPM/V42BIS".
  12202.  
  12203.   If you include s2, this replaces the default break set.  For example,
  12204.   suppose you have a string \%a whose value is:
  12205.  
  12206.     $150.00 $300.00 $39.95
  12207.  
  12208.   and you want each dollar amount to be a word; use:
  12209.  
  12210.     \fword(\%a,\%n,{ })
  12211.  
  12212.   This returns dollar amount number \%n, e.g. "$300.00" for \%n = 2.  "{ }"
  12213.   denotes a space (you must enclose it in braces, otherwise it is squeezed
  12214.   out).  Note that ASCII control characters are always included in the break
  12215.   set; you don't have to specify them (and you can't not specify them).
  12216.  
  12217.   The optional s3 argument lists characters (even control characters) that
  12218.   normally would be considered separators that you want included in words.
  12219.   So the dollars-and-cents example could also be handled this way:
  12220.  
  12221.     \fword(\%a,\%n,,$.)
  12222.  
  12223.   in other words, use the default separator list, but remove "$" and "."
  12224.   from it so they will be considered part of a word.
  12225.  
  12226. \fsplit(s1,&a,s2,s3)
  12227.   This is like \fword(), except instead of extracting and returning a
  12228.   particular word from string s1, it counts the words and optionally assigns
  12229.   them to the array whose identifying letter, a-z, is given after the "&" in
  12230.   the second argument, with the first word going into element 1, the second
  12231.   into element 2, and so on.  The rules regarding break and include lists (s2
  12232.   and s3) are exactly the same as for \fword().  \fsplit() returns the number
  12233.   of words that were assigned, which is either the number of words in the
  12234.   string, or the dimension of the array, whichever is less.  If the array is
  12235.   not declared, \fsplit() creates it and returns a number which is both the
  12236.   number of words in s1 and the dimension of the new array.  Examples:
  12237.  
  12238.      declare \&w[20]        ; (Optional.)
  12239.      ...
  12240.      read \%s               ; \%s is "This is a sentence with seven words."
  12241.      ...
  12242.      echo "\fsplit(\%s)"    ; This would print "7".
  12243.      echo "\fsplit(\%s,&w)" ; Ditto, and also assigns them to array \&w[].
  12244.  
  12245.      echo "\&w[7]"          ; This would print "words".
  12246.  
  12247.   If the line contained fields that were delimited by colon (:), you would use
  12248.   \fsplit(\%s,&w,:).  If the fields were delimited by comma, then you would
  12249.   use \fsplit(\%s,&w,{,}); in this case the literal comma must be enclosed in
  12250.   braces to distinguish it from the comma that separates function arguments.
  12251.   To get a word count without loading an array, but still specify break
  12252.   and/or include lists, leave the array argument empty:
  12253.  
  12254.      echo "\fsplit(\%s,,:)" ; Use colon as the separator.
  12255.  
  12256.   WARNINGS:
  12257.    a. If you use the same array repeatedly, \fsplit() leaves any trailing
  12258.       members undisturbed.  For example:
  12259.          dcl \&w[10]
  12260.          \fsplit(1 2 3 4 5,&w) ; Sets \&w[1] thru \&w[5].
  12261.          \fsplit(a b c,&w)     ; Sets \&w[1]-[3] leaving [4]-[5] as they were.
  12262.    b. If you allow \fsplit to create the array (by not declaring it first),
  12263.       it is dimensioned to the number of elements it was created with:
  12264.          \fsplit(1 2 3,&x)     ; Creates an array \&x[] with 3 elements.
  12265.          \fsplit(a b c d e,&x) ; This overflows the array.
  12266.  
  12267.    Thus if you want to use \fsplit() repeatedly on the same array, either
  12268.    dimension it in advance to the maximum expected size (and then some --
  12269.    more efficient), or else destroy it after each use (to allow for
  12270.    unexpectedly large arguments).  Example using a dynamic array:
  12271.  
  12272.       fopen /read \%c some-file
  12273.       if fail ...
  12274.       set function error on    ; See Section 7.12
  12275.       while true {
  12276.           dcl \&w[]            ; Destroy \&[w] each time thru the loop
  12277.           fread /line \%c \%a
  12278.           if fail break
  12279.           asg \%x \fsplit(\%a,&w)
  12280.           if fail ...
  12281.           ; (do what you want with \&w[] here...)
  12282.       }
  12283.       fclose \%c
  12284.  
  12285. \frindex(s1,s2,n)
  12286.   The "n" argument to \frindex() now works consistently (in mirror image)
  12287.   with the corresponding \findex() argument.  In each case, the (n-1)-most
  12288.   characters of s2 are ignored in the search; for findex, this means the
  12289.   starting position of the search is n (the default n is 1, and 0 is treated
  12290.   like 1).  For \frindex() it means the default starting point is:
  12291.   length(s2) - length(s1) - n (with the same defaults for n).
  12292.  
  12293. \fsearch(pattern,string[,position])
  12294.   Exactly like \findex(), except with a pattern (see Section 7.9) rather
  12295.   than a literal string.
  12296.  
  12297. \frsearch(pattern,string[,position])
  12298.   Exactly like \frindex(), except with a pattern rather than a literal string.
  12299.  
  12300. File Functions:
  12301.  
  12302. \ffiles(), \fnextfile()
  12303.   It is no longer necessary to copy the file list to an array before use,
  12304.   as shown on p.398 of "Using C-Kermit" 2nd Edition.  \ffiles() and friends
  12305.   now make their own safe copies of the file list.  Thus constructions like
  12306.   the following are now possible:
  12307.  
  12308.     for \%i 1 \ffiles(*.txt) 1 { send \fnextfile() }
  12309.  
  12310.   The same is true for the new function \frfiles(), \fdirectories(), and
  12311.   \frdirectories(), described in section 4.11.3.
  12312.  
  12313.   But note that each reference to \fnextfile() still gets you the next file.
  12314.   So "if newer \fnextfile() foo.txt send \fnextfile()" compares one file's
  12315.   age with that of foo.txt, and then sends an entirely different file.  If
  12316.   you're going to refer to the same file more than once, assign it to a
  12317.   variable:  asg \%f \fnextfile(), if newer \%f foo.txt send \%f (note:
  12318.   assign, *not* define).
  12319.  
  12320.   Also note that \ffiles(), \frfiles(), \fdirectories() and \frdirectories()
  12321.   all now accept on optional 2nd argument: the name of an array to load with
  12322.   the resulting file or directory list, explained in Section 4.11.3.
  12323.   So you can also load an array with the filelist when you need to refer to
  12324.   the same file more than once:
  12325.   for \%i 1 \ffiles(*,&a) 1 { if newer \&a[\%i] foo.txt send \&a[\%i] }
  12326.  
  12327. \fpermissions(file)
  12328.   Returns the platform-specific permissions string for the file, such as
  12329.   "-rw-rw-r--" in UNIX or "(RWE,RWE,RE,E)" in VMS.
  12330.  
  12331. \fdirname(f)
  12332.   Given a file specification f, this function returns the complete pathname
  12333.   of directory the file is in.
  12334.  
  12335. Array Functions:
  12336.  
  12337. \fdimension(&a)
  12338.   Returns the dimension declared for the array whose identifying letter, a-z,
  12339.   or special character "_" or "@", is given after the "&" in the argument.
  12340.   If the array is not declared, 0 is returned.  Note that when used with the
  12341.   macro argument vector array, \&_[] (see Section 7.5), the value of this
  12342.   function is one less than \v(argc), and when used with the C-Kermit
  12343.   command-line argument vector array, \&@[], it is equal to the \v(args)
  12344.   variable.  Examples:
  12345.  
  12346.     echo \fdimension(&a)       ; Not declared.
  12347.     0
  12348.     declare \&a[12]            ; Now it's declared.
  12349.     echo \fdim(&a)
  12350.     12
  12351.  
  12352. \farraylook(pattern,arrayname)
  12353.   Looks in the given array for the pattern and returns the index of the first
  12354.   element that matches, if any, or -1 if none match.  The arrayname can
  12355.   include a range specifier to restrict to search to a segment of the array,
  12356.   e.g. \farraylook(*xyz*,&a[32:63]).  For greater detail see Section 7.10.7.
  12357.  
  12358. \ftablelook(keyword,arrayname[,delimiter])
  12359.   Looks in the given "table", which must be sorted, for the given keyword.
  12360.   Returns the index of the table element that uniquely matches the given
  12361.   keyword, or -1 if none match, or -2 if more than 1 match.
  12362.   For greater detail see Section 7.10.7.
  12363.  
  12364. Other new functions:
  12365.  
  12366. \fip2hex(s)
  12367.   Converts a dotted decimal IP address to an 8-digit hexadecimal number.
  12368.   \fip2hex(128.59.39.2) = 803b2702.
  12369.  
  12370. \fhex2ip(x)
  12371.   Converts an 8-digit hexadecimal IP address to dotted decimal form, e.g.
  12372.   \fhex2ip(803b2702) = 128.59.39.2.  The inverse of \fip2hex().
  12373.  
  12374. \fcommand()
  12375. \frawcommand()
  12376.   These run an external command and return its output; see Section 4.2.8.4.
  12377.  
  12378. \fdialconvert(s)
  12379.   s is a phone number in either literal or portable format (not a dialing
  12380.   directory entry name).  The function returns the dial string that would
  12381.   actually be used when dialing from the current location (after processing
  12382.   country code, area code, and other SET DIAL values).
  12383.  
  12384. \ferrstring(n)
  12385.   Returns the system error message associated with the (numeric) error code n.
  12386.   UNIX and VMS only.  Use in conjunction with \v(errno) or \v(pexitstat).  See
  12387.   section 4.2.5 for a usage example.  Note: This function doesn't work in
  12388.   Windows because there is not a consistent error-code-to-message mapping;
  12389.   error code "x" means something completely different depending on whether it
  12390.   comes from the C runtime library, Winsock, a Windows-32 API, TAPI, etc,
  12391.  
  12392. \fpattern(s)
  12393.   Used in INPUT, REINPUT, and MINPUT commands to denote search strings that
  12394.   are to be treated as patterns rather than literally.
  12395.  
  12396. Also see Section 7.8 on built-in help for functions.
  12397.  
  12398. 7.4. New IF Conditions
  12399.  
  12400. IF AVAILABLE <feature> <command>
  12401.   Executes the <command> if the given <feature> is available.  Presently used
  12402.   only to determine if specific authentication and encryption options are
  12403.   available.  Type "if available ?" to see which features may be tested.
  12404.  
  12405. IF FLOAT f1 <command>
  12406.   Executes <command> if f1 is a legal floating point number (which includes
  12407.   integers).  Use this to preverify arguments for the \ffp...() floating-point
  12408.   arithmetic functions, e.g. "if float \%1 echo \ffpint(\%1)".
  12409.  
  12410. IF == n1 n2 <command>
  12411.   Synonym for "if =" (numeric equality).  Note that as of C-Kermit 7.0, this
  12412.   and all other numeric comparison operators also work for floating-point
  12413.   numbers.
  12414.  
  12415. IF != n1 n2 <command>
  12416.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12417.   numbers and the value of n1 is not equal to the value of n2.  This is
  12418.   equivalent to "if not = n1 n2".
  12419.  
  12420. IF <= n1 n2 <command>
  12421.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12422.   numbers and the value of n1 is less than or equal to the value of n2.  This
  12423.   is equivalent to "if not > n1 n2".
  12424.  
  12425. IF >= n1 n2 <command>
  12426.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12427.   numbers and the value of n1 is greater than or equal to the value of n2.
  12428.   Equivalent to "if not < n1 n2".
  12429.  
  12430. IF COMMAND <word> <command>
  12431.   Executes the <command> if <word> is a built-in C-Kermit command.
  12432.   Example: "if not command copy define { copy run copy \%1 \%2 }".
  12433.   This defines a COPY macro that runs an external COPY command if COPY
  12434.   is not already a built-in command.
  12435.  
  12436. IF LOCAL <command>
  12437.   Executes the <command> if Kermit is in local mode, i.e. if it has a
  12438.   SET LINE, SET PORT, or SET HOST (TELNET, RLOGIN, etc) device or connection
  12439.   open.  Does not execute the command if in remote mode.
  12440.  
  12441. IF MATCH <string> <pattern> <command>
  12442.   Executes the <command> if the <string> matches the <pattern>.  For a
  12443.   description of the syntax for the pattern, see Section 4.9.1.  If you want
  12444.   to test if the string contains pattern, use IF \fsearch(pattern,string).
  12445.  
  12446. IF OPEN { DEBUG-LOG, SESSION-LOG, TRANSACTION-LOG, ... } <command>
  12447.   Executes the <command> if the given file is open, fails if it is not open.
  12448.   Type IF OPEN ? for a complete list of files that can be checked (all the
  12449.   files that can be opened with the OPEN or LOG commands).
  12450.  
  12451. IF QUIET <command>
  12452.   Executes the command if SET QUIET is ON, and does not execute it if
  12453.   SET QUIET is OFF.  Example: IF NOT QUIET ECHO { This is a message.}.
  12454.  
  12455. IF READABLE <name>
  12456.   Succeeds if <name> is the name of an existing file or directory that is
  12457.   readable.
  12458.  
  12459. IF WRITEABLE <name>
  12460.   Succeeds if <name> is the name of an existing file or directory that is
  12461.   writeable, e.g.:
  12462.  
  12463.     if not writeable \v(lockdir) echo Please read installation instructions!
  12464.  
  12465. IF FLAG <command>
  12466.   This tests a user-settable condition, which can mean anything you like.
  12467.   SET FLAG ON causes subsequent IF FLAG commands to succeed; SET FLAG OFF
  12468.   causes them to fail.  One way to use it would be for debugging your
  12469.   scripts; precede any debugging statements with IF FLAG.  Then SET FLAG on
  12470.   to debug your script, SET FLAG OFF to run it without debugging.  Another
  12471.   common use is for causing an inner loop to cause an outer loop to exit.
  12472.  
  12473. IF C-KERMIT <command>
  12474.   C-Kermit, but not Kermit 95 or MS-DOS Kermit, executes the <command>.
  12475.  
  12476. IF K-95 <command>
  12477.   Kermit 95, but not C-Kermit or MS-DOS Kermit, executes the <command>.
  12478.  
  12479. IF MS-KERMIT <command>
  12480.   MS-DOS Kermit, but not C-Kermit or Kermit 95, executes the <command>.
  12481.  
  12482. 7.5. Using More than Ten Macro Arguments
  12483.  
  12484. The \v(argc) variable now gives the actual number of arguments, even if the
  12485. number is greater than 9:
  12486.  
  12487.   C-Kermit> define xx echo \v(argc)
  12488.   C-Kermit> xx a b c d e f g h i j k l m n o p q r s t u v w x y z
  12489.   27
  12490.  
  12491. Remember that \v(argc) includes the name of the macro itself, so it is always
  12492. at least 1, and is always 1 greater than the actual number of arguments.  As
  12493. in versions 6.0 and earlier, if more than 9 arguments are given, only the
  12494. first nine are assigned to the variables \%1..\%9.
  12495.  
  12496. The \&_[] array, discussed on page 353 of "Using C-Kermit", 2nd ed, now holds
  12497. all the arguments, up to some implementation-dependent limit (64 or greater),
  12498. rather than only the first 9.  To illustrate: the following macro tells the
  12499. number of arguments it was called with and then prints them:
  12500.  
  12501.   define show_all_args {
  12502.       local \%i
  12503.       echo \&_[0] - Number of arguments: \feval(\v(argc)-1)
  12504.       for \%i 1 \v(argc)-1 1 { echo \flpad(\%i,3). "\&_[\%i]" }
  12505.   }
  12506.  
  12507. Within a macro \&_[0], like \%0, contains the name of the macro.
  12508.  
  12509. At top level, the \&_[] array is filled as follows:
  12510.  
  12511.  . If the first argument on the C-Kermit command line was a filename,
  12512.    or C-Kermit was invoked from a "Kerbang" script (Section 7.19), element
  12513.    0 contains the filename, and elements 1 through \v(argc)-1 hold the
  12514.    remaining command-line arguments.
  12515.  
  12516.  . Otherwise the program name goes in element 0, and elements 1 through
  12517.    \v(argc)-1 hold any arguments that were included after "--" or "="
  12518.  
  12519. The new \%* variable, when used within a macro, is replaced by the text that
  12520. followed the macro name in the macro invocation.  If no arguments were given,
  12521. \%* is replaced by the empty string.  Examples:
  12522.  
  12523.   C-Kermit> define xx echo [\%*]
  12524.   C-Kermit> define \%a oofa
  12525.   C-Kermit> xx
  12526.   []
  12527.   C-Kermit> xx \%a
  12528.   [oofa]
  12529.   C-Kermit> xx a
  12530.   [a]
  12531.   C-Kermit> xx a b
  12532.   [a b]
  12533.   C-Kermit> xx a b c
  12534.   [a b c]
  12535.   C-Kermit> xx a b c d e f g h i j k l m n o p q r s t u v w x y z
  12536.   [a b c d e f g h i j k l m n o p q r s t u v w x y z]
  12537.  
  12538. Note that \%* can not be used at top level, since Kermit does not have
  12539. access to the raw command line (only to its elements separately, after they
  12540. have been processed by the shell and the C library).
  12541.  
  12542. C-Kermit 7.0 also adds a SHIFT command:
  12543.  
  12544. SHIFT [ number ]
  12545.   Shifts the macro arguments (except argument 0) the given number of places
  12546.   to the left and adjusts \v(argc) accordingly.  The default number is 1.
  12547.  
  12548. To illustrate, suppose macro XXX is invoked as follows:
  12549.  
  12550.   xxx arg1 arg2 arg3
  12551.  
  12552. Then inside XXX, \%1 is "arg1", \%2 is "arg2", and \%3 is "arg3".  After a
  12553. SHIFT command is given inside XXX, then \%1 is "arg2", \%2 is "arg3", and \%3
  12554. is empty.  \%0 (the name of the macro) remains unchanged.
  12555.  
  12556. If more than 9 arguments were given, then arguments are shifted into the
  12557. \%1..9 variables from the argument vector array.
  12558.  
  12559. At top level, the SHIFT command operates on the \&_[] array and \%1..9
  12560. variables; the \&@[] array is not affected.  See Section 7.16 for details.
  12561.  
  12562. The \%* variable is not affected by the SHIFT command.
  12563.  
  12564. 7.6. Clarification of Function Call Syntax
  12565.  
  12566. Spaces are normally stripped from the front and back of each function
  12567. argument; to prevent this enclose the argument in braces:
  12568.  
  12569.   \fsplit(\%a,&a,{ })
  12570.  
  12571. However, function calls that contain spaces can make trouble when the function
  12572. is to be used in a "word" field, since space separates words.  For example:
  12573.  
  12574.   for \%i 1 \fsplit(\%a,&a,{ }) 1 {
  12575.     echo \%i. "\&a[\%i]"
  12576.   }
  12577.  
  12578. In most cases, the trouble can be averted by enclosing the function reference
  12579. in braces:
  12580.  
  12581.   for \%i 1 {\fsplit(\%a,&a,{ })} 1 {
  12582.     echo \%i. "\&a[\%i]"
  12583.   }
  12584.  
  12585. or by replacing spaces with \32 (the ASCII code for space):
  12586.  
  12587.   for \%i 1 \fsplit(\%a,&a,\32) 1 {
  12588.     echo \%i. "\&a[\%i]"
  12589.   }
  12590.  
  12591. Braces are also used in function calls to indicate grouping.  For example:
  12592.  
  12593.   \fsubstring(abcd,2,2) = "bc"
  12594.  
  12595. But suppose "abcd" needed to contain a comma:
  12596.  
  12597.   \fsubstring(ab,cd,2,2)
  12598.  
  12599. This would cause an error, since "cd" appears to be the second argument, when
  12600. really you want the first "2" to be the second argument.  Braces to the rescue:
  12601.  
  12602.   \fsubstring({ab,cd},2,2) = "b,"
  12603.  
  12604. Similarly, leading and trailing spaces are stripped from each argument, so:
  12605.  
  12606.   \fsubstring( abcd ,2,2) = "bc"
  12607.  
  12608. but braces preserve them:
  12609.  
  12610.   \fsubstring({ abcd },2,2) = "ab"
  12611.  
  12612. Given these special uses for braces, there is no way to pass literal braces to
  12613. the function itself.  For example:
  12614.  
  12615.   \fsubstring(ab{cd,2,2)
  12616.  
  12617. causes an error.
  12618.  
  12619. So if you need a function to include braces, define a variable containing the
  12620. string that has braces.  Example:
  12621.  
  12622.   define \%a ab{cd
  12623.   \fsubstring(\%a,2,2) = "b{"
  12624.  
  12625. If the string is to start with a leading brace and end with a closing brace,
  12626. then double braces must appear around the string (which itself is enclosed in
  12627. braces):
  12628.  
  12629.   define \%a {{{foo}}}
  12630.   \fsubstring(\%a) = "{foo}"
  12631.  
  12632. This also works for any other kind of string:
  12633.  
  12634.   define \%a {{ab{cd}}
  12635.   echo \fsubstring(\%a) = "ab{cd"
  12636.  
  12637. 7.7. Autodownload during INPUT Command Execution
  12638.  
  12639. As of 6.1 / 1.1.12, C-Kermit can be told to look for incoming Kermit (or
  12640. Zmodem) packets during execution of an INPUT command.  By default (for
  12641. consistency with earlier releases), this is not done.  You can enable this
  12642. feature with:
  12643.  
  12644.   SET INPUT AUTODOWNLOAD ON
  12645.  
  12646. (and disable it again with OFF.)
  12647.  
  12648. One possible use for this feature is as a server mode with a time limit:
  12649.  
  12650.   INPUT 3600 secret-string-to-end-the-INPUT-command
  12651.  
  12652. In this example, any GET, SEND, or REMOTE commands received within one hour
  12653. (3600 seconds) of when the INPUT command was issued will be executed.  Here's
  12654. another example, in which we want to stay open until 11:30pm, or until
  12655. interrupted by seven consecutive Ctrl-C (\3) characters:
  12656.  
  12657.   INPUT 23:30:00 \3\3\3\3\3\3\3
  12658.  
  12659. The INPUT AUTODOWNLOAD setting is displayed by SHOW SCRIPTS or SHOW INPUT.
  12660.  
  12661. 7.8. Built-in Help for Functions.
  12662.  
  12663. Beginning in C-Kermit 7.0, you may obtain a description of the calling
  12664. conventions and return values of any built-in function, such as
  12665. \fsubstring(), with the new HELP FUNCTION command; give the function's
  12666. name without the leading "\f", e.g. "help func substring".  You can use ?,
  12667. completion, and abbreviation in the normal manner.
  12668.  
  12669. 7.9. Variable Assignments
  12670.  
  12671. 7.9.1. Assignment Operators
  12672.  
  12673. Programmers accustomed to languages such as C or Fortran might find Kermit's
  12674. method of assigning values to variables unnatural or awkward.  Beginning in
  12675. C-Kermit 7.0, you can use the following alternative notation:
  12676.  
  12677.  .name = value    is equivalent to   DEFINE name value
  12678.  .name := value   is equivalent to   ASSIGN name value
  12679.  .name ::= value  is equivalent to   ASSIGN name \feval(value)
  12680.  
  12681. When the command begins with a period (.), this indicates an assignment.
  12682. The name can be a macro name, a \%{digit,letter} variable, or an array
  12683. element.  There can be space(s) between "." and the name.  Examples:
  12684.  
  12685.   .\%a = This is a string  ; Same as "define \%a This is a string"
  12686.   echo \%a
  12687.   This is a string
  12688.  
  12689.   .xxx = \%a               ; Same as "define xxx \%a"
  12690.   echo \m(xxx)
  12691.   \%a
  12692.  
  12693.   .xxx := \%a              ; Same as "assign xxx \%a"
  12694.   echo \m(xxx)
  12695.   This is a string
  12696.  
  12697.   declare \&a[2]           ; Use with arrays...
  12698.   define \%i 2
  12699.   .\&a[1] = first
  12700.   .\&a[\%i] = second
  12701.  
  12702. The following sequence illustrates the differences among three levels of
  12703. evaluation:
  12704.  
  12705.   .\%x = 2          ; Define a variable to have a numeric value
  12706.   .\%y = (3 + \%x)  ; Define another variable as an arithmetic expression
  12707.  
  12708.   .xxx = 4 * \%y    ; "=" simply copies the right-hand side.
  12709.   echo \m(xxx)
  12710.   4 * \%y
  12711.  
  12712.   .xxx := 4 * \%y   ; ":=" evaluates the variables first, then copies.
  12713.   echo \m(xxx)
  12714.   4 * (3 + 2)
  12715.  
  12716.   .xxx ::= 4 * \%y  ; "::=" evaluates the expression, then copies.
  12717.   echo \m(xxx)
  12718.   20
  12719.  
  12720. You can also use this syntax to clear (undefine) a variable:
  12721.  
  12722.   .\%a = oofa       ; Define the variable
  12723.   echo "\%a"
  12724.   "oofa"
  12725.   .\%a              ; Clear the variable
  12726.   echo "\%a"
  12727.   ""
  12728.  
  12729. Extra credit: Can you guess what happens below when the file "abc" does not
  12730. exist?
  12731.  
  12732.   fopen /read \%c abc
  12733.   if fail ...
  12734.  
  12735. 7.9.2. New Assignment Commands
  12736.  
  12737. Recall the DEFINE and ASSIGN commands, and their hidden counterparts,
  12738. _DEFINE and _ASSIGN.  The former take the variable name literally, the latter
  12739. evaluate the variable-name field to form the variable name dynamically.
  12740. Examples:
  12741.  
  12742.   DEFINE \%x foo    ; Sets the value of the variable \%x to "foo".
  12743.   DEFINE \%a \%x    ; Sets the value of the variable \%a to "\%x".
  12744.   _DEFINE x_\%a \%x ; Sets the value of the variable x_foo to "\%x".
  12745.   ASSIGN \%a \%x    ; Sets the value of the variable \%a to the "foo".
  12746.   _ASSIGN x_\%a \%x ; Sets the value of the variable x_foo to "foo".
  12747.  
  12748. This concept has been carried over to the remaining variable-assignment
  12749. commands: EVALUATE, INCREMENT, and DECREMENT:
  12750.  
  12751. EVALUATE <variablename> <expression>
  12752.   Evaluates the arithmetic <expression> and assigns its value to the
  12753.   variable whose name is given.  Example: "eval \%a 1+1" assigns "2" to \%a.
  12754.  
  12755. _EVALUATE <metaname> <expression>
  12756.   Evaluates the arithmetic <expression> and assigns its value to the
  12757.   variable whose name is computed from the given <metaname>.  Example:
  12758.   "eval foo<\%a>::\%1 \%2 * (\%3 + \%4)" assigns the value of
  12759.   "\%2 * (\%3 + \%4)" to the variable whose name is computed from
  12760.   "foo<\%a>::\%1".
  12761.  
  12762. INCREMENT <variablename> <expression>
  12763.   Evaluates the arithmetic <expression> and adds its value to the
  12764.   value of the variable whose name is given.  Example: "increment \%a".
  12765.  
  12766. _INCREMENT <metaname> <expression>
  12767.   Evaluates the arithmetic <expression> and adds its value to the
  12768.   value of the variable whose name is computed from the given <metaname>.
  12769.   Example: "_increment Words::\%1.count[\%2]".
  12770.  
  12771. DECREMENT <variablename> <expression>
  12772.   Evaluates the arithmetic <expression> and subtracts its value from the
  12773.   value of the variable whose name is given.
  12774.  
  12775. _DECREMENT <metaname> <expression>
  12776.   Evaluates the arithmetic <expression> and subtracts its value from the
  12777.   value of the variable whose name is computed from the given <metaname>.
  12778.  
  12779. WARNING: The syntax of the EVALUATE command has changed since C-Kermit 6.0
  12780. and K95 1.1.17.  Previously, it did not include a variable name, only an
  12781. expression.  To restore the old behavior, use SET EVALUATE OLD.  To return
  12782. to the new behavior after restoring the old behavior, use SET EVALUATE NEW.
  12783.  
  12784. NOTE: There are no analogs to the "_" commands for the operators described
  12785. in Section 7.9.1; those operators can not be used to assign values to
  12786. variables whose names must be computed.
  12787.  
  12788. 7.10. Arrays
  12789.  
  12790. C-Kermit 7.0 adds lots of new array-related features, and groups them together
  12791. under the NEW ARRAY command:
  12792.  
  12793.   ARRAY { CLEAR, COPY, DECLARE, DESTROY, RESIZE, SHOW, SORT }
  12794.  
  12795. In each of the ARRAY commands, wherever an array name is expected, "short
  12796. forms" may be used.  For example, all of the following are acceptable:
  12797.  
  12798.   array show \&a[]  (or SHOW ARRAY...)
  12799.   array show &a[]
  12800.   array show a[]
  12801.   array show &a
  12802.   array show a
  12803.  
  12804. In addition, ranges are accepted in the ARRAY COPY, ARRAY CLEAR, ARRAY SET,
  12805. ARRAY SHOW, and ARRAY SORT commands:
  12806.  
  12807.   array clear \&a[16]     ; Clears 16 thru end
  12808.   array clear &a[16]      ; Ditto
  12809.   array clear a[16]       ; Ditto
  12810.  
  12811.   array clear \&a[16:32]  ; Clears 16 thru 32
  12812.   array clear &a[16:32]   ; Ditto
  12813.   array clear a[16:32]    ; Ditto
  12814.  
  12815. When using array names as function arguments, you must omit the "\" and you
  12816. must include the "&".  You may optionally include empty brackets.  Examples:
  12817.  
  12818.   \fsplit(\%a,a)          ; Bad
  12819.   \fsplit(\%a,\&a)        ; Bad
  12820.   \fsplit(\%a,&a[3])      ; Bad
  12821.  
  12822.   \fsplit(\%a,&a)         ; Good
  12823.   \fsplit(\%a,&a[])       ; Good
  12824.  
  12825. 7.10.1. Array Initializers
  12826.  
  12827. Beginning in C-Kermit 7.0, you may initialize an array -- in whole or in part
  12828. -- in its declaration:
  12829.  
  12830.   [ ARRAY ] DECLARE <array-name>[<size>] [ = ] [ <value1> [ <value2> [...] ] ]
  12831.  
  12832. For compatibility with versions 5A and 6.0, the ARRAY keyword is optional.
  12833. DECLARE can also be spelled DCL.
  12834.  
  12835. Initializers are (a) optional, (b) start with element 1, (c) must be enclosed
  12836. in braces if they contain spaces, and (d) are evaluated according to normal
  12837. rules by the DECLARE command prior to assignment.  Thus the assignments made
  12838. here are the same as those made by the ASSIGN command.  This allows you to
  12839. initialize array elements from the values of other variables.  If you actually
  12840. want to initialize an array element to variable's name, as opposed to its
  12841. value, use double backslashes (as in "\\&a", "\\v(time)", etc).
  12842.  
  12843. The <size> (dimension) of the array is optional.  If the size is omitted, as
  12844. in "\&a[]", then the array sizes itself to the number of initializers; if
  12845. there are no initalizers the array is not declared or, if it was declared
  12846. previously, it is destroyed.  If a size is given, any extra elements in the
  12847. initialization list are discarded and ignored.
  12848.  
  12849. NOTE: Unlike in C, the list of initializers is NOT enclosed in braces.
  12850. Instead, braces are used to group multiple words together.  So:
  12851.  
  12852.   ARRAY DECLARE \&a[] = { one two three }
  12853.  
  12854. would create an array with two elements (0 and 1), with element 1 having
  12855. the value " one two three ".
  12856.  
  12857. Examples:
  12858.  
  12859. ARRAY DECLARE \&a[16]
  12860.   Declares the array \&a with 17 elements (0 through 16), in which all
  12861.   elements are initially empty.  If the array \&a[] existed before, the
  12862.   earlier copy is destroyed.
  12863.  
  12864. ARRAY DECLARE &a[16]
  12865. ARRAY DECLARE a[16]
  12866. ARRAY DCL \&a[16]
  12867. ARRAY DCL &a[16]
  12868. ARRAY DCL a[16]
  12869. DECLARE \&a[16]
  12870. DECLARE &a[16]
  12871. DECLARE a[16]
  12872. DCL \&a[16]
  12873. DCL &a[16]
  12874. DCL a[16]
  12875.   All of the above are the same as the first example.
  12876.  
  12877. ARRAY DECLARE \&a[16] = alpha beta {gamma delta}
  12878.   Declares the array \&a with 17 elements (0 through 16), initializing \&a[1]
  12879.   to "alpha", \&a[2] to "beta", and \&a[3] to "gamma delta".  The remaining
  12880.   elements are empty.
  12881.  
  12882. ARRAY DECLARE \&a[] = alpha beta {gamma delta}
  12883.   Same as the previous example, but the array is automatically dimensioned
  12884.   to 3.
  12885.  
  12886. ARRAY DECLARE \&a[3] = alpha beta {gamma delta} epsilon zeta
  12887.   Too many initializers; only the first three are kept.
  12888.  
  12889. ARRAY DECLARE \&a[0]
  12890. ARRAY DECLARE \&a[]
  12891. ARRAY DECLARE &a[]
  12892. ARRAY DECLARE &a
  12893. ARRAY DECLARE a
  12894. DECLARE \&[0]
  12895. DECLARE a
  12896. DCL a
  12897.   All of these are equivalent.  Each destroys \&a[] if it exists.  Declaring
  12898.   an array with a dimension of 0 is the same as ARRAY DESTROY <arrayname>.
  12899.  
  12900. ARRAY DECLARE \&a[] = \%1 \%2 \%3
  12901.   Declares the array \&a with 3 elements (0 through 3), initializing \&a[1]
  12902.   to the value of \%1, \&a[2] to the value of \%2, and \&a[3] to the value of
  12903.   \%3.  In this case, any reference to one of these array elements is replaced
  12904.   by the value of the corresponding \%n variable at the time the declaration
  12905.   was executed (immediate evaluation; the array element's value does not
  12906.   change if the initalizer variable's value changes).
  12907.  
  12908. ARRAY DECLARE \&a[] = \\%1 \\%2 \\%3
  12909.   Declares the array \&a with 3 elements (0 through 3), initializing \&a[1]
  12910.   to the string "\%1", \&a[2] to "\%2", and \&a[3] to "\%3".  In this case any
  12911.   reference to one of these array elements is replaced by the CURRENT value
  12912.   of the corresponding \%n variable (deferred evaluation -- the array element's
  12913.   value follows the value of the initializer variable).
  12914.  
  12915. The equal sign (=) preceding the initalizer list is optional, but is
  12916. recommended for clarity.  If you need to initialize element 1 to a literal
  12917. equal sign, use two of them, separated by a space, as in this example:
  12918.  
  12919.   ARRAY DECLARE \&a[] = = + - * /
  12920.  
  12921. Remember, element 0 is not initialized by the DECLARE command.  To initialize
  12922. element 0, use a regular DEFINE or ASSIGN command:
  12923.  
  12924.   ARRAY DECLARE \&a[] one two three four five six seven eight nine
  12925.   DEFINE \&a[0] zero
  12926.  
  12927. Finally, remember that every command level has its own local array, \&_[],
  12928. containing all the macro arguments (\%0, \%1, ...) for that level.  See
  12929. Section 7.5 for details.
  12930.  
  12931. 7.10.2. Turning a String into an Array of Words
  12932.  
  12933. The \fsplit(s1,&a,s2,s3) function assigns the words of string s1 to successive
  12934. elements of the array (beginning with element 1) whose identifying letter,
  12935. a-z, is given after the "&" in the second argument, using break and include
  12936. characters given in s2 and s3.  See Section 7.3 for details.
  12937.  
  12938. 7.10.3. Arrays of Filenames
  12939.  
  12940. See Section 4.11.3 for news about how \ffiles() and related functions
  12941. can assign a list of filenames to an array.  To recapitulate briefly here:
  12942.  
  12943.   \ffiles(*,&a)
  12944.  
  12945. assigns all files that match the first argument to the array denoted by the
  12946. second argument.  If the array has not been declared, it is declared
  12947. automatically, with exactly the number of elements needed to hold the file
  12948. list; if it was previously declared, it is destroyed and reused.  The
  12949. filenames are assigned starting at array element 1.  Element 0 holds the
  12950. number of files in the list.
  12951.  
  12952. The DIRECTORY command (Section 4.5.1) can also create filename arrays if you
  12953. give it the /ARRAY: switch; this allows selection criteria beyond whether the
  12954. filename matches the given pattern.
  12955.  
  12956. All functions and commands that create filename arrays store the number of
  12957. filenames, n, as element 0 of the array, and the filenames as elements 1
  12958. through n.
  12959.  
  12960. 7.10.4. Automatic Arrays
  12961.  
  12962. In a command file or macro, you can now have local (automatic) arrays.
  12963. Just give the name followed by empty subscript brackets (no spaces inside
  12964. the brackets please) in a LOCAL command, and then declare the array:
  12965.  
  12966.   LOCAL \%a \&a[] oofa
  12967.   ARRAY DECLARE \&a[32] = value1 value2 value3 ...
  12968.  
  12969. This declares the scalar variable \%a, the array \&a[], and the macro name
  12970. "oofa" to be local, and then declares the new local copy of \&a[] with 32
  12971. elements, perhaps assigning some initial values.  When C-Kermit exits from the
  12972. command file or macro containing these command, the previous \&a[] array is
  12973. restored (and if there was no \&a[] at any higher level, this will still be
  12974. true).  The process can be repeated to any level.  Thus it is now safe to
  12975. write scripts or macros containing arrays without danger of interfering with
  12976. global arrays of the same name.
  12977.  
  12978. Just as scalars are inherited by lower command levels, so are arrays.  So, for
  12979. example, if \&a[] is declared at top level, all lower levels will see it
  12980. unless they include a "local \&a[]" statement, in which case all levels at and
  12981. beneath the level where the LOCAL statement was executed will see the local
  12982. copy.  This too can be repeated to any level.
  12983.  
  12984. On the other hand, if you DECLARE an array at a lower command level without
  12985. also making it LOCAL, this replaces the copy that was declared at the lowest
  12986. command level above this one.
  12987.  
  12988. 7.10.5. Sorting Arrays
  12989.  
  12990. Although arrays can be sorted using FOR loops as shown on page 383 of "Using
  12991. C-Kermit" 2nd Ed., this involves quite a bit of repetitive interpretation by
  12992. the command parser, and so can be slow for large arrays.  For this reason,
  12993. C-Kermit 7.0 adds a built-in SORT command:
  12994.  
  12995. ARRAY SORT [ switches ] array [ array2 ]
  12996.   Sorts the given array in place.  Sorting is strictly lexical (string based).
  12997.   The array name can be given fully, e.g. \&a[]", or the \ and/or & and/or
  12998.   brackets can be omitted, e.g. "array sort \&a[]", "sort &a", "sort a".
  12999.   Also, a range can be indicated in the brackets as noted in section 7.10,
  13000.   to restrict the sort to a range of elements (equivalent to the /RANGE
  13001.   switch, described just below), e.g. "array sort &a[20:30]"
  13002.  
  13003. A second array may be specified.  If it is, and if it is at least as big as
  13004. the first array, it is sorted according to the first array.  For a sample
  13005. application, see Section 7.10.10.
  13006.  
  13007. See Section 1.5 for an explanation of switches.  The optional switches are:
  13008.  
  13009. /CASE:{ON,OFF}
  13010.   /CASE:ON means that alphabetic case is significant in comparisons; uppercase
  13011.   letters are sorted before lowercase ones.  /CASE:OFF means case is ignored,
  13012.   e.g. "A" is the same as "a".  If this switch is not given, sorting is
  13013.   according the current SET CASE setting.
  13014.  
  13015. /KEY:n
  13016.   Comparison begins at position n (1-based) in each string.  If no
  13017.   key is given, the entire strings are compared.  Only one key can be
  13018.   given.  If an array element is shorter than the key value, n, that element
  13019.   is considered empty for comparison purposes, and therefore lexically
  13020.   less than any element at least n characters long.
  13021.  
  13022. /NUMERIC
  13023.   If this switch is included, it means sorting should be numeric, rather than
  13024.   lexical.  The sort key is the string starting at the key position, skipping
  13025.   any leading blanks or tabs, and then as much of the string from that point
  13026.   on that fits the definition of "numeric", terminating at the first character
  13027.   that does not qualify.  A numeric string has an optional sign (+ or -)
  13028.   followed by one or more digits, and (if your version of Kermit was built
  13029.   with floating-point support; see Section 7.23) zero or one decimal point
  13030.   (period).  If both /CASE and /NUMERIC are given, /NUMERIC takes precedence.
  13031.  
  13032. /RANGE:n[:m]
  13033.   Sort elements n through m of the array.  By default, the entire array
  13034.   from element 1 to its dimensioned size is sorted, which might produce
  13035.   surprising results if the array is not full; see example in Section 7.10.7.
  13036.   If ":m" is omitted from the range, the dimensioned size is used.  Thus,
  13037.   to sort an entire array, \&a[], including its 0th element, use
  13038.   "sort /range:0 &a".  You can also sort any desired section of an
  13039.   array, e.g. "sort /range:10:20 &a" or "sort /range:\%i:\%j-1 &b".
  13040.   As noted above, you can also specify a range in the array-name brackets.
  13041.   If you specify a range in the array-name brackets AND with a /RANGE
  13042.   switch, the ones in the brackets take precedence.
  13043.  
  13044. /REVERSE
  13045.   Sort in reverse order.  If this switch is not given, the array is
  13046.   sorted in ascending order.
  13047.  
  13048. Remember that numeric switch arguments can be numbers, arithmetic expressions,
  13049. or variables whose values are numbers or expressions, as illustrated in the
  13050. /RANGE examples above.
  13051.  
  13052. A typical sorting application might be to list students' test scores in
  13053. descending order.  Suppose you had the following records:
  13054.  
  13055. olaf      65
  13056. olga      98
  13057. ivan      83
  13058. xena     100
  13059.  
  13060. (and so on) stored in array \&s[] (e.g. by reading them from a file as
  13061. illustrated in section 7.10.7).  In these records, the student's name
  13062. is in columns 1-9 and the score in 10-12.  So to rearrange the list in
  13063. descending order of score:
  13064.  
  13065.   sort /key:10 /reverse &s
  13066.  
  13067. Then to list your top five students:
  13068.  
  13069.   for \%i 1 5 1 { echo \&s[\%i] }
  13070.  
  13071. Or more simply (see next section):
  13072.  
  13073.   show array a[1:5]
  13074.  
  13075. To illustrate the difference between a lexical and a numeric sort, suppose
  13076. you have the following records (the lines that are numbered, starting at
  13077. column 1) in array \&a[]:
  13078.  
  13079.     Column   1         2
  13080.     12345678901234567890
  13081.  
  13082.  1. Ivan      10.0
  13083.  2. Olaf      9.95
  13084.  3. Olga       101.5
  13085.  
  13086. ARRAY SORT /KEY:10 &a[] would order them 3,1,2, but
  13087. ARRAY SORT /KEY:10 /NUMERIC &a[] would order them 2,1,3.
  13088.  
  13089. 7.10.6. Displaying Arrays
  13090.  
  13091. The SHOW ARRAY command (or ARRAY SHOW) now accepts an optional array-name
  13092. argument:
  13093.  
  13094.   SHOW ARRAY \&a[]
  13095.  
  13096. (you can leave off the \, the \&, and/or the []'s if you like; "show array a"
  13097. is equivalent to "show array \&a[]").  When an array is specified, its
  13098. dimension is shown and all defined (non-empty) elements are listed.
  13099.  
  13100. Example:
  13101.  
  13102.   assign \%n \ffiles(*,&a)  ; Fill an array with filenames (Section 4.11.3)
  13103.   show array \&a[]          ; Show the array we just read
  13104.   array show \&a[]          ; Same as previous
  13105.   array sort \&a[]          ; Sort the array
  13106.   array show \&a[]          ; Show it after sorting
  13107.   array show \&a            ; Show it again
  13108.   array show &a             ; Show it again
  13109.   array show a              ; Show it again
  13110.  
  13111. (The final four commands demonstrate the alternative forms that are accepted
  13112. for the array name.)
  13113.  
  13114. If you SHOW ARRAY without giving an array name, all defined arrays are
  13115. listed by name and dimension, but their contents are not shown.
  13116.  
  13117. You can also show a piece of an array by including a subscript or range
  13118. within the array brackets:
  13119.  
  13120.   array show \&a[5]         ; Shows \&a[5]
  13121.   array show &a[3:8]        ; Shows \&a[3] through \&a[8]
  13122.   array show a[:\%n-1]      ; Shows \&a[0] through \&a[\%n-1]
  13123.  
  13124. 7.10.7. Other Array Operations
  13125.  
  13126. ARRAY DESTROY <arrayname>
  13127.   Destroys and undeclares the named array.  Subscripts or ranges are not
  13128.   accepted in this command.
  13129.  
  13130. ARRAY COPY <array1> <array2>
  13131.   Copies the first array to the second array.  If the target array has not
  13132.   been declared, it is created automatically with the same size as the first.
  13133.   If it has been declared, it will be used as declared; if the source array
  13134.   is larger, only as much of it as will fit is copied to the target array.
  13135.   Syntax for <array1> and <array2> is as in ARRAY SHOW (SHOW ARRAY).
  13136.  
  13137.   Example:
  13138.     .\%n := \ffiles(*,&a)  ; Create and load array A with a file list.
  13139.     array copy &a &b       ; Copy array A to array B.
  13140.  
  13141.   The ARRAY COPY command also lets you copy pieces of arrays by including
  13142.   range specifiers:
  13143.  
  13144.   ARRAY COPY \&a[4:27] \&b
  13145.     This copies \&a[] elements 4-27 to \&b[] elements 1-23, creating \&b[]
  13146.     if necessary or, if \&b[] is already declared, stopping early if its size
  13147.     is less than 23.
  13148.  
  13149.   ARRAY COPY \&a[4:27] \&b[12]
  13150.     This copies \&a[] elements 4-27 to \&b[] elements 12-35, creating \&b[]
  13151.     if necessary or, if \&b[] is already declared, stopping early if its size
  13152.     is less than 35.
  13153.  
  13154.   ARRAY COPY \&a[4:27] \&b[12:14]
  13155.     This copies \&a[] elements 4-6 to \&b[] elements 12-14, creating \&b[]
  13156.     if necessary or, if \&b[] is already declared, stopping early if its size
  13157.     is less than 14.
  13158.  
  13159.   ARRAY COPY \&a[17] \&b
  13160.     This copies all the elements of \&a[] starting with 17 until the last
  13161.     to \&b[], creating \&b[] if necessary or, if \&b[] is already declared,
  13162.     stopping early if \&b[] is not big enough.
  13163.  
  13164. ARRAY CLEAR <arrayname>
  13165.   Sets all the elements of the array to the empty value.  You may also include
  13166.   a range specifier to clear only a selected portion of the array; for example
  13167.   "array clear \&a[37:214]".  If the range is out of bounds, only the part of
  13168.   the array that is in bounds is cleared.
  13169.  
  13170. ARRAY SET <arrayname> [ <value> ]
  13171.   Sets all the elements of the array to the given value.  If no value is
  13172.   given, the array is cleared.  You may also include a range specifier to set
  13173.   only a selected portion of the array; for example "array set \&a[1:9] -1".
  13174.   If the range is out of bounds, only the part of the array that is in bounds
  13175.   is set.
  13176.  
  13177. ARRAY RESIZE <arrayname> <size>
  13178.   Resizes the given array.  If the <size> is greater than the array's current
  13179.   dimension, new empty elements are added to the end.  If the <size> is less
  13180.   than the current dimension, the extra elements are discarded.  Note: If you
  13181.   have stored the array size in element 0, ARRAY RESIZE does not change this
  13182.   value.  Alternative notation: ARRAY RESIZE <arrayname>[<size>].  For a
  13183.   practical example, see Section 7.10.11.
  13184.  
  13185. \farraylook(<pattern>,<arrayname>)
  13186.   This function returns the index of the first element of the given array
  13187.   that matches the given pattern (for details about pattern syntax, see
  13188.   section 4.9).  The array name can include a range specification to restrict
  13189.   the search to a given segment of the array.  If no elements match the
  13190.   pattern, -1 is returned.
  13191.  
  13192. \ftablelook(keyword,arrayname[,delimiter])
  13193.   Looks in the given "table", which must be sorted, for the given keyword.
  13194.   The keyword need not be spelled out in full.  Pattern-matching characters
  13195.   should not be included as part of the keyword.  The function returns the
  13196.   index of the table element that uniquely matches the given keyword, or -1
  13197.   if none match, or -2 if more than 1 match.
  13198.  
  13199. A "table" is an array that is sorted in lexical order; each of its elements
  13200. may contain multiple fields, delimited by the given delimiter character or,
  13201. if no delimiter is specifed, a colon (:).
  13202.  
  13203. The \farraylook() function does exactly what you tell it.  If you give it
  13204. a pattern that does not include wildcard characters (such as *, ?, etc), it
  13205. requires an exact match.  For example:
  13206.  
  13207.   \farraylook(oofa,&a)
  13208.  
  13209. searches for the first element of \&a[] whose value is "oofa".  But:
  13210.  
  13211.   \farraylook(oofa*,&a)
  13212.  
  13213. finds the first element whose value starts with "oofa", and;
  13214.  
  13215.   \farraylook(*oofa,&a)
  13216.  
  13217. finds the first element whose value ends with "oofa", and;
  13218.  
  13219.   \farraylook(*oofa*,&a)
  13220.  
  13221. finds the first element whose value contains "oofa".
  13222.  
  13223. Here's a simple demonstration of looking up patterns in arrays:
  13224.  
  13225.   local \&a[] \%x \%n
  13226.   declare \&a[] = zero one two three four five six seven eight nine ten
  13227.   while true {
  13228.       .\%x = 1
  13229.       .\%n = 0
  13230.       ask \%a { Pattern? }
  13231.       if not def \%a exit 0 Done.
  13232.       while <= \%x \fdim(&a) {
  13233.       .\%x := \farraylook(\%a,&a[\%x])
  13234.       if ( < \%x 0 ) break
  13235.           echo \flpad(\%x,3). \&a[\%x]
  13236.           increment \%x
  13237.           increment \%n
  13238.       }
  13239.       if ( < \%n 1 ) echo Pattern not found - "\%a"
  13240.   }
  13241.  
  13242. The array need not be sorted.  When a pattern is given, a search is performed;
  13243. if there is a match, the matching element's index and the element itself are
  13244. printed, and the search begins again at the next element.  Thus each matching
  13245. element is printed.  If none match, the "Pattern not found" message is
  13246. printed.  The process repeats for as many patterns as the user wants to type,
  13247. and terminates when the user types an empty pattern.
  13248.  
  13249. Now let's build a little command parser, consisting of a keyword table,
  13250. and a loop to look up the user's commands in it with \ftablelook().  In this
  13251. case the array elements have "fields" separated by colon (:) -- a keyword
  13252. and a value.  Keyword tables must be sorted if \tablelook() is to work right,
  13253. so after declaring and initializing the table array, we sort it.
  13254.  
  13255.   local \&k[] \%a \%i \%n
  13256.  
  13257.   array declare \&k[] = drive:9 do:8 discuss:7 live:6 spend:5 help:4 quit:0
  13258.  
  13259.   array sort &k                             ; Make sure array is sorted
  13260.   echo Type "help" for help.                ; Print greeting & instructions
  13261.  
  13262.   while true {                              ; Loop to get commands
  13263.       undefine \%a
  13264.       while not defined \%a {               ; Get a command
  13265.           ask \%a { Command? }
  13266.       }
  13267.       .\%n := \ftablelook(\%a,&k)           ; Look up the command
  13268.       switch \%n {                          ; Handle errors
  13269.         :-1, echo Not found - "\%a"         ; Doesn't match
  13270.              continue
  13271.         :-2, echo Ambiguous - "\%a"         ; Matches too many
  13272.              continue
  13273.       }
  13274.       switch \fword(\&k[\%n],2) {           ; Dispatch according to value
  13275.      :9, echo Driving..., break
  13276.      :8, echo Doing..., break
  13277.      :7, echo Discussing..., break
  13278.      :6, echo Living..., break
  13279.      :5, echo Spending..., break
  13280.          :4, echo { Commands (may be abbreviated):}
  13281.              for \%i 1 \fdim(&k) 1 {
  13282.                 echo {  \%i. \fword(\&k[\%i],1) }
  13283.              }
  13284.              break
  13285.          :0, exit 0 Bye!
  13286.          :default, stop 1 Internal error
  13287.       }
  13288.   }
  13289.  
  13290. In this example, keywords are "drive", "do", "discuss", etc, and their values
  13291. are unique numbers (values need not be numbers, and there need not be only one
  13292. value -- there can be 0, 1, 2, or more of them).  The user types a command,
  13293. which can be the whole word (like "help") or any abbreviation (like "hel",
  13294. "he", or just "h").  If this does not match any keywords, \ftablelook() returns
  13295. -1; if it matches more than one (as would "d"), it returns -2.  Otherwise
  13296. the array index is returned, 1 or higher.
  13297.  
  13298. Given the array index \%n, we can get the table values as follows:
  13299.  
  13300.   \fword(\&k[\%n],1) is the keyword (first field)
  13301.   \fword(\&k[\%n],2) is the value (second field, in this case a number)
  13302.  
  13303. In our example, we use the value (number) as the SWITCH variable.  As noted,
  13304. \fablelook() expects the array elements to contain multiple fields separated
  13305. by colon (:) (or other character that you specify, e.g. \ftablelook(\%a,&a,^))
  13306. and when matching the keyword, ignores the first delimiter and everything
  13307. after it.
  13308.  
  13309. 7.10.8. Hints for Using Arrays
  13310.  
  13311. C programmers are accustomed to out-of-bounds array references causing core
  13312. dumps or worse.  In C-Kermit:
  13313.  
  13314.  . A reference to an an out-of-bounds array element returns the empty string.
  13315.  
  13316.  . An attempt to set the value of an array element that is out of bounds
  13317.    or that has not been declared simply fails.
  13318.  
  13319. C programmers expect an array of size n to have elements 0 through n-1.
  13320. Fortran programmers expect the same array to have elements 1 through n.
  13321. C-Kermit accommodates both styles; when you declare an array of size n, it
  13322. has n+1 elements, 0 through n, and you can use the array in your accustomed
  13323. manner, 0-based or 1-based.
  13324.  
  13325. However, note that C-Kermit has certain biases towards 1-based arrays:
  13326.  
  13327.  . Assignment of file lists starts with element 1 (Section 7.10.3).
  13328.  
  13329.  . Assignment by \fsplit() starts with element 1 (Section 7.3).
  13330.  
  13331.  . Array initialization skips the 0th element.  To initialize a 0-based
  13332.    array, use something like this:
  13333.  
  13334.      declare \&a[3] = one two three
  13335.      .\&a[0] = zero
  13336.  
  13337.  . The ARRAY SORT command skips the 0th element unless you include /RANGE:0
  13338.  
  13339.  . The SHIFT command ignores element 0 of the \&_[] array.
  13340.  
  13341. The distinction between an array's dimensioned size and the number of elements
  13342. in the array is important when sorting.  To illustrate:
  13343.  
  13344.   declare \&a[100]                  ; Declare array &a with 100 elements
  13345.   fopen /read \%c oofa.txt          ; Open a file
  13346.   if fail...
  13347.   for \%i 1 \fdim(&a) 1 {           ; Read the file into the array
  13348.       fread \%c \&a[\%i]
  13349.       if fail break
  13350.   }
  13351.   fclose \%c
  13352.   if > \%i \fdim(&a) end 1 File has too many lines for array.
  13353.   .\%n ::= \%i - 1
  13354.   echo File has \%n line(s).
  13355.  
  13356. Let's say the file had 95 lines.  This leaves elements 96-100 of the array
  13357. empty.  Now suppose you sort the array and write out the result:
  13358.  
  13359.   sort &a                           ; Sort the whole array
  13360.   fopen /write \%o oofa.txt.sorted  ; Open an output file
  13361.   if fail ...
  13362.   for \%i 1 \%n 1 {                 ; Write out 95 records
  13363.       fwrite /line \%o \&a[\%i]
  13364.       if fail end 1 Write error
  13365.   }
  13366.   close write
  13367.  
  13368. You might be surprised at the contents of "oofa.txt.sorted" -- five empty
  13369. elements, 96-100, floated to the top of the array in the sort, and since your
  13370. write loop only had 95 iterations, the final 5 lines of the sorted file are
  13371. lost.
  13372.  
  13373. Therefore, when dealing with partially filled arrays -- especially when
  13374. sorting them -- remember to specify the number of elements.  A handy way of
  13375. recording an array's "true" size is to put it in the 0th element.  That way,
  13376. it "travels with the array".  To illustrate (continuing the previous example
  13377. at the "close read" statement):
  13378.  
  13379.   close read
  13380.   if > \%i \fdim(&a) end 1 File has too many lines for array.
  13381.   .\&a[0] ::= \%i - 1     ; Assign number of lines to \&a[0].
  13382.   echo File has \&a[0] line(s).
  13383.   sort /range:1:\&a[0] &a
  13384.   open write oofa.txt.sorted
  13385.   if fail ...
  13386.   for \%i 1 \&a[0] 1 {
  13387.       writeln file \&a[\%j]
  13388.       if fail end 1 Write error
  13389.   }
  13390.   close write
  13391.  
  13392. Note the SORT switch, /RANGE:1:\&a[0].  This keeps the sort 1-based, and uses
  13393. element 0 of the array as its size indicator.
  13394.  
  13395. Finally, note that even though some commands or functions might put a size
  13396. in array element 0, no built-in functions or commands depend on a size
  13397. actually being there.  Thus you are perfectly free to replace the size with
  13398. something else and treat the array as 0-based.
  13399.  
  13400. 7.10.9. Do-It-Yourself Arrays
  13401.  
  13402. Kermit's \&x[] arrays are nice because of the accompanying built-in
  13403. functionality -- ARRAY commands, built-in functions that load and search
  13404. arrays, automatic evaluation of arithmetic expressions within the subscript
  13405. brackets, and so on.  Yet they also have certain limitations:
  13406.  
  13407.  a. Except when created by dynamic loading (e.g. by \ffiles()) they must
  13408.     be declared and dimensioned in advance.
  13409.  
  13410.  b. Indices must be numeric, positive, and in range.
  13411.  
  13412.  c. There can be only one dimension.  Matrices or other higher-dimensioned
  13413.     arrays are not available.
  13414.  
  13415. But none of this is to say you can't invent any kind of data structure you
  13416. like.  In Section 7.9.2 you can see some examples.  Here's another (courtesy
  13417. of Dat Thuc Nguyen), in which a pair of matrices is created and then added: no
  13418. dimensioning necessary.
  13419.  
  13420.   .row = 4
  13421.   .col = 9
  13422.  
  13423.   ; MACRO TO PRINT A MATRIX
  13424.   define PMATRIX {
  13425.       echo Matrix \%1:
  13426.       for \%r 1 \m(row) 1 {
  13427.       for \%c 1 \m(col) 1 {
  13428.           xecho \flpad(\m(\%1[\%r][\%c]),4)
  13429.       }
  13430.       echo
  13431.       }
  13432.       echo
  13433.   }
  13434.   ; CREATE MATRICES A AND B
  13435.   for \%r 1 \m(row) 1 {
  13436.       for \%c 1 \m(col) 1 {
  13437.       _eval A[\%r][\%c] \%r + \%c
  13438.       _eval B[\%r][\%c] \%r * \%c
  13439.       }
  13440.   }
  13441.   ; CREATE MATRIX C = SUM OF MATRIX A AND MATRIX B
  13442.   for \%r 1 \m(row) 1 {
  13443.       for \%c 1 \m(col) 1 {
  13444.       _eval C[\%r][\%c] \m(A[\%r][\%c]) + \m(B[\%r][\%c])
  13445.       }
  13446.   }
  13447.   pmatrix A  ; Print Matrix A
  13448.   pmatrix B  ; Print Matrix B
  13449.   pmatrix C  ; Print Matrix C
  13450.  
  13451. In the example, we use matrix-like notation to create macros with names
  13452. like "A[1][1]", "B[3][7]", and so on.
  13453.  
  13454. 7.10.10. Associative Arrays
  13455.  
  13456. An associative array is a special kind of Do-It-Yourself array.  It differs
  13457. from a regular array in that its indices need not be numbers -- they can be
  13458. anything at all -- words, filenames, names of months, any character string at
  13459. all, and that it doesn't have to be (and in fact can't be) declared.  An
  13460. associative array element is simply a macro whose name ends with an index
  13461. enclosed in angle brackets, for example:
  13462.  
  13463.   file<oofa.txt>
  13464.  
  13465. More formally:
  13466.  
  13467.   basename<index>
  13468.  
  13469. An associative array is a collection of all associative array elements that
  13470. have the same basename.  Any number of associative arrays, each with any
  13471. number of elements, can exist at the same time.
  13472.  
  13473. An associative array element can be assigned a value, such as "1", just like
  13474. any other macro:
  13475.  
  13476.   define file<oofa.txt> 1     ; Give "file<oofa.txt>" the value "1".
  13477.  
  13478. or:
  13479.  
  13480.   assign file<oofa.txt> \%a   ; Give it the value of the variable \%a.
  13481.  
  13482. However, since an associative array element is a macro, it may not have an
  13483. emtpy (null) value, since assigning an empty value to a macro undefines the
  13484. macro.
  13485.  
  13486. You can refer to the value of an associative array element using the familiar
  13487. notation for macro values:
  13488.  
  13489.   echo \m(file<oofa.txt>)     ; Echo the value of "file<oofa.txt>".
  13490.  
  13491. Associative arrays are most useful, however, when the value of the index is
  13492. a variable.  In that case, you must use the "hidden" forms of the DEFINE or
  13493. ASSIGN commands that evaluate the macro name before making the assignment (see
  13494. "Using C-Kermit", page 457).  Example:
  13495.  
  13496.   define \%f oofa.txt
  13497.   _define file<\%f> 1
  13498.   echo file<\%f> = \m(file<\%f>)
  13499.  
  13500. prints:
  13501.  
  13502.   file<oofa.txt> = 1
  13503.  
  13504. and then:
  13505.  
  13506.   _increment file<\%f>
  13507.   echo file<\%f> = \m(file<\%f>)
  13508.  
  13509. prints:
  13510.  
  13511.   file<oofa.txt> = 2
  13512.  
  13513. What are associative arrays good for?  The classic example is "word counts":
  13514. finding the number of times each word is used in a text without knowing in
  13515. advance what the words are.  Without associative arrays, your program would
  13516. have to build a table of some kind, and every time a word was encountered,
  13517. look it up in the table to find its position and counter, or add it to the
  13518. table if it wasn't found -- a time-consuming and laborious process.
  13519. Associative arrays, however, let you use the word itself as the table index
  13520. and therefore sidestep all the table building and lookups.
  13521.  
  13522. Let's work through a practical example.  Suppose you have a file-transfer log
  13523. in which each line is composed of a number of blank-separated fields, and the
  13524. 9th field is a filename (which happens to be the format of certain FTP server
  13525. logs, as well as of C-Kermit's new FTP-format transaction log, described in
  13526. Section 4.17.2), for example:
  13527.  
  13528.   Wed Jul 14 09:35:31 1999 22 xx.mit.edu 13412 /pub/ftp/mm/intro.txt ....
  13529.  
  13530. and you want to find out how many times each file was transferred.  The
  13531. following code builds an associative array, file<>, containing the counts for
  13532. each file:
  13533.  
  13534.   local name line max \%c \%n          ; Declare local variables
  13535.   fopen /read \%c /var/log/ftpd.log    ; Open the log file (Section 1.22)
  13536.   if fail exit 1 Can't open log        ; Check
  13537.   while true {                         ; Loop for each record
  13538.       fread /line \%c line             ; Read a line
  13539.       if fail break                    ; Check for end of file
  13540.       .name := \fword(\m(line),9,{ })  ; Get 9th field = filename (Sec 7.3)
  13541.       _increment file<\m(name)>        ; Increment its counter (Sec 7.9.2)
  13542.   }
  13543.   fclose \%c                           ; Close file when done.
  13544.  
  13545. Note that _INCREMENT (and INCREMENT, and [_]DECREMENT) treat an empty (i.e.
  13546. nonexistent) variable as having a value of 0, and therefore creates the
  13547. variable with a value of 1.
  13548.  
  13549. At this point, if you told Kermit to "show macro file<", it would list the
  13550. associative array.  But since you don't necessarily know the names of the
  13551. files in the array, or even how many elements are in the array, how can you
  13552. use it in a script program?
  13553.  
  13554. The idea of creating macro names that include character-string indices
  13555. enclosed in angle brackets is perfectly arbitrary and doesn't depend on any
  13556. Kermit features that weren't already there -- we could just as easily have
  13557. used some other notation, such as "file[index]", "file:index", or
  13558. "file.index", and the code above would have worked just as well (with the
  13559. corresponding syntax adjustments).  But to be able to use an associative array
  13560. in a program after the array is built, we need a method of accessing all its
  13561. elements without knowing in advance what they are.  That's where the chosen
  13562. notation comes in.
  13563.  
  13564. First of all, any macro name that ends with "<xxx>" (where "xxx" is any
  13565. string) is case sensitive, unlike all other macro names, which are case
  13566. independent.  To illustrate, "file<oofa.txt>" and "file<OOFA.TXT>" are two
  13567. distinct macros, whereas "OOFA", "Oofa", and "oofa", when used as macro names,
  13568. are all the same.
  13569.  
  13570. Second, the new \faaconvert() function converts an associative array (that is,
  13571. all macros with names of the form "base<index>" that have the same "base"
  13572. part) into a pair of regular arrays and returns the number of elements:
  13573.  
  13574.   \faaconvert(name,&a[,&b])
  13575.  
  13576. "name" is the name of the associative array, without the angle brackets or
  13577. index ("file" in our example).
  13578.  
  13579. The second argument is the name of a regular array in which to store the
  13580. indices of the associative array (filenames in our example); if an array of
  13581. this name already exists, it is destroyed unless the array is LOCAL.  The
  13582. third argument is the name of another regular array in which to store the
  13583. values (the counts in our example), with the same rules about array name
  13584. collisions.  If you care only about the indices and not the values, you can
  13585. omit the third argument to \faaconvert().  In any case, the associative array
  13586. is converted, not copied: its elements are moved to the specified regular
  13587. arrays, so after conversion the original associative array is gone.
  13588.  
  13589. As with other array-loading functions, \faaconvert() sets element 0 of each
  13590. array to the number of elements in the array.
  13591.  
  13592. To continue our example:
  13593.  
  13594.   .max := 0                                   ; Maximum count
  13595.   .\%n := \faaconvert(file,&a,&b)             ; Convert
  13596.   for \%i 1 \%n 1 {                           ; Loop through values
  13597.       echo \flpad(\%i,3). \&a[\%i]: \&b[\%i]  ; Echo this pair
  13598.       if ( > \&b[\%i] \m(max) ) {             ; Check for new maximum
  13599.           .name := \&a[\%i]
  13600.           .max  := \&b[\%i]
  13601.       }
  13602.   }
  13603.   echo Most popular file: \m(name), accesses: \m(max)
  13604.  
  13605. This lists the files and counts and then announces which file has the highest
  13606. count.
  13607.  
  13608. Now suppose you want to sort the array pair created from an associative array.
  13609. In our example, \&a[] contains filenames, and \&b[] contains the associated
  13610. counts.  Here we take advantage of the ARRAY SORT command's ability to sort a
  13611. second array according to the first one:
  13612.  
  13613.   array sort /reverse /numeric &b &a          ; Descending sort by count
  13614.  
  13615. Now to see the top five files and their counts:
  13616.  
  13617.   echo The top 5 files are:
  13618.   for \%i 1 5 1 {                             ; Loop through top 5 values
  13619.       echo \flpad(\%i,3). \&a[\%i]: \&b[\%i]  ; Echo this pair
  13620.   }
  13621.  
  13622. 7.10.11. Transferring Array Contents to Other Computers
  13623.  
  13624. The SEND /ARRAY:arrayname command (Section 4.7.1) allows you to send the
  13625. contents of any array, or any contiguous segment of it, in either text or
  13626. binary mode to another computer, using Kermit protocol.  When used in
  13627. conjunction with C-Kermit's other features (the array features described in
  13628. this section; the file i/o package from Section 1.22; its decision-making,
  13629. pattern-matching, and string manipulation capabilities, and so on) the
  13630. possibilities are endless: extracts of large files, remote database queries,
  13631. ..., all without recourse to system-dependent mechanisms such UNIX pipes and
  13632. filters, thus ensuring cross-platform portability of scripts that use these
  13633. features.
  13634.  
  13635. When sending an array in text mode, Kermit appends a line terminator to each
  13636. array element, even empty ones, and it also converts the character set from
  13637. your current FILE character-set to your current TRANSFER character-set, if
  13638. any.  No conversions are made or line terminations added in binary mode.  For
  13639. example, the following array:
  13640.  
  13641.   dcl \&a[] = One Two Three Four Five Six
  13642.  
  13643. is sent as six lines, one word per line, in text mode, and as the bare
  13644. unterminated string "OneTwoThreeFourFiveSix" in binary mode.
  13645.  
  13646. You should always include a /TEXT or /BINARY switch in any SEND /ARRAY command
  13647. to force the desired transfer mode, otherwise you're likely to be surprised
  13648. by the effects described in Section 4.3.
  13649.  
  13650. Here are some examples:
  13651.  
  13652. send /text /array:\&a[]
  13653.   Sends the entire contents of the array \&a[] in text mode.  Since an
  13654.   as-name is not included, the receiver is told the filename is _array_a_.
  13655.  
  13656. send /text /array:&a[]
  13657. send /text /array:a[]
  13658. send /text /array:&a
  13659. send /text /array:a
  13660.   These are all equivalent to the previous example.
  13661.  
  13662. send /text /array:&a /as-name:foo.bar
  13663.   As above, but the array is sent under the name foo.bar.
  13664.  
  13665. send /text /array:&a[100:199] /as:foo.bar
  13666.   As above, but only the elements from 100 through 199 are sent.
  13667.  
  13668. In text-mode transfers, character sets are translated according to your
  13669. current settings, just as for text files.  In binary mode, of course, there
  13670. is no character-set translation or other conversion of any kind.  But
  13671. remember that array elements can not contain the NUL (ASCII 0) character,
  13672. since they are implemented as NUL-terminated strings.
  13673.  
  13674. Here's an example that shows how to send all the lines (up to 1000 of them)
  13675. from a file animals.txt that contain the words "cat", "dog", or "hog" (see
  13676. section 4.9 about pattern matching):
  13677.  
  13678.   declare \&a[1000]
  13679.   fopen /read \%c animals.txt
  13680.   if fail exit 1
  13681.   .\%i = 0
  13682.   while true {
  13683.       fread \%c line
  13684.       if fail break
  13685.       if match {\m(line)} {*{cat,[dh]og}*} {
  13686.           increment \%i
  13687.           if ( > \%i \fdim(&a) ) break
  13688.           .\&a[\%i] := \m(line)
  13689.       }
  13690.   }
  13691.   fclose \%c
  13692.   send /array:a[1:\%i] /text
  13693.  
  13694. Note that we are careful to send only the part of the array that was filled,
  13695. not the entire array, because there are likely to be lots of unused elements
  13696. at the end, and these would be sent as blank lines otherwise.
  13697.  
  13698. This example raises an interesting question: what if we want to send ALL the
  13699. matching lines, even if there are more than 1000 of them, but we don't know
  13700. the number in advance?  Clearly the problem is limited by Kermit's (and the
  13701. computer's) memory.  If there are a thousand trillion matching lines, they
  13702. most likely will not fit in memory, and in this case the only solution is to
  13703. write them first to a temporary file on mass storage and then send the
  13704. temporary file and delete it afterwards.
  13705.  
  13706. However, when the selection is likely to fit in memory, the once-familiar
  13707. technique of initial allocation with extents can be used:
  13708.  
  13709.       if match {\m(line)} {*{cat,[dh]og}*} {
  13710.           increment \%i
  13711.       if ( > \%i \fdim(&a) ) {
  13712.           array resize a \fdim(&a)+100
  13713.           if fail stop 1 MEMORY FULL
  13714.           echo NEW DIMENSION: \fdim(&a)
  13715.       }
  13716.           .\&a[\%i] := \m(line)
  13717.       }
  13718.  
  13719. This grows the array in chunks of 100 as needed.
  13720.  
  13721. 7.11. OUTPUT Command Improvements
  13722.  
  13723. LINEOUT [ <text> ]
  13724.   This command is exactly like OUTPUT, except it supplies a carriage return
  13725.   at the end of the <text>.  "lineout exit" is exactly the same as
  13726.   "output exit\13".
  13727.  
  13728. SET OUTPUT SPECIAL-ESCAPES { ON, OFF }
  13729.   This command lets you tell C-Kermit whether to process \N, \L, and \B
  13730.   specially in an OUTPUT command, as distinct from other \-sequences (such
  13731.   as \%a, \13, \v(time), etc).  Normally the special escapes are handled.
  13732.   Use SET OUTPUT SPECIAL-ESCAPES OFF to disable them.
  13733.  
  13734. Disabling special escapes is necessary in situations when you need to transmit
  13735. lines of data and you have no control over what is in the lines.  For example,
  13736. a file oofa.txt that contains:
  13737.  
  13738.   This is a file
  13739.   It has \%a variables in it
  13740.   And it has \B in it.
  13741.   And it has \L in it.
  13742.   And it has \N in it.
  13743.   And this is the last line.
  13744.  
  13745. can be sent like this:
  13746.  
  13747.   local line
  13748.   set output special-escapes off
  13749.   fopen /read \%c oofa.txt
  13750.   if fail stop 1 Can't open oofa.txt
  13751.   while success {
  13752.       fread \%c line
  13753.       if fail break
  13754.       ; Add filtering or processing commands here...
  13755.       output \m(line)\13
  13756.   }
  13757.  
  13758. 7.12. Function and Variable Diagnostics
  13759.  
  13760. In C-Kermit 6.0 and earlier, the only diagnostic returned by a failing
  13761. function call was an empty value, which (a) could not be distinguished from
  13762. an empty value returned by a successful function call; (b) did not give any
  13763. indication of the cause of failure; and (c) did not cause the enclosing
  13764. statement to fail.  C-Kermit 7.0 corrects these deficiencies.
  13765.  
  13766. SET FUNCTION DIAGNOSTICS { ON, OFF }
  13767.   when ON, allows built-in functions to return diagnostic messages when
  13768.   improperly referenced, instead of an empty string.  FUNCTION DIAGNOSTICS are
  13769.   ON by default.  When OFF, improperly referenced functions continue to return
  13770.   an empty string.  This command also affects built-in variables; in this case,
  13771.   an error message is returned only if the variable does not exist.  When
  13772.   FUNCTION DIAGNOSTICS are ON, the error message is also printed.
  13773.  
  13774. For variables, the only message is:
  13775.  
  13776.   <ERROR:NO_SUCH_VARIABLE:\v(name)>
  13777.  
  13778. where "name" is the name of the nonexistent variable.
  13779.  
  13780. For functions, the diagnostic message is:
  13781.  
  13782.   <ERROR:message:\fname()>
  13783.  
  13784. where "message" is replaced by a message, and "name" is replaced by the
  13785. function name, e.g. <ERROR:ARG_NOT_NUMERIC:\fmod()>.  Messages include:
  13786.  
  13787.   ARG_BAD_ARRAY       An argument contains a malformed array reference.
  13788.   ARG_BAD_DATE        An argument contains a malformed date and/or time.
  13789.   ARG_BAD_PHONENUM    An argument contains a malformed telephone number.
  13790.   ARG_BAD_VARIABLE    An argument contains a malformed \%x variable.
  13791.   ARG_INCOMPLETE      An argument is incomplete (e.g. a broken Base64 string).
  13792.   ARG_EVAL_FAILURE    An argument could not be evaluated (internal error).
  13793.   ARG_NOT_ARRAY       An argument references an array that is not declared.
  13794.   ARG_NOT_NUMERIC     An argument that must be integer contains non-digits.
  13795.   ARG_NOT_FLOAT       An argument has bad floating-point number format.
  13796.   ARG_NOT_VARIABLE    An argument that must be a variable is not a variable.
  13797.   ARG_OUT_OF_RANGE    An argument's numeric value is too big or too small,
  13798.                       or an argument contains illegal characters (e.g. a hex
  13799.                       or Base-64 string).
  13800.   ARG_TOO_LONG        An argument's value is too long.
  13801.   ARRAY_FAILURE       Failure to create an array.
  13802.   DIVIDE_BY_ZERO      Execution of the function would cause division by zero.
  13803.   FLOATING_POINT_OP   Execution error in a floating-point operation.
  13804.   FILE_NOT_FOUND      Filename argument names a file that can't be found.
  13805.   FILE_NOT_READABLE   Filename argument is not a regular file.
  13806.   FILE_NOT_ACCESSIBLE Filename argument names a file that is read-protected.
  13807.   FILE_ERROR          Other error with filename argument.
  13808.   FILE_NOT_OPEN       A file function was given a channel that is not open.
  13809.   FILE_ERROR_-n       A file function got error -<n> (Section 1.22).
  13810.   LOOKUP_FAILURE      Error looking up function (shouldn't happen).
  13811.   MALLOC_FAILURE      Failure to allocate needed memory (shouldn't happen).
  13812.   NAME_AMBIGUOUS      The function is not uniquely identified.
  13813.   MISSING_ARG         A required argument is missing.
  13814.   NO_SUCH_FUNCTION    An argument references a function that is not defined.
  13815.   NO_SUCH_MACRO       An argument references a macro that is not defined.
  13816.   RESULT_TOO_LONG     The result of a function is too long.
  13817.   UNKNOWN_FUNCTION    Internal error locating function (shouldn't happen).
  13818.  
  13819. Examples:
  13820.  
  13821.   assign \%m \fmod()
  13822.   ?<ERROR:MISSING_ARG:\fmod()>
  13823.   echo "\fcontents(\%m)"
  13824.   "<ERROR:MISSING_ARG:\fmod()>"
  13825.   echo \fmod(3,x)
  13826.   ?<ERROR:ARG_NOT_NUMERIC:\fmod()>
  13827.   echo \fmod(3,4-2*2)
  13828.   ?<ERROR:DIVIDE_BY_ZERO:\fmod()>
  13829.  
  13830. Notice the use of \fcontents() in echoing the value of a variable that
  13831. contains a returned error message.  That's because the error message includes
  13832. the name of the variable or function that failed, so you must use \fcontents()
  13833. to prevent it from being evaluated again -- otherwise the same error will
  13834. occur.
  13835.  
  13836. The handling of function and variable errors is controlled by:
  13837.  
  13838. SET FUNCTION ERROR { ON, OFF }
  13839.   Tells whether invalid function calls or variable references should cause
  13840.   command errors.  FUNCTION ERROR is ON by default.  When ON, and an error is
  13841.   diagnosed in a built-in function or variable, the command that includes the
  13842.   function call or variable reference fails.  The failing command can be
  13843.   handled in the normal way with IF FAILURE / IF SUCCESS, SET TAKE ERROR, or
  13844.   SET MACRO ERROR.
  13845.  
  13846. When FUNCTION DIAGNOSTICS is OFF, there is no error message.
  13847.  
  13848. SHOW SCRIPTS displays the current FUNCTION DIAGNOSTICS and ERROR settings.
  13849.  
  13850. 7.13. Return Value of Macros
  13851.  
  13852. In C-Kermit 5A and 6.0, there are two ways to return one level from a macro:
  13853. RETURN <value> and END <number> <text>.  When RETURN is used, the <value>,
  13854. which can be a number or a text string, is assigned to \v(return).  When
  13855. END was used, however, \v(return) was not set.  SUCCESS/FAILURE was set
  13856. according to whether the <number> was zero, and the <text> was printed, but
  13857. the actual value of the <number> was lost.
  13858.  
  13859. In C-Kermit 7.0, the END <number> is available in the \v(return) variable.
  13860.  
  13861. 7.14. The ASSERT, FAIL, and SUCCEED Commands.
  13862.  
  13863. The ASSERT command is just like the IF command, but without a command to
  13864. execute.  It simply succeeds or fails, and this can be tested by a subsequent
  13865. IF SUCCESS or IF FAILURE command.  Example:
  13866.  
  13867.   ASSERT = 1 1
  13868.   IF SUCCESS echo 1 = 1.
  13869.  
  13870. The FAIL command does nothing, but always fails.
  13871. The SUCCEED command does nothing, but always succeeds.
  13872.  
  13873. These commands are handy in debugging scripts when you want to induce a
  13874. failure (or success) that normally would not occur, e.g. for testing blocks
  13875. of code that normally are not executed.
  13876.  
  13877. 7.15. Using Alarms
  13878.  
  13879. Alarms may be set in two ways:
  13880.  
  13881.   SET ALARM <number>
  13882.     Sets an alarm for the given number of seconds "from now", i.e. in the
  13883.     future, relative to when the SET ALARM command was given.  Examples:
  13884.       set alarm 60        ; 60 seconds from now
  13885.       set alarm +60       ; The same as "60"
  13886.       set alarm -60       ; Not legal - you can't set an alarm in the past.
  13887.       set alarm 60*60     ; 60 minutes from now.
  13888.       set alarm \%a+10    ; You can use variables, etc.
  13889.  
  13890.   SET ALARM <hh:mm:ss>
  13891.     Sets an alarm for the specified time.  If the given time is earlier than
  13892.     the current time, the alarm is set for the given time in the next day.
  13893.     You may give the time in various formats:
  13894.       set alarm 15:00:00  ; 3:00:00pm
  13895.       set alarm 3:00:00pm ; 3:00:00pm
  13896.       set alarm 3:00pm    ; 3:00:00pm
  13897.       set alarm 3pm       ; 3:00:00pm
  13898.  
  13899.   SHOW ALARM
  13900.     Displays the current alarm, if any, in standard date-time format
  13901.     (see Section 1.6): yyyymmdd hh:mm:ss.
  13902.  
  13903.   IF ALARM <command>
  13904.     Executes the <command> if an alarm has been set and the alarm time
  13905.     has passed.
  13906.  
  13907.   XIF ALARM { <command-list> } [ else { <command-list> } ]
  13908.     Executes the <command-list> if an alarm has been set and the alarm time
  13909.     has passed.  Otherwise, if an ELSE part is given, its command-list is
  13910.     executed.
  13911.  
  13912.   CLEAR ALARM
  13913.     Clears the alarm.
  13914.  
  13915. Only one alarm may be set at a time.
  13916.  
  13917. Example: Suppose you have a script that is always running, and that transfers
  13918. files periodically, and that keeps a transaction log.  Suppose you want to
  13919. start a new transaction log each day:
  13920.  
  13921.   log transactions \v(date).log
  13922.   set alarm 00:00:00                     ; Set an alarm for midnight
  13923.   while true {                           ; Main script loop
  13924.       xif alarm {                        ; If the alarm time is past...
  13925.           close transactions             ; Close current log
  13926.           log transactions \v(date).log  ; Start new one
  13927.           pause 1                        ; To make sure 00:00:00 is past
  13928.           set alarm 00:00:00             ; Set a new alarm
  13929.       }
  13930.       ; put the rest of the script here...
  13931.   }
  13932.  
  13933. Note that IF ALARM -- no matter whether it succeeds or fails -- does NOT
  13934. clear an expired alarm.  Thus, once an alarm has expired, every IF ALARM will
  13935. succeed until the alarm is cleared (with the CLEAR ALARM command) or reset
  13936. with a new SET ALARM command.
  13937.  
  13938. 7.16. Passing Arguments to Command Files
  13939.  
  13940. Beginning in version 7.0, C-Kermit accepts arguments on the TAKE command line,
  13941. for example:
  13942.  
  13943.   C-Kermit> take oofa.ksc one two {this is three} four
  13944.  
  13945. This automatically sets the variables \%1 through \%9 to the arguments,
  13946. and \%0 to the name of the file, in this case:
  13947.  
  13948.   \%0 = /usr/olga/oofa.ksc
  13949.   \%1 = one
  13950.   \%2 = two
  13951.   \%3 = this is three
  13952.   \%4 = four
  13953.  
  13954. and \%5..\%9 are undefined (empty).  Arguments past the ninth are available in
  13955. the \&_[] argument-vector array (Section 7.5).
  13956.  
  13957. The variables are those at the current macro level.  Thus, if the TAKE command
  13958. is executed from within a macro, the macro's arguments are replaced by those
  13959. given on the TAKE command line (but only if at least one argument is given).
  13960. The command shown above is exactly equivalent to:
  13961.  
  13962.   assign \%0 /usr/olga/oofa.ksc
  13963.   assign \%1 one
  13964.   assign \%2 two
  13965.   assign \%3 this is three
  13966.   assign \%4 four
  13967.   assign \%5
  13968.   assign \%6
  13969.   assign \%7
  13970.   assign \%8
  13971.   assign \%9
  13972.   take oofa.ksc
  13973.  
  13974. Remember, the variables \%0..\%9 are on the macro call stack, and command
  13975. files are independent of the macro stack.  Thus, if a command file TAKEs
  13976. another command file and passes arguments to it, the variables are changed
  13977. from that point on for both files, and so forth for all levels of nested
  13978. command files without intervening macro invocations.
  13979.  
  13980. It would have been possible to change C-Kermit to use the overall command
  13981. stack, rather than the macro stack, for arguments -- this would have made
  13982. TAKE work exactly like DO, which is "nicer", but it would also have broken
  13983. countless existing scripts.  However, the new SHIFT command (Section 7.5)
  13984. makes it possible to create an alternative TAKE command that does indeed
  13985. save and restore the argument variables at its own level around execution
  13986. of a command file:
  13987.  
  13988.   define mtake {
  13989.      local \%f
  13990.      assign \%f \fcontents(\%1)
  13991.      shift
  13992.      take \%f
  13993.   }
  13994.  
  13995. C-Kermit 7.0 also supports a new, easier way to pass arguments to scripts
  13996. from the system command line:
  13997.  
  13998.   kermit filename arg1 arg2 arg3 ...
  13999.  
  14000. in which arg1, arg2, arg3 (etc) are arguments for the script (whose filename
  14001. is given), and are assigned to \%1, \%2, ... \%9.  The filename is assigned to
  14002. \%0.  This applies equally to "Kerbang" scripts in UNIX (Section 7.19).
  14003. For example, suppose you have a file called "showargs" containing the
  14004. following lines:
  14005.  
  14006.   #!/usr/local/bin/kermit +
  14007.   echo Hello from \%0
  14008.   show args
  14009.   exit
  14010.  
  14011. (except not indented, since the "#!" line must be on the left margin).  If
  14012. you give this file execute permission:
  14013.  
  14014.   chmod +x showargs
  14015.  
  14016. then you can run it exactly as you would run a UNIX shell script, e.g.:
  14017.  
  14018.   $ showargs one two three
  14019.  
  14020. $ x one two three
  14021. Hello from /usr/olga/showargs
  14022. Top-level arguments (\v(argc) = 4):
  14023.  \&_[0] = /usr/olga/showargs
  14024.  \&_[1] = one
  14025.  \&_[2] = two
  14026.  \&_[3] = three
  14027.  
  14028. Furthermore, the \&_[] array now contains the filename, if one was given as
  14029. the first command line argument, or it is a "Kerbang" script, in element 0.
  14030.  
  14031. Otherwise element 0 is program name, and elements 1 through \v(argc)-1 contain
  14032. the command-line arguments, if any, that appear after "--" or "=", if any.
  14033. This array is saved and restored around macro calls; recall that inside macros
  14034. it contains the macro argument vector (allowing you to access arguments
  14035. programmatically, and to have more than 9 of them).
  14036.  
  14037. At top level, notice the difference between the \&@[] and \&_[] arrays.  The
  14038. former includes C-Kermit options; the latter omits them.
  14039.  
  14040. 7.17. Dialogs with Timed Responses
  14041.  
  14042. The ASK, ASKQ, GETOK, and GETC commands (let's call them the "ASK-class
  14043. commands") let you write scripts that carry on dialogs with the user, asking
  14044. them for text, a Yes/No answer, or a character, respectively.  Prior to
  14045. C-Kermit 7.0, these questions would always wait forever for an answer.  In
  14046. C-Kermit 7.0, you may specify a time limit for them with the new command:
  14047.  
  14048. SET ASK-TIMER number
  14049.   Sets a time-limit on ASK-CLASS commands to the given number of seconds.
  14050.   If the number is 0 or less, there is no time limit and these commands wait
  14051.   forever for a response.  Any timer that is established by this command
  14052.   remains in effect for all future ASK-class commands until another SET
  14053.   ASK-TIMER command is given (e.g. with a value of 0 to disable ASK timeouts).
  14054.  
  14055. An ASK-class command that times out returns a failure status.  You can test
  14056. explicitly for a timeout with:
  14057.  
  14058.   IF ASKTIMEOUT <command>
  14059.  
  14060. 7.18. Increased Flexibility of SWITCH Case Labels
  14061.  
  14062. Prior to C-Kermit 7.0 / K95 1.1.18, the case labels in SWITCH statements
  14063. were string constants.
  14064.  
  14065. Now case labels can be variables, function calls, or any mixture of these
  14066. with each other and/or with regular characters.
  14067.  
  14068. Furthermore, after the case label is evaluated, it is treated not as a string
  14069. constant, but as a pattern against which the SWITCH variable is matched
  14070. (Section 4.9.1).
  14071.  
  14072. This introduces a possible incompatibility with previous releases, since
  14073. the following characters in case labels are no longer taken literally:
  14074.  
  14075.   \ * ? [ {
  14076.  
  14077. Any scripts that previously included any of these characters in case labels
  14078. must now quote them with backslash (\).
  14079.  
  14080. 7.19. "Kerbang" Scripts
  14081.  
  14082. In UNIX only, Kermit scripts can be stored in files and run "directly",
  14083. without starting Kermit first (as noted on page 467 of the manual), just as a
  14084. shell script can be "run" as if it were a program.  This section amplifies on
  14085. that idea a bit, and presents some new aspects of version 7.0 that make it
  14086. easier to write and run Kerit scripts directly.
  14087.  
  14088.   NOTE: On non-UNIX platforms, such as VMS or Windows, Kerbang scripts can
  14089.   be run as "kermit + scriptfilename arg1 arg2 arg3 ...".  Windows 95/98/NT
  14090.   file associations do not allow for the passing of parameters.  In VMS,
  14091.   however, you can achieve the Kerbang effect by defining a symbol, as
  14092.   in this example:
  14093.  
  14094.     $ autotelnet :== "$SYS$TOOLS:KERMIT.EXE + AUTOTELNET.KSC"
  14095.  
  14096.   and then running the script like any other command:
  14097.  
  14098.     $ autotelnet xyzcorp.com myuserid
  14099.  
  14100.   See section 9.3 for an explanation of the "+" symbol.
  14101.  
  14102. UNIX shell scripts can specify which shell should run them by including a
  14103. "shebang" line at the top, e.g.:
  14104.  
  14105.   #!/bin/sh
  14106.  
  14107. (but not indented; the shebang line must be on the left margin).  The term
  14108. "shebang" is a contraction of "shell" and "bang".  "Bang" is a slang word for
  14109. the exclamation mark ("!"); "shebang" itself is an American slang word used in
  14110. in the phrase "the whole shebang".
  14111.  
  14112. We can run Kermit scripts directly too, by including a "shebang" line that
  14113. names Kermit as the "shell"; thus we call these "Kerbang" scripts.  This
  14114. mechanism has been considerably simplified in C-Kermit 7.0 to facilitate
  14115. C-Kermit's use a scripting tool just like any of the UNIX shells or scripting
  14116. languages.  The rules are the same as for shell scripts:
  14117.  
  14118.  a. The first line of the Kermit script must begin with "#!" immediately
  14119.     followed by the full pathname of the program that will execute the
  14120.     script (in this case, C-Kermit rather than a UNIX shell), followed by
  14121.     any Kermit command-line options.  To suppress execution of the C-Kermit
  14122.     initialization file and to make command line arguments available to the
  14123.     script, the final option should be "+":
  14124.  
  14125.     #!/usr/local/bin/kermit +
  14126.  
  14127.     Some users have reported that in some circumstances a space might be
  14128.     necessary after the plus sign; this depends on your shell -- it has
  14129.     nothing to do with Kermit.  In most cases, no space is needed.
  14130.  
  14131.  b. The file must have execute permission (granted via "chmod +x <filename>").
  14132.  
  14133. When C-Kermit is invoked from a Kerbang script (or from the system prompt
  14134. with a "+" command-line argument, which amounts to the same thing), the
  14135. following special rules apply:
  14136.  
  14137.  a. The C-Kermit initialization file is NOT executed automatically.  If you
  14138.     want it to be executed, include a TAKE command for it in the script,
  14139.     e.g.  "take \v(home).kermrc".  (In previous releases, the initialization
  14140.     file was always executed, with no way to prevent it except for the user
  14141.     to include Kermit-specific command line options which had nothing to do
  14142.     with the script).  Many scripts have no need for the standard Kermit
  14143.     initialization file, which is quite lengthy and not only delays startup
  14144.     of the script, but also spews forth numerous messages that are most
  14145.     likely unrelated to the script.
  14146.  
  14147.  b. If the initialization file is not executed, neither is your customization
  14148.     file, since the initialization file is the command file from which the
  14149.     customization file is TAKEn.  Again, you can include a TAKE command for
  14150.     the initialization file if desired, or for the customization file by
  14151.     itself, or for any other file.
  14152.  
  14153.  c. C-Kermit does not process command-line arguments at all.  Instead, it
  14154.     passes all words on the command line after the "+" to the script as \%0
  14155.     (the script name), \%1..\%9 (the first nine arguments), as well as in
  14156.     the argument vector array \&_[].  The variable \v(argc) is set to the
  14157.     total number of "words" (as passed by the shell to Kermit) including the
  14158.     script name.  Quoting and grouping rules are those of the shell.
  14159.  
  14160.  d. At any point where the script terminates, it must include an EXIT
  14161.     command if you want it to exit back to the shell; otherwise C-Kermit
  14162.     enters interactive prompting mode when the script terminates.  The EXIT
  14163.     command can include a numeric status to be returned to the shell (0, 1,
  14164.     etc), plus an optional message.
  14165.  
  14166. Here is a simple Kerbang script that prints its arguments:
  14167.  
  14168.   #/usr/local/bin/kermit +
  14169.   echo Hello from \%0
  14170.   for \%i 0 \v(argc)-1 1 {
  14171.       echo \%i. "\&_[\%i]"
  14172.   }
  14173.   exit 0
  14174.  
  14175. Save this file as (say) "showargs", then give it execute permission and
  14176. run it (the \&_[] array is the same as \%0..\%9, but allows you to refer
  14177. to argument variables programmatically; see Section 7.5).  (Yes, you could
  14178. substitute SHOW ARGUMENTS for the loop.)
  14179.  
  14180.   $ chmod +x showargs
  14181.   $ ./showargs one "this is two" three
  14182.  
  14183. The script displays its arguments:
  14184.  
  14185.   Hello from /usr/olga/showargs
  14186.   0. "/usr/olga/showargs"
  14187.   1. "one"
  14188.   2. "this is two"
  14189.   3. "three"
  14190.   $
  14191.  
  14192. Notice that no banners or greetings are printed and that startup is
  14193. instantaneous, just like a shell script.  Also notice that grouping of
  14194. arguments is determined by *shell* quoting rules, not Kermit ones, since
  14195. the command line is parsed by the shell before Kermit ever sees it.
  14196.  
  14197. Of course you can put any commands at all into a Kerbang script.  It can
  14198. read and write files, make connections, transfer files, anything that Kermit
  14199. can do -- because it *is* Kermit.  And of course, Kerbang scripts can also
  14200. be executed from the Kermit prompt (or from another script) with a TAKE
  14201. command; the Kerbang line is ignored since it starts with "#", which is a
  14202. comment introducer to Kermit just as it is to the UNIX shell.  In VMS and
  14203. other non-UNIX platforms, the Kerbang line has no effect and can be omitted.
  14204.  
  14205. It might be desireable for a script to know whether it has been invoked
  14206. directly from the shell (as a Kerbang script) or by a TAKE command given to
  14207. the Kermit prompt or in a Kermit command file or macro.  This can be done
  14208. as in this example:
  14209.  
  14210.   #!/usr/local/bin/kermit +
  14211.   assign \%m \fbasename(\%0)
  14212.   define usage { exit 1 {usage: \%m <phonenumber> <message>} }
  14213.   define apage { (definition of APAGE...) } ; (See book pp.454-456)
  14214.   xif equal "\%0" "\v(cmdfil)" {
  14215.       if not def \%1 usage
  14216.       if not def \%2 usage
  14217.       apage {\%1} {\%2}
  14218.       exit \v(status)
  14219.   }
  14220.  
  14221. In a Kerbang script, \%0 and \v(cmdfile) are the same; both of them are the
  14222. name of the script.  When a script is invoked by a Kermit TAKE command, \%0 is
  14223. the name of the Kermit program, but \v(cmdfile) is the name of the script.  In
  14224. the example above, a macro called APAGE is defined.  If the script was invoked
  14225. directly, the APAGE macro is also executed.  Otherwise, it is available for
  14226. subsequent and perhaps repeated use later in the Kermit session.
  14227.  
  14228. An especially handy use for Kerbang scripts is to have the initialization file
  14229. itself be one.  Since the standard initialization file is rather long and
  14230. time-consuming to execute, it is often overkill if you want to start Kermit
  14231. just to transfer a file.  Of course there are command-line switches to
  14232. suppress initialization-file execution, etc, but another approach is to "run"
  14233. the initialization file when you want its features (notably the services
  14234. directory), and run C-Kermit directly when you don't.  A setup like this
  14235. requires that (a) the C-Kermit initialization file is configured as a Kerbang
  14236. script (has #!/path.../kermit as first line), has execute permission, and is
  14237. in your PATH; and (b) that you don't have a .kermrc file in your login
  14238. directory.
  14239.  
  14240. 7.20. IF and XIF Statement Syntax
  14241.  
  14242. The IF command has been improved in two signifant ways in C-Kermit 7.0,
  14243. described in the following subsections.  All changes are backwards compatible.
  14244.  
  14245. 7.20.1. The IF/XIF Distinction
  14246.  
  14247. The distinction between IF and XIF is no longer important as of C-Kermit 7.0.
  14248. You should be able to use IF in all cases (and of course, also XIF for
  14249. backwards compatibility).  In the past, IF was used for single-command THEN
  14250. parts, followed optionally by a separate ELSE command:
  14251.  
  14252.   IF <condition> <command1>  ; THEN part
  14253.   ELSE <command2>            ; ELSE part
  14254.  
  14255. whereas XIF was required if either part had multiple commands:
  14256.  
  14257.   XIF <condition> { command, command, ... } ELSE { command, command, ... }
  14258.  
  14259. The syntactic differences were primarily that IF / ELSE was two commands on
  14260. two separate lines, whereas XIF was one command on one line, and that XIF
  14261. allowed (and in fact required) braces around its command lists, whereas IF
  14262. did not allow them.
  14263.  
  14264. Furthermore, the chaining or nesting of parts and conditions was inconsistent.
  14265. For example, the IF command could be used like this:
  14266.  
  14267.   IF <condition> <command>
  14268.   ELSE IF <condition> <command>
  14269.   ELSE IF <condition> <command>
  14270.   ELSE IF <condition> <command>
  14271.   ...
  14272.  
  14273. but XIF could not.  C-Kermit 7.0 accepts the old syntax and executes it the
  14274. same as previous versions, but also accepts a new unified and more convenient
  14275. syntax:
  14276.  
  14277.   IF <condition> <command-list> [ ELSE <command-list> ]
  14278.  
  14279. or:
  14280.  
  14281.   IF <condition> <command-list>
  14282.   ELSE <command-list>
  14283.  
  14284. in which the ELSE part is optional, and where <command-list> can be a single
  14285. command (with or without braces around it) or a list of commands enclosed in
  14286. braces.  Examples:
  14287.  
  14288. Example 1:
  14289.  
  14290.   IF <condition> { command1, command2 } ELSE { command3, command4 }
  14291.  
  14292. Example 2 (same as Example 1):
  14293.  
  14294.   IF <condition> {
  14295.      command1
  14296.      command2
  14297.   } ELSE {
  14298.      command3
  14299.      command4
  14300.   }
  14301.  
  14302. Example 3 (same as 1 and 2):
  14303.  
  14304.   IF <condition> {
  14305.      command1
  14306.      command2
  14307.   }
  14308.   ELSE { command3, command4 }
  14309.  
  14310. Example 4 (same as 1-3):
  14311.  
  14312.   IF <condition> {
  14313.      command1
  14314.      command2
  14315.   }
  14316.   ELSE {
  14317.      command3
  14318.      command4
  14319.   }
  14320.  
  14321. Example 5 (ELSE can be followed by another command):
  14322.  
  14323.   IF <condition> {
  14324.      command1
  14325.      command2
  14326.   } ELSE IF <condition> {
  14327.      command3
  14328.      command4
  14329.   } ELSE {
  14330.      command5
  14331.      command6
  14332.   }
  14333.  
  14334. Example 5 suggests other possibilities:
  14335.  
  14336.   IF <condition> {
  14337.      command1
  14338.      command2
  14339.   } ELSE FOR <variable> <initial> <final> <increment> {
  14340.      command3
  14341.      command4
  14342.   }
  14343.  
  14344. And this too is possible, except for some non-obvious quoting considerations:
  14345.  
  14346.   dcl \&a[6] = one two three four five six
  14347.  
  14348.   IF < \%n 3 {
  14349.       echo \\%n is too small: \%n
  14350.   } ELSE FOR \\%i 1 \\%n 1 {
  14351.       echo \\%i. \\&a[\\%i]
  14352.   }
  14353.  
  14354. (The loop variable must be quoted in this context to prevent premature
  14355. evaluation.)
  14356.  
  14357. 7.20.2. Boolean Expressions (The IF/WHILE Condition)
  14358.  
  14359. Prior to C-Kermit 7.0, the IF and WHILE commands accepted only a single
  14360. Boolean ("true or false") assertion, e.g. "if > \%m 0 <command>" or "if exist
  14361. <filename> <command>".  There was no way to form Boolean expressions and, in
  14362. particular, nothing that approached a Boolean OR function (AND could be
  14363. simulated by concatenating IF statements: "if <condition1> if <condition2>..").
  14364.  
  14365. C-Kermit 7.0 (and K95 1.1.18) allow grouping of Boolean assertions using
  14366. parentheses and combining them using AND (or &&) and OR (or ||).  Each of
  14367. these operators -- including the parentheses -- is a field and must be set off
  14368. by spaces.  AND has higher precedence than OR, NOT has higher precendence than
  14369. AND, but parentheses can be used to force any desired order of evaluation.
  14370. The old syntax is still accepted.
  14371.  
  14372. Here are some examples:
  14373.  
  14374.   define \%z 0                          ; Define some variables
  14375.   define \%n 1                          ; for use in the examples.
  14376.  
  14377.   if > \%n \%z echo \%n is greater.     ; Original format - still accepted.
  14378.   if ( > \%n \%z ) echo \%n is greater. ; Parentheses may be used in 7.0.
  14379.   if ( > \%n \%z && not = \%z 0 ) ...   ; Two assertions combined with AND.
  14380.   if ( > \%n \%z and not = \%z 0 ) ...  ; Same as previous ("and" = "&&").
  14381.   if ( > \%n \%z || not = \%z 0 ) ...   ; Two assertions combined with OR.
  14382.   if ( > \%n \%z or not = \%z 0 ) ...   ; Same as previous ("or" = "||").
  14383.   if ( > \%n \%z || != \%z 0 ) ...      ; Ditto ("!=" = "not =").
  14384.   while ( 1 ) { ... }                   ; Just like C.
  14385.  
  14386. Notice the spaces around all operators including the parentheses -- these
  14387. are required.  The following examples show how parentheses can be used to
  14388. alter the precedence of the AND and OR operators:
  14389.  
  14390.   if ( false || false && false || true ) ,..         ; True
  14391.   if ( false || ( false && false ) || true ) ...     ; Same as previous
  14392.   if ( ( false || false ) && ( false || true ) ) ... ; False
  14393.  
  14394. Similarly for NOT:
  14395.  
  14396.   if ( not true && false ) ...          ; False (NOT binds to TRUE only)
  14397.   if ( ( not true ) && false ) ...      ; Same as previous
  14398.   if ( not ( true && false ) ) ...      ; True (NOT binds to (TRUE && FALSE))
  14399.  
  14400. Notes:
  14401.  
  14402.  a. The syntax of the Boolean expression itself has not changed; each
  14403.     expression begins with a keyword or token such as "EXIST", ">", or
  14404.     "=", etc; operators such as "<", "=", and ">" do not go between their
  14405.     operands but precede them as before; this might be called "reverse
  14406.     reverse Polish notation"; it allows deterministic on-the-fly parsing
  14407.     of these expressions at the C-Kermit> prompt as well as in scripts, and
  14408.     allows ?-help to be given for each item when IF or WHILE commands are
  14409.     typed at the prompt.
  14410.  
  14411.  b. Parentheses are required when there is more than one Boolean assertion.
  14412.  
  14413.  c. Parentheses are not required, but are allowed, when there is only one
  14414.     Boolean assersion.
  14415.  
  14416.  d. Evaluation of Boolean assertions occurs left to right, but the resulting
  14417.     Boolean expression is evaluated afterwards according to the rules of
  14418.     precedence.  All Boolean assertions are always evaluated; there is no
  14419.     "early stopping" property and therefore no question about when or if
  14420.     side effects will occur -- if any Boolean assertion has side effects,
  14421.     they will always occur.
  14422.  
  14423. Constructions of arbitrary complexity are possible, within reason.
  14424.  
  14425. Also see Section 7.4 for new IF / WHILE conditions.
  14426.  
  14427. 7.21. Screen Formatting and Cursor Control
  14428.  
  14429. C-Kermit 7.0 adds a simple way to create formatted screens, the SCREEN
  14430. command:
  14431.  
  14432. SCREEN { CLEAR, CLEOL, MOVE-TO row [ column ] }
  14433.   Performs screen-formatting actions.  Correct operation of these commands
  14434.   depends on proper terminal setup on both ends of the connection -- mainly
  14435.   that the host terminal type is set to agree with the kind of terminal or
  14436.   the emulation you are viewing C-Kermit through.  The UNIX version uses
  14437.   terminfo or termcap (not curses); the VMS version uses SMG; K-95 uses its
  14438.   built in screen manager.
  14439.  
  14440. SCREEN CLEAR
  14441.   Moves the cursor to home position and clears the entire screen.
  14442.   Synonyms: CLEAR COMMAND-SCREEN ALL (K-95 only), CLS, CLEAR SCREEN.
  14443.  
  14444. SCREEN CLEOL
  14445.   Clears from the current cursor position to the end of the line.
  14446.   Synonym: CLEAR COMMAND-SCREEN EOL (K-95 only)
  14447.  
  14448. SCREEN MOVE-TO row column
  14449.   Moves the cursor to the indicated row and column.  The row and column
  14450.   numbers are 1-based, so on a 24x80 screen the home position is 1 1 and
  14451.   the lower right corner is 24 80.  If a row or column number is given that
  14452.   too large for what Kermit or the operating system thinks is your screen
  14453.   size, the appropriate number is substituted.
  14454.  
  14455. These escape sequences used by these commands depends on the platform.
  14456. In UNIX, your TERM environment variable is used to query the terminfo/termcap
  14457. database; if the query fails, ANSI/VT100 sequences are used.  In VMS, the
  14458. SMG library is used, which sends sequences based on your VMS terminal type.
  14459. K95 does its own screen control.  On other platforms (such as AOS/VS, VOS,
  14460. etc), screen formatting is not supported, and the SCREEN command does nothing.
  14461.  
  14462. The three SCREEN actions can be used in scripts to produce menus, formatted
  14463. screens, dynamic displays, etc.  Related variables include:
  14464.  
  14465.   \v(terminal)     The type terminal C-Kermit thinks you have.
  14466.   \v(rows)         The number of rows C-Kermit thinks your terminal has.
  14467.   \v(columns)      The number of columns C-Kermit thinks your terminal has.
  14468.  
  14469. And functions:
  14470.  
  14471.   \fscrncurx()     The current X coordinate of the cursor (K-95 only).
  14472.   \fscrncury()     The current Y coordinate of the cursor (K-95 only).
  14473.   \fscrnstr(x,y,n) The string of length n at position (x,y) (K-95 only).
  14474.  
  14475. And commands:
  14476.  
  14477.   ECHO string      Writes string + CRLF at the current cursor position.
  14478.   XECHO string     Writes string at current cursor position; CRLF not supplied.
  14479.   GETC v prompt    Issues prompt, reads one character into variable v, no echo.
  14480.  
  14481. And special characters:
  14482.  
  14483.   Ctrl-L           At the C-Kermit> command prompt, or in a C-Kermit command,
  14484.                    works like Return or Enter, but also clears the screen
  14485.  
  14486. Example 1: A macro that prints a message \%1 at cursor position (\%2,\%3):
  14487.  
  14488.   define MSG {
  14489.       if not def \%3 def \%3 0             ; Default column to 0
  14490.       if > \v(argc) 2 screen move \%2 \%3  ; Move to given row/col (if any)
  14491.       screen cleol                         ; Clear to end of line
  14492.       if def \%1 xecho \fcontents(\%1)     ; Print message (if any)
  14493.   }
  14494.  
  14495. Example 2: A macro put the cursor on the bottom screen line, left margin:
  14496.  
  14497.   define BOT {
  14498.       screen move \v(rows) 0
  14499.   }
  14500.  
  14501. Example 3: A macro to center message \%1 on line \%2.
  14502.  
  14503.   define CENTER {
  14504.       if not def \%2 def \%2 1
  14505.       .\%x ::= (\v(cols)-\flen(\%1))/2
  14506.       msg {\%1} {\%2} {\%x}
  14507.   }
  14508.  
  14509. Example 4: A simple menu (building on Examples 1-3):
  14510.  
  14511.   def \%c 0                             ; Menu choice variable
  14512.   screen clear                          ; Clear the screen
  14513.   center {Welcome to This Menu} 2       ; Display the menu
  14514.   msg {Choices:} 4
  14515.   msg { 1. File} 6
  14516.   msg { 2. Edit} 7
  14517.   msg { 3. Exit} 8
  14518.   while ( != \%c 3 ) {                  ; Read and verify choice
  14519.       while true {                      ; Keep trying till we get a good one
  14520.       screen move 10                ; Move to line 10
  14521.       screen cleol                  ; Clear this line
  14522.       getc \%c {Your choice: }      ; Prompt and get and echo 1 character
  14523.       xecho \%c
  14524.       if ( not numeric \%c ) { msg {Not numeric - "\%c"} 12, continue }
  14525.       if ( >= \%c 1 && <= \%c 3 ) break
  14526.       msg {Out of range - "\%c"} 12
  14527.       }
  14528.       switch \%c {                      ; Valid choice - execute it.
  14529.     :1, msg {Filing... } 12, break
  14530.     :2, msg {Editing...} 12, break
  14531.     :3, msg {Exiting...} 12, break
  14532.       }
  14533.   }
  14534.   echo Bye                              ; Exit chosen - say goodbye.
  14535.   bot                                   ; Leave cursor at screen bottom.
  14536.   exit                                  ; And exit.
  14537.  
  14538. Similar scripts can work over the communication connection; substitute
  14539. INPUT and OUTPUT for GETC and ECHO/XECHO.
  14540.  
  14541.  
  14542. 7.22. Evaluating Arithmetic Expressions
  14543.  
  14544. A new arithmetic operator was added to the list recognized by the EVALUATE
  14545. command, the \feval() function, and which can also be used anywhere else
  14546. arithmetic expressions are accepted (numeric command fields, array subscripts,
  14547. etc):
  14548.  
  14549. Prefix "!"
  14550.   This operator inverts the "truth value" of the number or arithmetic
  14551.   expression that follows.  If the value of the operand is 0, the result is 1.
  14552.   If the value is nonzero, the result is 0.
  14553.  
  14554. Examples:
  14555.  
  14556.   set eval old
  14557.   evaluate 0
  14558.   0
  14559.  
  14560.   evaluate !0
  14561.   1
  14562.  
  14563.   evaluate !3
  14564.   0
  14565.  
  14566.   evaluate !(-3)
  14567.   0
  14568.  
  14569.   .\%a = 1
  14570.   .\%b = 0
  14571.   evaluate !(\%a|\%b)
  14572.   0
  14573.  
  14574.   evaluate !(\%a&\%b)
  14575.   1
  14576.  
  14577.   evaluate !(!(\%a&\%b))
  14578.   0
  14579.  
  14580. Note the distinction between Prefix ! (invert truth value) and Suffix !
  14581. (factorial).  Also the distinction between Prefix ! and Prefix ~ (which
  14582. inverts all the bits in its operand).  Also note that prefix operators
  14583. (!, -, and ~) can not be adjacent unless you use parentheses to separate
  14584. them, as shown in the final example above.
  14585.  
  14586. 7.23. Floating-Point Arithmetic
  14587.  
  14588. C-Kermit 7.0 adds limited support for floating-point numbers (numbers that
  14589. have fractional parts, like 3.141592653).  This support is provided through a
  14590. small repertoire of functions and in Boolean expressions that compare numbers,
  14591. but does not apply to number parsing in general, or to expression evaluation,
  14592. array subscripts, the INCREMENT and DECREMENT commands, or in any context
  14593. other than those listed in this section.
  14594.  
  14595. A floating point number has an optional sign (+ or -), followed by a series of
  14596. decimal digits containing either zero or one period (.) character, which is
  14597. the decimal point.  The use of comma or any other character besides period as
  14598. a decimal point is not supported.  Scientific notation is not supported
  14599. either.  Examples of legal floating-point numbers:
  14600.  
  14601.   0                Integers can be used
  14602.   1                Ditto
  14603.   2.               A decimal point without decimal digits
  14604.   3.0              A decimal point with decimal digits
  14605.   3.141592653      Ditto
  14606.  -4.0              A negative sign can be included
  14607.  +5.0              A positive sign can be included
  14608.  
  14609. Examples of notations that are not accepted:
  14610.  
  14611.   1,000,000        Separators can not be used
  14612.   1.000.000        Ditto (or multiple decimal points)
  14613.   6.022137E23      No scientific notation
  14614.   6.62606868e-34   Ditto
  14615.   12.5+6.25        No "bare" expressions
  14616.  
  14617. You can use IF FLOAT test a string or variable to see if it's in acceptable
  14618. floating-point format.  Example:
  14619.  
  14620.   ask \%f { Type a number: }
  14621.   if not def \%f .\%f = 0.0
  14622.   if not float \%f stop 1 Invalid floating-point number: "\%f"
  14623.  
  14624. C-Kermit's floating-point support, like its support for whole numbers
  14625. (integers), relies on the capabilities of the underlying computer.  Your
  14626. computer has only a limited amount of precision for numbers, depending on its
  14627. architecture.  Thus floating-point numbers that have too many digits will not
  14628. be accurate; adding a very small number to a very large one might have no
  14629. effect at all; and so on.  For details, read a text on numerical analysis.
  14630. Example:
  14631.  
  14632.   .\%a = 11111111111111111111  ; A long number
  14633.   .\%b = 22222222222222222222  ; Another one
  14634.   echo \ffpadd(\%a,\%b)        ; Add them - the result should be all 3's
  14635.   33333333333333330000.0       ; See the result
  14636.  
  14637. In this example, the computer has 16 digits of precision; after that, the
  14638. (low-order) digits are set to 0, since the computer doesn't know what they
  14639. really are.  In fact, the computer returns random digits, but Kermit sets
  14640. all digits beyond the computer's precision to 0.
  14641.  
  14642. C-Kermit's floating-point functions have names of the form "\ffpxxx(args)"
  14643. ("\f" for function, "fp" for floating-point), where "xxx" is replaced by the
  14644. name of the function, such as "sqrt", and "args" is the argument list,
  14645. consisting of one or two floating-point numbers (depending on the function),
  14646. and an optional "d" argument that says now many decimal places should be shown
  14647. in the result.  Example:
  14648.  
  14649.   \ffpdiv(10,3,1) returns "3.3"
  14650.   \ffpdiv(10,3,2) returns "3.33"
  14651.   \ffpdiv(10,3,3) returns "3.333"
  14652.  
  14653. and so on, up to the precision of the computer.  If the decimal-places
  14654. argument is less than zero, the fractional part of the result is truncated:
  14655.  
  14656.   \ffpdiv(10,3,-1) returns "3".
  14657.  
  14658. If the decimal-places argument is 0, or is omitted, C-Kermit returns as many
  14659. decimal places as are meaningful in the computer's floating-point precision,
  14660. truncating any extraneous trailing 0's:
  14661.  
  14662.   \ffpdiv(10,8) returns "1.25".
  14663.   \ffpdiv(10,4) returns "2.5".
  14664.   \ffpdiv(10,2) returns "5.0".
  14665.   \ffpdiv(10,3) returns "3.333333333333333" (for 16-digit precision).
  14666.  
  14667. There is no way to request that a floating-point function return a decimal
  14668. point but no decimal places.  However, this is easy enough to accomplish in
  14669. other ways, for example by supplying it outside the function call:
  14670.  
  14671.   echo \ffpadd(\%a,\%b,-1).
  14672.  
  14673. Kermit's floating-point functions always round the result for the requested
  14674. number of decimal places when the "d" argument is given and has a value
  14675. greater than 0 (see the description of \ffpround() just below).
  14676.  
  14677. Floating-point arguments can be constants in floating-point format or
  14678. variables whose values are floating-point numbers.  If a floating-point
  14679. argument is omitted, or is a variable with no value, 0.0 is supplied
  14680. automatically.  Example:
  14681.  
  14682.   def \%x 999.999
  14683.   undef \%y
  14684.   echo \ffpmin(\%x,\%y)
  14685.   0.0
  14686.  
  14687. Or equivalently:
  14688.  
  14689.   echo \ffpmin(999.999)
  14690.   0.0
  14691.  
  14692. The floating-point functions are:
  14693.  
  14694. \ffpround(f1,d)
  14695.   Returns f1 rounded to d decimal places.  For this function only, d = 0
  14696.   (or d omitted) has a special meaning: return the integer part of f1
  14697.   rounded according to the fractional part.  Examples:
  14698.     \ffpround(2.74653,-1) returns "2" (fraction truncated, no rounding).
  14699.     \ffpround(2.74653,0)  returns "3" (integer part is rounded).
  14700.     \ffpround(2.74653)    returns "3" (d omitted same as d = 0).
  14701.     \ffpround(2.74653,1)  returns "2.7".
  14702.     \ffpround(2.74653,2)  returns "2.75".
  14703.     \ffpround(2.74653,3)  returns "2.747".
  14704.     \ffpround(2.74653,4)  returns "2.7465", etc.
  14705.  
  14706. \ffpadd(f1,f2,d)
  14707.   Returns the sum of f1 and f2.
  14708.  
  14709. \ffpsubtract(f1,f2,d)
  14710.   Subtracts f2 from f1 and returns the result.
  14711.  
  14712. \ffpmultiply(f1,f2,d)
  14713.   Returns the product of f1 and f2.
  14714.  
  14715. \ffpdivide(f1,f2,d)
  14716.   If f2 is not 0, divides f1 by f2 and returns the quotient.
  14717.   If f2 is 0, a DIVIDE_BY_ZERO error occurs.
  14718.  
  14719. \ffpraise(f1,f2,d)
  14720.   If f1 = 0 and f2 <= 0, or if f1 < 0 and f2 has a fractional part,
  14721.   an ARG_OUT_OF_RANGE error occurs; otherwise f1 raised to the f2 power
  14722.   is returned.
  14723.  
  14724. \ffpsqrt(f1,d)
  14725.   If f1 >= 0, returns the square root of f1; otherwise ARG_OUT_OF_RANGE.
  14726.  
  14727. \ffpabsolute(f1,d)
  14728.   Returns the absolute value of f1 (i.e. f1 without a sign).
  14729.   This is the floating-point analog of \fabsolute(n1).
  14730.  
  14731. \ffpint(f1)
  14732.   Returns the integer part of f1.  Equivalent to \ffpround(f1,-1).
  14733.  
  14734. \ffpexp(f1,d)
  14735.   The base of natural logarithms, e (2.718282...), raised to the f1 power.
  14736.  
  14737. \ffplogn(f1,d)
  14738.   The natural logarithm of f1 (the power to which e must be raised to
  14739.   obtain f1).
  14740.  
  14741. \ffplog10(f1,d)
  14742.   The base-10 logarithm of f1 (the power to which 10 must be raised to
  14743.   obtain f1).
  14744.  
  14745. \ffpmodulus(f1,f2,d)
  14746.   If f2 is not 0, the remainder after dividing f1 by f2.
  14747.   If f2 is 0, a DIVIDE_BY_ZERO error occurs.
  14748.   This is the floating-point analog of \fmod(n1,n2).
  14749.  
  14750. \ffpmaximum(f1,f2,d)
  14751.   Returns the maximum of f1 and f2.
  14752.   This is the floating-point analog of \fmax(n1,n2).
  14753.  
  14754. \ffpminimum(f1,f2,d)
  14755.   Returns the minimum of f1 and f2.
  14756.   This is the floating-point analog of \fmin(n1,n2).
  14757.  
  14758. \ffpsine(f1,d)
  14759.   Returns the sine of f1 radians.
  14760.  
  14761. \ffpcosine(f1,d)
  14762.   Returns the cosine of f1 radians.
  14763.  
  14764. \ffptangent(f1,d)
  14765.   Returns the tangent of f1 radians.
  14766.  
  14767. Note that all of these functions can be used with integer arguments.  If you
  14768. want an integer result, specify d = -1 (to truncate) or feed the result to
  14769. \ffpround(xxx,0) (to round).
  14770.  
  14771. Floating-point numbers (or variables or functions that return them) can be
  14772. used in Boolean expressions (see Section 7.20.2) that compare numbers:
  14773.  
  14774.   = x y
  14775.   != x y
  14776.   < x y
  14777.   > x y
  14778.   <= x y
  14779.   >= x y
  14780.  
  14781. In these examples, x and y can be either integers or floating-point numbers
  14782. in any combination.  In an arithmetic comparison of an integer and a
  14783. floating-point number, the integer is converted to floating-point before the
  14784. comparison is made.  Examples:
  14785.  
  14786.   .\%t = 3.000000000
  14787.   .\%f = 3.141592653
  14788.   .\%i = 3
  14789.  
  14790.   if > \%f \%i echo Pi is greater.
  14791.   if = \%t \%i echo "\%i" = "\%t".
  14792.  
  14793. A floating-point number can also be used in:
  14794.  
  14795.   IF <number> <command>
  14796.  
  14797. where the <command> is executed if the <number> is nonzero.  If the number
  14798. is floating-point, the <command> is not executed if the number is 0.0, and
  14799. is executed otherwise.
  14800.  
  14801. Floating-point numbers can be sorted using ARRAY SORT /NUMERIC (see Section
  14802. 7.10.5).
  14803.  
  14804. Two floating-point constants are provided:
  14805.  
  14806.   \v(math_pi) = Pi (3.141592653...)
  14807.   \v(math_e)  = e, the base of natural logarithms (2.71828...)
  14808.  
  14809. These are given to the computer's precision, e.g. 16 digits.  This number
  14810. itself is available in a variable:
  14811.  
  14812.   \v(math_precision) = How many significant digits in a floating-point number.
  14813.  
  14814. 7.24. Tracing Script Execution
  14815.  
  14816. The TRACE command is handy for debugging scripts.
  14817.  
  14818. Syntax: TRACE [ switch ] [ object ]
  14819.  
  14820. TRACE [ { /ON, /OFF } ] [ { ASSIGNMENTS, COMMAND-LEVEL, ALL } ]
  14821.   Selects tracing of the given object.
  14822.  
  14823. Optional switches are /ON and /OFF.  If no switch is given, /ON is implied.
  14824. The trace objects are ASSIGNMENTS, COMMAND-LEVEL, and ALL.  The default object
  14825. is ALL, meaning to select all trace objects (besides ALL).  Thus TRACE by
  14826. itself selects tracing of everything, as does TRACE /ON, and TRACE /OFF turns
  14827. off all tracing.
  14828.  
  14829. When tracing of ASSIGNMENTS is on, every time the value of any user-defined
  14830. variable or macro changes, C-Kermit prints one of the following:
  14831.  
  14832. >>> name: "value"
  14833.   The name of the variable or macro followed by the new value in quotes.
  14834.   This includes implicit macro-parameter assignments during macro invocation.
  14835.  
  14836. >>> name: (undef)
  14837.   This indicates that the variable or macro has been undefined.
  14838.  
  14839. <<< name: "value"
  14840.   For RETURN statements: the name of the macro and the return value.
  14841.  
  14842. <<< name: (null)
  14843.   For RETURN statements that include no value or an empty value.
  14844.  
  14845. When tracing of COMMAND-LEVEL is on, C-Kermit prints:
  14846.  
  14847. [n] +F: "name"
  14848.   Whenever a command file is entered, where "n" is the command level
  14849.   (0 = top); the name of the command file is shown in quotes.
  14850.  
  14851. [n] +M: "name"
  14852.   Whenever a macro is entered; "n" is the command level.  The name of
  14853.   the macro is shown in quotes.
  14854.  
  14855. [n] -F: "name"
  14856.   Whenever a command file is reentered from below, when a macro or
  14857.   command file that it has invoked has returned.
  14858.  
  14859. [n] -M: "name"
  14860.   Whenever a macro is reentered from below.
  14861.  
  14862. For other debugging tools, see SHOW ARGS, SHOW STACK, SET TAKE, SET MACRO, and
  14863. of course, ECHO.
  14864.  
  14865. 7.25. Compact Substring Notation
  14866.  
  14867. It is often desirable to extract a substring from a string which is stored
  14868. in a variable, and for this we have the \fsubstring() function, which is
  14869. used like this:
  14870.  
  14871.   define \%a 1234567890
  14872.   echo \fsubstring(\%a,3,4) ; substring from 3rd character length 4
  14873.   3456
  14874.  
  14875. or like this with macro-named variables:
  14876.  
  14877.   define string 1234567890
  14878.   echo \fsubstring(\m(string),3,4)
  14879.   3456
  14880.  
  14881. C-Kermit 7.0 adds a pair of alternative compact notations:
  14882.  
  14883.   \:(variablename[start:length])  <-- Substring of variable's value
  14884.   \s(macroname[start:length])     <-- Substring of macro's definition
  14885.  
  14886. These are exactly equivalent to using \fsubstring(), except more compact to
  14887. write and also faster since evaluation is in one step instead of two.
  14888.  
  14889. The "\:()" notation can be used with any Kermit variable, that is, almost
  14890. anything that starts with a backslash:
  14891.  
  14892.   \:(\%a[2:6])      <-- equivalant to \fsubstring(\%a,2,6)
  14893.   \:(\&x[1][2:6])   <-- equivalant to \fsubstring(\&x[1],2,6)
  14894.   \:(\m(foo)[2:6])  <-- equivalant to \fsubstring(\m(foo),2,6)
  14895.   \:(\v(time)[2:6]) <-- equivalant to \fsubstring(\v(time),2,6)
  14896.   \:(\$(TERM)[2:6]) <-- equivalant to \fsubstring(\$(TERM),2,6)
  14897.   \:(ABCDEFGH[2:6]) <-- equivalant to \fsubstring(ABCDEFGH,2,6)
  14898.  
  14899. Whatever appears between the left parenthesis and the left bracket is
  14900. evaluated and then the indicated substring of the result is returned.
  14901.  
  14902. The "\s()" notation is the same, except after evaluating the variable,
  14903. the result is treated as a macro name and is looked up in the macro table.
  14904. Then the indicated substring of the macro definition is returned.  Example:
  14905.  
  14906.   define testing abcdefghijklmnopqrstuvwxyz
  14907.   define \%a testing
  14908.  
  14909.   \s(testing[2:6])  -->  bcdefg
  14910.   \:(testing[2:6])  -->  esting
  14911.   \:(\%a[2:6])      -->  esting
  14912.   \s(\%a[2:6])      -->  bcdefg
  14913.  
  14914. Note that the following two examples are equivalent:
  14915.  
  14916.   \:(\m(foo)[2:6])
  14917.   \s(foo[2:6])
  14918.  
  14919. The first number in the brackets is the 1-based starting position.  If it is
  14920. omitted, or less than 1, it is treated as 1.  If it is greater than the length
  14921. of the string, an empty string is returned.
  14922.  
  14923. The second number is the length of the desired substring.  If the second
  14924. number is omitted, is less than 0, or would be past the end of the string,
  14925. then "through the end of the string" is assumed.  If it is 0, the empty string
  14926. is returned.
  14927.  
  14928. If the brackets are empty or omitted, the original string is returned.
  14929.  
  14930. The starting position and length need not be literal numbers; they can also
  14931. be variables, functions, arithmetic expressions, or even other \s() or \:()
  14932. quantities; anything that evaluates to a number, for example:
  14933.  
  14934.   \s(block[1025:\fhex2n(\s(block[\%b:\%n+4]))/2])
  14935.  
  14936. Syntactically, \m(name) and \s(name) differ only in that the sequence [*]
  14937. at the end of the name (where * is any sequence of 0 or more characters) is
  14938. treated as substring notation in \s(name), but is considered part of the name
  14939. in \m(name) (to see why, see Section 7.10.9).
  14940.  
  14941. 7.26. New WAIT Command Options
  14942.  
  14943. The WAIT command has been extended to allow waiting for different kinds of
  14944. things (formerly it only waited for modem signals).  Now it also can wait
  14945. for file events.
  14946.  
  14947. 7.26.1. Waiting for Modem Signals
  14948.  
  14949. The previous syntax:
  14950.  
  14951.   WAIT <time> { CD, DSR, RTS, RI, ... }
  14952.  
  14953. has changed to:
  14954.  
  14955.   WAIT <time> MODEM-SIGNALS { CD, DSR, RTS, RI, ... }
  14956.  
  14957. However, the previous syntax is still accepted.  The behavior is the same
  14958. in either case.
  14959.  
  14960. 7.26.2. Waiting for File Events
  14961.  
  14962. The new WAIT option:
  14963.  
  14964.   WAIT <time> FILE { CREATION, DELETION, MODIFICATION } <filename>
  14965.  
  14966. lets you tell Kermit to wait the given amount of time (or until the given time
  14967. of day) for a file whose name is <filename> to be created, deleted, or
  14968. modified, respectively.  The <filename> may not contain wildcards.  If the
  14969. specified event does not occur within the time limit, or if WAIT CANCELLATION
  14970. is ON and you interrupt from the keyboard before the time is up, the WAIT
  14971. command fails.  If the event is MODIFICATION and the file does not exist, the
  14972. command fails.  Otherwise, if the given event occurs within the time limit,
  14973. the command succeeds.  Examples:
  14974.  
  14975.   WAIT 600 FILE DELETION oofa.tmp
  14976.     Wait up to 10 minutes for file oofa.tmp to disappear.
  14977.  
  14978.   WAIT 23:59:59 FILE MOD orders.db
  14979.     Wait until just before midnight for the orders.db file to be changed.
  14980.  
  14981. Example: Suppose you want to have the current copy of /etc/motd on your
  14982. screen at all times, and you want to hear a bell whenever it changes:
  14983.  
  14984.   def \%f /etc/motd                      ; The file of interest.
  14985.   while 1 {                              ; Loop forever...
  14986.       cls                                ; Clear the screen.
  14987.       echo \%f: \v(date) \v(time)...     ; Print 2-line heading...
  14988.       echo
  14989.       if ( not exist \%f ) {             ; If file doesn't exist,
  14990.           echo \%f does not exist...     ; print message,
  14991.           wait 600 file creat \%f        ; and wait for it to appear.
  14992.           continue
  14993.       }
  14994.       beep                               ; Something new - beep.
  14995.       type /head:\v(rows-2) \%f          ; Display the file
  14996.       if fail exit 1 \%f: \ferrstring()  ; (checking for errors).
  14997.       wait 999 file mod \%f              ; Wait for it to change.
  14998.   }
  14999.  
  15000. This notices when the file is created, deleted, or modified, and acts only
  15001. then (or when you interrupt it with); the time shown in the heading is the
  15002. time of the most recent event (including when the program started).
  15003.  
  15004. See Section 1.10, where the \v(kbchar) variable is explained.  This lets
  15005. you modify a loop like the one above to also accept single-character commands,
  15006. which interrupt the WAIT, and dispatch accordingly.  For example:
  15007.  
  15008.       wait 999 file mod \%f              ; Wait for the file to change.
  15009.       if defined \v(kbchar) {            ; Interrupted from keyboard?
  15010.           switch \v(kbchar) {            ; Handle the keystroke...
  15011.             :q, exit                     ; Q to Quit
  15012.             :h, echo blah blah, break    ; H for Help
  15013.             :default, beep, continue     ; Anything else beep and ignore
  15014.           }
  15015.       }
  15016.  
  15017. This lets you write event-driven applications that wait for up to three
  15018. events at once: a file or modem event, a timeout, and a keystroke.
  15019.  
  15020. 7.27. Relaxed FOR and SWITCH Syntax
  15021.  
  15022. For consistency with the extended IF and WHILE syntax, the FOR and SWITCH
  15023. control lists may (but need not be) enclosed in parentheses:
  15024.  
  15025.   FOR ( \%i 1 \%n 1 ) { command-list... }
  15026.   SWITCH ( \%c ) { command-list... }
  15027.  
  15028. In the FOR command, the increment item can be omitted if the control list is
  15029. enclosed in parentheses, in which case the increment defaults appropriately to
  15030. 1 or -1, depending on the values of the first two variables.
  15031.  
  15032. As with IF, the parentheses around the FOR-command control list must be set
  15033. off by spaces (in the SWITCH command, the spaces are not required since the
  15034. SWITCH expression is a single arithmetic expression).
  15035.  
  15036. Also, outer braces around the command list are supplied automatically if
  15037. you omit them, e.g.:
  15038.  
  15039.   FOR ( \%i 1 %n 1 ) echo \%i
  15040.  
  15041.  
  15042. (8) USING OTHER FILE TRANSFER PROTOCOLS
  15043.  
  15044. In C-Kermit 7.0, alternative protocols can be selected using switches.
  15045. Switches are described in section 1.5; the use of protocol-selection switches
  15046. is described in section 4.7.1.  Example:
  15047.  
  15048.   send /binary /protocol:zmodem x.tar.gz
  15049.  
  15050. Note that file transfer recovery works only with Kermit and Zmodem protocols.
  15051. With Zmodem, recovery can be initiated only by the sender.
  15052.  
  15053. Only pre-1988 versions of the publicly-distributed sz/rz programs use
  15054. Standard I/O; those released later than that do not use Standard I/O and
  15055. therefore do not work with REDIRECT.  However, Omen Technology does offer
  15056. an up-to-date redirectable version called crzsz, which must be licensed
  15057. for use:
  15058.  
  15059.   "Unix Crz and Csz support XMODEM, YMODEM, and ZMODEM transfers
  15060.   when called by dial-out programs such as Kermit and certain
  15061.   versions of cu(1).  They are clients designed for this use.
  15062.  
  15063.   "Crz and Csz are Copyrighted shareware programs.  Use of these
  15064.   programs beyond a brief evaluation period requires registration.
  15065.   Please print the "mailer.rz" file, fill out the form and return
  15066.   same with your registration."
  15067.  
  15068. To use the crzsz programs as your external XYZMODEM programs in C-Kermit,
  15069. follow the instructions in the book, but put a "c" before each command,
  15070. e.g.:
  15071.  
  15072.   set protocol zmodem {csz %s} {csz -a %s} crz crz crz crz
  15073.  
  15074. To use Zmodem protocol over Telnet or other non-transparent connections,
  15075. you might need to add the -e (Escape) option:
  15076.  
  15077.   set protocol zmodem {csz -e %s} {csz -e -a %s} crz crz crz crz
  15078.  
  15079.  
  15080. (9) COMMAND-LINE OPTIONS
  15081.  
  15082. 9.0. Extended-Format Command-Line Options
  15083.  
  15084. Standard UNIX command line options are a single letter.  C-Kermit has run
  15085. out of letters, so new options are in a new extended format:
  15086.  
  15087.  --word[:arg]
  15088.  
  15089. where a keyword (rather than a single letter) specifies the function, and if
  15090. an argument is to be included, it is separated by a colon (or equal sign).
  15091. Most of the new extended-format command-line options are only for use with the
  15092. Internet Kermit Service Daemon; see iksd.txt for details.  However, several
  15093. of them are also general in nature:
  15094.  
  15095. --nointerrupts
  15096.   Disables keyboard interrupts that are normally ensabled, which are usually
  15097.   Ctrl-C (to interrupt a command) and Ctrl-Z (UNIX only, to suspend C-Kermit).
  15098.  
  15099. --help
  15100.   Lists the extended command-line options that are available in your version
  15101.   of C-Kermit.  If any options seem to be missing, that is because your
  15102.   copy of C-Kermit was built with compile-time options to deselect them.
  15103.  
  15104. --helpfile:<filename>
  15105.   Specifies the name of a file to be displayed if the user types HELP
  15106.   (not followed by a specific command or topic), in place of the built-in
  15107.   top-level help text.  The file need not fit on one screen; more-prompting
  15108.   is used if the file is more than one screen long if COMMAND MORE-PROMPTING
  15109.   is ON, as it is by default.
  15110.  
  15111. --bannerfile:<filename>
  15112.   The name of a file containing a message to be printed after the user logs
  15113.   in, in place of the normal message (Copyright notice, "Type HELP or ? for
  15114.   help", "Default transfer mode is...", etc).
  15115.  
  15116. --cdmessage:{on,off,0,1,2}
  15117.   For use in the Server-Side Server configuration; whenever the client
  15118.   tells the server to change directory, the server sends the contents of a
  15119.   "read me" file to the client's screen.  This feature is On by default,
  15120.   and operates only in client/server mode when ON or 1.  If set to 2 or
  15121.   higher, it also operates when the CD command is given at the IKSD> prompt.
  15122.   Synonym: --cdmsg.
  15123.  
  15124. --cdfile:<filename> (or list)
  15125.   When cdmessage is on, this is the name of the "read me" file to be sent.
  15126.   Normally you would specify a relative (not absolute) name, since the file
  15127.   is opened using the literal name you specified, after changing to the new
  15128.   directory.  Example:
  15129.  
  15130.     --cdfile:READ.ME
  15131.  
  15132.   You can also give a list of up to 8 filenames by (a) enclosing each
  15133.   filename in braces, and (b) enclosing the entire list in braces.  Example:
  15134.   --cdfile:{{./.readme}{READ.ME}{aaareadme.txt}{README}{read-this-first}}
  15135.   When a list is given, it is searched from left to right and the first
  15136.   file found is displayed.  The default list for UNIX is:
  15137.  
  15138.     {{./.readme}{README.TXT}{READ.ME}}
  15139.  
  15140. 9.1. Command Line Personalities
  15141.  
  15142. Beginning in version 7.0, if the C-Kermit binary is renamed to "telnet"
  15143. (or TELNET.EXE, telnet.pr, etc, depending on the platform), it accepts the
  15144. Telnet command line:
  15145.  
  15146.   telnet [ host [ port ] ]
  15147.  
  15148. When installed in this manner, C-Kermit always reads its initialization file.
  15149. If no host (and therefore no port) is given, C-Kermit starts in interactive
  15150. prompting mode.  If a host is given as the first command-line argument,
  15151. C-Kermit makes a connection to it.  The host argument can be an IP host name
  15152. or address, or the name of a TCP/IP entry in your C-Kermit network directory.
  15153.  
  15154. If a port is given, it is used.  If a port is not given, then if the hostname
  15155. was found in your network directory and port was also listed there, then that
  15156. port is used.  Otherwise port 23 (the Telnet port) is used.
  15157.  
  15158. When C-Kermit is called "telnet" and it is invoked with a hostname on the
  15159. command line, it exits automatically when the connection is closed.  While
  15160. the connection is open, however, you may escape back and forth as many times
  15161. as you like, transfer files, etc.
  15162.  
  15163. Additional personalities (e.g. rlogin) might be added in the future.
  15164.  
  15165. The new variable \v(name) indicates the name with which C-Kermit was invoked
  15166. ("kermit", "wermit", "k95", "telnet", etc).
  15167.  
  15168. 9.2. Built-in Help for Command Line Options
  15169.  
  15170. "kermit -h", given from the system prompt, lists as many command-line options
  15171. as will fit on a standard 24x80 screen.  For more comprehensive help, use the
  15172. interactive HELP OPTIONS command that was added in C-Kermit 7.0:
  15173.  
  15174. HELP OPTIONS
  15175.   Explains how command-line options work, their syntax, etc.
  15176.  
  15177. HELP OPTIONS ALL
  15178.   Lists all command-line options and gives brief help about each one.
  15179.  
  15180. HELP OPTION x
  15181.   Gives brief help about option "x".
  15182.  
  15183. HELP EXTENDED-OPTIONS
  15184.   Lists the available extended-format command-line options.
  15185.  
  15186. HELP EXTENDED-OPTION xxx
  15187.   Gives help for the specified extended option.
  15188.  
  15189. 9.3. New Command-Line Options
  15190.  
  15191. Command-line options added since C-Kermit 6.0 are:
  15192.  
  15193. +:  (plus sign by itself): The next argument is the name of a script to
  15194.     execute; all subsequent arguments are ignored by C-Kermit itself, but
  15195.     passed to the script as top-level copies of \%1, \%2, etc; the \&_[] is
  15196.     also set accordingly.  \%0 and \&_[0] become the name of the script file,
  15197.     rather than the pathname of the C-Kermit program, which is its normal
  15198.     value.  Primarily for use in the top line of "Kerbang" scripts in UNIX
  15199.     (see Section 7.19).  Example from UNIX command line:
  15200.  
  15201.       $ kermit [ regular kermit args ] + filename
  15202.  
  15203.     Sample first line of Kerbang script:
  15204.  
  15205.       #!/usr/local/bin/kermit +
  15206.  
  15207. --: (two hyphens surrounded by whitespace)  Equivalent to "=", for
  15208.     compatibility with UNIX getopt(1,3).
  15209.  
  15210. -G: GET (like -g), but send the incoming file to standard output.  Example:
  15211.     "kermit -G oofa.txt | lpr" retrieves a file from your local computer
  15212.     (providing it is running a Kermit program that supports the autodownload
  15213.     feature and has it enabled) and prints it.
  15214.  
  15215. -O: equivalent to -x (start up in server mode), but exits after the first
  15216.     client command has been executed (mnemonic: O = Only One).  This one is
  15217.     handy replacing "kermit -x" in the "automatically-start-Kermit-on-the-
  15218.     other-end" string:
  15219.  
  15220.       set protocol kermit {kermit -ir} {kermit -r} {kermit -x}
  15221.  
  15222.     since -x leaves the remote Kermit in server mode after the transfer,
  15223.     which can be confusing, whereas -O makes it go away automatically
  15224.     after the transfer.
  15225.  
  15226. -L: Recursive, when used in combination with -s (mnemonic: L = Levels).
  15227.     In UNIX or other environments where the shell expands wildcards itself,
  15228.     the -s argument, if it contains wildcards, must be quoted to prevent
  15229.     this, e.g.:
  15230.  
  15231.       kermit -L -s "*.c"
  15232.  
  15233.     In UNIX only, "kermit -L -s ." means to send the current directory tree.
  15234.     See sections 4.10-4.11 about recursive file transfer.
  15235.  
  15236. -V: Equivalent to SET FILE PATTERNS OFF (Section 4.3) and SET TRANSFER MODE
  15237.     MANUAL.  In other words, take the FILE TYPE setting literally.  For
  15238.     example, "kermit -VT oofa.bin" means send the file in Text mode, no matter
  15239.     what its name is and no matter whether a kindred spirit is recognized at
  15240.     the other end of the connection.
  15241.  
  15242. -0: (digit zero) means "be 100% transparent in CONNECT mode".  This is
  15243.     equivalent to the following series of commands: SET PARITY NONE, SET
  15244.     COMMAND BYTESIZE 8, SET TERMINAL BYTESIZE 8, SET FLOW NONE, SET
  15245.     TERM ESCAPE DISABLED, SET TERM CHAR TRANSPARENT, SET TERM AUTODOWNLOAD
  15246.     OFF, SET TERM APC OFF, SET TELOPT KERMIT REFUSE REFUSE.
  15247.  
  15248.  
  15249. (10) C-KERMIT AND G-KERMIT
  15250.  
  15251. Every multifunctioned and long-lived software program grows in complexity
  15252. and size over time to meet the needs and requests of its users and the demands
  15253. of the underlying technology as it changes.
  15254.  
  15255. Eventually users begin to notice how big the application has grown, how much
  15256. disk space it occupies, how long it takes to load, and they start to long for
  15257. the good old days when it was lean and mean.  Not long after that they begin
  15258. asking for a "light" version that only does the basics with no frills.
  15259.  
  15260. And so it is with C-Kermit.  A "light" version of Kermit was released (for
  15261. UNIX only) in December 1999 under the GNU General Public License; thus it is
  15262. called G-Kermit (for GNU Kermit).  All it does is send and receive files,
  15263. period.  You can find it at:
  15264.  
  15265.   http://www.columbia.edu/kermit/gkermit.html
  15266.  
  15267. Where the C-Kermit 7.0 binary might be anywhere from 1 to 3 million bytes in
  15268. size, the G-Kermit binary ranges from 30K to 100K, depending on the underlying
  15269. architecture (RISC vs CISC, etc).
  15270.  
  15271. G-Kermit and C-Kermit may reside side-by-side on the same computer.  G-Kermit
  15272. does not make connections; it does not have a script language; it does not
  15273. translate character sets.  G-Kermit may be used instead of C-Kermit when:
  15274.  
  15275.  . It is on the remote end.
  15276.  . Files are to be transferred in binary mode or in text mode without
  15277.    character-set translation.
  15278.  . File timestamps don't need to be preserved.
  15279.  
  15280. In such cases G-Kermit might be preferred since it generally starts up faster,
  15281. and yet transfers files just as fast on most (but not necessarily all) kinds
  15282. of connections; for example, it supports streaming (Section 4.20).
  15283.  
  15284. G-Kermit is also handy for bootstrapping.  It is easier to load on a new
  15285. computer than C-Kermit -- it fits on a floppy diskette with plenty of room to
  15286. spare.  Thus if you have (say) an old PC running (say) SCO Xenix and no
  15287. network connection, you can download the Xenix version of G-Kermit to (say) a
  15288. DOS or Windows PC, copy it to diskette, read the diskette on Xenix with
  15289. "dosread", and then use G-Kermit to receive C-Kermit (which does not fit on a
  15290. diskette).  If diskettes aren't an option, other bootstrapping methods are
  15291. possible too -- see the G-Kermit web page for details.
  15292.  
  15293.  
  15294. III. APPENDICES
  15295.  
  15296. III.1.  Character Set Tables
  15297.  
  15298. III.1.1. The Hewlett Packard Roman8 Character Set
  15299.  
  15300. dec col/row oct hex  description
  15301. 160  10/00  240  A0  (Undefined)
  15302. 161  10/01  241  A1  A grave
  15303. 162  10/02  242  A2  A circumflex
  15304. 163  10/03  243  A3  E grave
  15305. 164  10/04  244  A4  E circumflex
  15306. 165  10/05  245  A5  E diaeresis
  15307. 166  10/06  246  A6  I circumflex
  15308. 167  10/07  247  A7  I diaeresis
  15309. 168  10/08  250  A8  Acute accent
  15310. 169  10/09  251  A9  Grave accent
  15311. 170  10/10  252  AA  Circumflex accent
  15312. 171  10/11  253  AB  Diaeresis
  15313. 172  10/12  254  AC  Tilde accent
  15314. 173  10/13  255  AD  U grave
  15315. 174  10/14  256  AE  U circumflex
  15316. 175  10/15  257  AF  Lira symbol
  15317. 176  11/00  260  B0  Top bar (macron)
  15318. 177  11/01  261  B1  Y acute
  15319. 178  11/02  262  B2  y acute
  15320. 179  11/03  263  B3  Degree Sign
  15321. 180  11/04  264  B4  C cedilla
  15322. 181  11/05  265  B5  c cedilla
  15323. 182  11/06  266  B6  N tilde
  15324. 183  11/07  267  B7  n tilde
  15325. 184  11/08  270  B8  Inverted exclamation mark
  15326. 185  11/09  271  B9  Inverted question mark
  15327. 186  11/10  272  BA  Currency symbol
  15328. 187  11/11  273  BB  Pound sterling symbol
  15329. 188  11/12  274  BC  Yen symbol
  15330. 189  11/13  275  BD  Paragraph
  15331. 190  11/14  276  BE  Florin (Guilder) symbol
  15332. 191  11/15  277  BF  Cent symbol
  15333. 192  12/00  300  C0  a circumflex
  15334. 193  12/01  301  C1  e circumflex
  15335. 194  12/02  302  C2  o circumflex
  15336. 195  12/03  303  C3  u circumflex
  15337. 196  12/04  304  C4  a acute
  15338. 197  12/05  305  C5  e acute
  15339. 198  12/06  306  C6  o acute
  15340. 199  12/07  307  C7  u acute
  15341. 200  12/08  310  C8  a grave
  15342. 201  12/09  311  C9  e grave
  15343. 202  12/10  312  CA  o grave
  15344. 203  12/11  313  CB  u grave
  15345. 204  12/12  314  CC  a diaeresis
  15346. 205  12/13  315  CD  e diaeresis
  15347. 206  12/14  316  CE  o diaeresis
  15348. 207  12/15  317  CF  u diaeresis
  15349. 208  13/00  320  D0  A ring
  15350. 209  13/01  321  D1  i circumflex
  15351. 210  13/02  322  D2  O with stroke
  15352. 211  13/03  323  D3  AE digraph
  15353. 212  13/04  324  D4  a ring
  15354. 213  13/05  325  D5  i acute
  15355. 214  13/06  326  D6  o with stroke
  15356. 215  13/07  327  D7  ae digraph
  15357. 216  13/08  330  D8  A diaeresis
  15358. 217  13/09  331  D9  i grave
  15359. 218  13/10  332  DA  O diaeresis
  15360. 219  13/11  333  DB  U diaeresis
  15361. 220  13/12  334  DC  E acute
  15362. 221  13/13  335  DD  i diaeresis
  15363. 222  13/14  336  DE  German sharp s
  15364. 223  13/15  337  DF  O circumflex
  15365. 224  14/00  340  E0  A acute
  15366. 225  14/01  341  E1  A tilde
  15367. 226  14/02  342  E2  a tilde
  15368. 227  14/03  343  E3  Icelandic Eth
  15369. 228  14/04  344  E4  Icelandic eth
  15370. 229  14/05  345  E5  I acute
  15371. 230  14/06  346  E6  I grave
  15372. 231  14/07  347  E7  O acute
  15373. 232  14/08  350  E8  O grave
  15374. 233  14/09  351  E9  O tilde
  15375. 234  14/10  352  EA  o tilde
  15376. 235  14/11  353  EB  S caron
  15377. 236  14/12  354  EC  s caron
  15378. 237  14/13  355  ED  U acute
  15379. 238  14/14  356  EE  Y diaeresis
  15380. 239  14/15  357  EF  y diaeresis
  15381. 240  15/00  360  F0  Icelandic Thorn
  15382. 241  15/01  361  F1  Icelandic thorn
  15383. 242  15/02  362  F2  Middle dot
  15384. 243  15/03  363  F3  Greek mu
  15385. 244  15/04  364  F4  Pilcrow sign
  15386. 245  15/05  365  F5  Fraction 3/4
  15387. 246  15/06  366  F6  Long dash, horizontal bar
  15388. 247  15/07  367  F7  Fraction 1/4
  15389. 248  15/08  370  F8  Fraction 1/2
  15390. 249  15/09  371  F9  Feminine ordinal
  15391. 250  15/10  372  FA  Masculine ordinal
  15392. 251  15/11  373  FB  Left guillemot
  15393. 252  15/12  374  FC  Solid box
  15394. 253  15/13  375  FD  Right guillemot
  15395. 254  15/14  376  FE  Plus or minus sign
  15396. 255  15/15  377  FF  (Undefined)
  15397.  
  15398. III.1.2. Greek Character Sets
  15399.  
  15400. III.1.2.1. The ISO 8859-7 Latin / Greek Alphabet = ELOT 928
  15401.  
  15402. dec col/row oct hex  description
  15403. 160  10/00  240  A0  No-break space
  15404. 161  10/01  241  A1  Left single quotation mark
  15405. 162  10/02  242  A2  right single quotation mark
  15406. 163  10/03  243  A3  Pound sign
  15407. 164  10/04  244  A4  (UNUSED)
  15408. 165  10/05  245  A5  (UNUSED)
  15409. 166  10/06  246  A6  Broken bar
  15410. 167  10/07  247  A7  Paragraph sign
  15411. 168  10/08  250  A8  Diaeresis (Dialytika)
  15412. 169  10/09  251  A9  Copyright sign
  15413. 170  10/10  252  AA  (UNUSED)
  15414. 171  10/11  253  AB  Left angle quotation
  15415. 172  10/12  254  AC  Not sign
  15416. 173  10/13  255  AD  Soft hyphen
  15417. 174  10/14  256  AE  (UNUSED)
  15418. 175  10/15  257  AF  Horizontal bar (Parenthetiki pavla)
  15419. 176  11/00  260  B0  Degree sign
  15420. 177  11/01  261  B1  Plus-minus sign
  15421. 178  11/02  262  B2  Superscript two
  15422. 179  11/03  263  B3  Superscript three
  15423. 180  11/04  264  B4  Accent (tonos)
  15424. 181  11/05  265  B5  Diaeresis and accent (Dialytika and Tonos)
  15425. 182  11/06  266  B6  Alpha with accent
  15426. 183  11/07  267  B7  Middle dot (Ano Teleia)
  15427. 184  11/08  270  B8  Epsilon with accent
  15428. 185  11/09  271  B9  Eta with accent
  15429. 186  11/10  272  BA  Iota with accent
  15430. 187  11/11  273  BB  Right angle quotation
  15431. 188  11/12  274  BC  Omicron with accent
  15432. 189  11/13  275  BD  One half
  15433. 190  11/14  276  BE  Upsilon with accent
  15434. 191  11/15  277  BF  Omega with accent
  15435. 192  12/00  300  C0  iota with diaeresis and accent
  15436. 193  12/01  301  C1  Alpha
  15437. 194  12/02  302  C2  Beta
  15438. 195  12/03  303  C3  Gamma
  15439. 196  12/04  304  C4  Delta
  15440. 197  12/05  305  C5  Epsilon
  15441. 198  12/06  306  C6  Zeta
  15442. 199  12/07  307  C7  Eta
  15443. 200  12/08  310  C8  Theta
  15444. 201  12/09  311  C9  Iota
  15445. 202  12/10  312  CA  Kappa
  15446. 203  12/11  313  CB  Lamda
  15447. 204  12/12  314  CC  Mu
  15448. 205  12/13  315  CD  Nu
  15449. 206  12/14  316  CE  Ksi
  15450. 207  12/15  317  CF  Omicron
  15451. 208  13/00  320  D0  Pi
  15452. 209  13/01  321  D1  Rho
  15453. 210  13/02  322  D2  (UNUSED)
  15454. 211  13/03  323  D3  Sigma
  15455. 212  13/04  324  D4  Tau
  15456. 213  13/05  325  D5  Upsilon
  15457. 214  13/06  326  D6  Phi
  15458. 215  13/07  327  D7  Khi
  15459. 216  13/08  330  D8  Psi
  15460. 217  13/09  331  D9  Omega
  15461. 218  13/10  332  DA  Iota with diaeresis
  15462. 219  13/11  333  DB  Upsilon with diaeresis
  15463. 220  13/12  334  DC  alpha with accent
  15464. 221  13/13  335  DD  epsilon with accent
  15465. 222  13/14  336  DE  eta with accent
  15466. 223  13/15  337  DF  iota with accent
  15467. 224  14/00  340  E0  upsilon with diaeresis and accent
  15468. 225  14/01  341  E1  alpha
  15469. 226  14/02  342  E2  beta
  15470. 227  14/03  343  E3  gamma
  15471. 228  14/04  344  E4  delta
  15472. 229  14/05  345  E5  epsilon
  15473. 230  14/06  346  E6  zeta
  15474. 231  14/07  347  E7  eta
  15475. 232  14/08  350  E8  theta
  15476. 233  14/09  351  E9  iota
  15477. 234  14/10  352  EA  kappa
  15478. 235  14/11  353  EB  lamda
  15479. 236  14/12  354  EC  mu
  15480. 237  14/13  355  ED  nu
  15481. 238  14/14  356  EE  ksi
  15482. 239  14/15  357  EF  omicron
  15483. 240  15/00  360  F0  pi
  15484. 241  15/01  361  F1  rho
  15485. 242  15/02  362  F2  terminal sigma
  15486. 243  15/03  363  F3  sigma
  15487. 244  15/04  364  F4  tau
  15488. 245  15/05  365  F5  upsilon
  15489. 246  15/06  366  F6  phi
  15490. 247  15/07  367  F7  khi
  15491. 248  15/08  370  F8  psi
  15492. 249  15/09  371  F9  omega
  15493. 250  15/10  372  FA  iota with diaeresis
  15494. 251  15/11  373  FB  upsilon with diaeresis
  15495. 252  15/12  374  FC  omicron with diaeresis
  15496. 253  15/13  375  FD  upsilon with accent
  15497. 254  15/14  376  FE  omega with accent
  15498. 255  15/15  377  FF  (UNUSED)
  15499.  
  15500. III.1.2.2. The ELOT 927 Character Set
  15501.  
  15502. dec col/row oct hex  description
  15503.  32  02/00   40  20  SPACE
  15504.  33  02/01   41  21  EXCLAMATION MARK
  15505.  34  02/02   42  22  QUOTATION MARK
  15506.  35  02/03   43  23  NUMBER SIGN
  15507.  36  02/04   44  24  DOLLAR SIGN
  15508.  37  02/05   45  25  PERCENT SIGN
  15509.  38  02/06   46  26  AMPERSAND
  15510.  39  02/07   47  27  APOSTROPHE
  15511.  40  02/08   50  28  LEFT PARENTHESIS
  15512.  41  02/09   51  29  RIGHT PARENTHESIS
  15513.  42  02/10   52  2A  ASTERISK
  15514.  43  02/11   53  2B  PLUS SIGN
  15515.  44  02/12   54  2C  COMMA
  15516.  45  02/13   55  2D  HYPHEN, MINUS SIGN
  15517.  46  02/14   56  2E  PERIOD, FULL STOP
  15518.  47  02/15   57  2F  SOLIDUS, SLASH
  15519.  48  03/00   60  30  DIGIT ZERO
  15520.  49  03/01   61  31  DIGIT ONE
  15521.  50  03/02   62  32  DIGIT TWO
  15522.  51  03/03   63  33  DIGIT THREE
  15523.  52  03/04   64  34  DIGIT FOUR
  15524.  53  03/05   65  35  DIGIT FIVE
  15525.  54  03/06   66  36  DIGIT SIX
  15526.  55  03/07   67  37  DIGIT SEVEN
  15527.  56  03/08   70  38  DIGIT EIGHT
  15528.  57  03/09   71  39  DIGIT NINE
  15529.  58  03/10   72  3A  COLON
  15530.  59  03/11   73  3B  SEMICOLON
  15531.  60  03/12   74  3C  LESS-THAN SIGN, LEFT ANGLE BRACKET
  15532.  61  03/13   75  3D  EQUALS SIGN
  15533.  62  03/14   76  3E  GREATER-THAN SIGN, RIGHT ANGLE BRACKET
  15534.  63  03/15   77  3F  QUESTION MARK
  15535.  64  04/00  100  40  COMMERCIAL AT SIGN
  15536.  65  04/01  101  41  CAPITAL LETTER A
  15537.  66  04/02  102  42  CAPITAL LETTER B
  15538.  67  04/03  103  43  CAPITAL LETTER C
  15539.  68  04/04  104  44  CAPITAL LETTER D
  15540.  69  04/05  105  45  CAPITAL LETTER E
  15541.  70  04/06  106  46  CAPITAL LETTER F
  15542.  71  04/07  107  47  CAPITAL LETTER G
  15543.  72  04/08  110  48  CAPITAL LETTER H
  15544.  73  04/09  111  49  CAPITAL LETTER I
  15545.  74  04/10  112  4A  CAPITAL LETTER J
  15546.  75  04/11  113  4B  CAPITAL LETTER K
  15547.  76  04/12  114  4C  CAPITAL LETTER L
  15548.  77  04/13  115  4D  CAPITAL LETTER M
  15549.  78  04/14  116  4E  CAPITAL LETTER N
  15550.  79  04/15  117  4F  CAPITAL LETTER O
  15551.  80  05/00  120  50  CAPITAL LETTER P
  15552.  81  05/01  121  51  CAPITAL LETTER Q
  15553.  82  05/02  122  52  CAPITAL LETTER R
  15554.  83  05/03  123  53  CAPITAL LETTER S
  15555.  84  05/04  124  54  CAPITAL LETTER T
  15556.  85  05/05  125  55  CAPITAL LETTER U
  15557.  86  05/06  126  56  CAPITAL LETTER V
  15558.  87  05/07  127  57  CAPITAL LETTER W
  15559.  88  05/08  130  58  CAPITAL LETTER X
  15560.  89  05/09  131  59  CAPITAL LETTER Y
  15561.  90  05/10  132  5A  CAPITAL LETTER Z
  15562.  91  05/11  133  5B  LEFT SQUARE BRACKET
  15563.  92  05/12  134  5C  REVERSE SOLIDUS, BACKSLASH
  15564.  93  05/13  135  5D  RIGHT SQUARE BRACKET
  15565.  94  05/14  136  5E  CIRCUMFLEX ACCENT
  15566.  95  05/15  137  5F  UNDERSCORE
  15567.  96  06/00  140  60  ACCENT GRAVE
  15568.  97  06/01  141  61  GREEK LETTER ALPHA
  15569.  98  06/02  142  62  GREEK LETTER BETA
  15570.  99  06/03  143  63  GREEK LETTER GAMMA
  15571. 100  06/04  144  64  GREEK LETTER DELTA
  15572. 101  06/05  145  65  GREEK LETTER EPSILON
  15573. 102  06/06  146  66  GREEK LETTER ZETA
  15574. 103  06/07  147  67  GREEK LETTER ETA
  15575. 104  06/08  150  68  GREEK LETTER THETA
  15576. 105  06/09  151  69  GREEK LETTER IOTA
  15577. 106  06/10  152  6A  GREEK LETTER KAPPA
  15578. 107  06/11  153  6B  GREEK LETTER LAMDA
  15579. 108  06/12  154  6C  GREEK LETTER MU
  15580. 109  06/13  155  6D  GREEK LETTER NU
  15581. 110  06/14  156  6E  GREEK LETTER KSI
  15582. 111  06/15  157  6F  GREEK LETTER OMICRON
  15583. 112  07/00  160  70  GREEK LETTER PI
  15584. 113  07/01  161  71  GREEK LETTER RHO
  15585. 114  07/02  162  72  GREEK LETTER SIGMA
  15586. 115  07/03  163  73  GREEK LETTER TAU
  15587. 116  07/04  164  74  GREEK LETTER UPSILON
  15588. 117  07/05  165  75  GREEK LETTER FI
  15589. 118  07/06  166  76  GREEK LETTER XI
  15590. 119  07/07  167  77  GREEK LETTER PSI
  15591. 120  07/08  170  78  GREEK LETTER OMEGA
  15592. 121  07/09  171  79  SPACE
  15593. 122  07/10  172  7A  SPACE
  15594. 123  07/11  173  7B  LEFT CURLY BRACKET, LEFT BRACE
  15595. 124  07/12  174  7C  VERTICAL LINE, VERTICAL BAR
  15596. 125  07/13  175  7D  RIGHT CURLY BRACKET, RIGHT BRACE
  15597. 126  07/14  176  7E  TILDE
  15598. 127  07/15  177  7F  RUBOUT, DELETE
  15599.  
  15600. III.1.2.3. PC Code Page 869
  15601.  
  15602. (to be filled in...)
  15603.  
  15604. III.2. Updated Country Codes
  15605.  
  15606. Date: Mon, 7 Apr 1997 23:23:49 EDT
  15607. From: Dave Leibold <dleibold@else.net>
  15608. Newsgroups: comp.dcom.telecom
  15609. Subject: Ex-USSR Country Codes Profile
  15610. Organization: TELECOM Digest
  15611.  
  15612. Ex-USSR Country Codes Profile
  15613. 4 April 1997
  15614.  
  15615. Below is a summary of the country codes that have formed in the wake
  15616. of the USSR dissolution, along with some updated findings and reports.
  15617. Additional or corrected information on any of these nations would be
  15618. welcome (c/o dleibold@else.net).
  15619.  
  15620. * Kyrgyz Republic country code 996 will take effect, at least in
  15621.   Canada, effective 1 May 1997, according to CRTC Telecom Order 97-464,
  15622.   based on Stentor Tariff Notice 433. There is no indication whether
  15623.   there will be a permissive dialing period involved or for how long
  15624.   such a permissive operation would remain.
  15625.  
  15626. * Country code 992 was reported as a recent assignment for Tajikistan,
  15627.   which will be moving from country code 7 at some unknown time.
  15628.  
  15629. * Uzbekistan has its own country code assignment, but I have no
  15630.   information if this is in service yet or what implementation dates
  15631.   have been set.
  15632.  
  15633. * Kazakstan does not have a known separate country code assignment
  15634.   at present. It remains in country code 7 for the time being.
  15635.  
  15636. * Russia seems destined to keep country code 7.
  15637.  
  15638. * Recent news reports speak of some agreements forming between Russia and
  15639. Belarus. While there is no outright reunification yet, there is expected
  15640. to be much closer ties between the two nations. Whether this will lead to
  15641. a reunification of telephone codes remains to be seen.
  15642.  
  15643. In the table, "Effective" means the date at which the country code
  15644. began service (which could vary according to the nation). "Mandatory"
  15645. means the date at which the country code 7 is invalid for calls to
  15646. that nation. There are a number of question marks since exact
  15647. dates have not been collected in all cases.
  15648.  
  15649. CC  Nation            Effective     Mandatory    Notes
  15650.  
  15651. 370 Lithuania         1993?         ???          Announced Jan 1993
  15652. 371 Latvia            1993?         ???
  15653. 372 Estonia           1 Feb 1993?   March 1993?
  15654. 373 Moldova           1993?         ???          Announced Jan 1993
  15655. 374 Armenia           1 May 1995    1 July 1995  Announced Jan 1995 (ITU)
  15656. 375 Belarus           16 Apr 1995   1997?
  15657. 380 Ukraine           16 Apr 1995   Oct 1995?
  15658. 7   Kazakstan         (no known changes)
  15659. 7   Russia            (presumably not changing)
  15660. 992 Tajikistan        ???           ???          Announced 1996-7?
  15661. 993 Turkmenistan      3 Jan 1997    3 Apr 1997   Canada as of 29 Nov 1996
  15662. 994 Azerbaijan        Sept 1994?    ???          Announced 1992
  15663. 995 Georgia           1994?         ???          ref: Telecom Digest Oct 1994
  15664. 996 Kyrgyz Republic   1 May 1997    ???          ref: Stentor Canada/CRTC
  15665. 998 Uzbekistan        ???           ???          Announced 1996? (ITU)
  15666.  
  15667. Details courtesy Toby Nixon, ITU, Stentor (Canada), CRTC (Canada),
  15668. TELECOM Digest (including information collected for the country code
  15669. listings).
  15670.  
  15671.  
  15672. IV. ERRATA & CORRIGENDA
  15673.  
  15674. The following errors in "Using C-Kermit", Second Edition, first printing,
  15675. have been noted.
  15676.  
  15677. First, some missing acknowledgements for C-Kermit 6.0: JE Jones of Microware
  15678. for help with OS-9, Nigel Roles for his help with Plan 9, Lucas Hart for help
  15679. with VMS and Digital UNIX, Igor Kovalenko for his help with QNX.  And later,
  15680. to Susan Kleinmann for her help with Debian Linux packaging; Patrick
  15681. Volkerding for his help with Slackware Linux packaging; Jim Knoble for his
  15682. help with Red Hat Linux packaging; and to dozens of others for sending
  15683. individual C-Kermit binaries for varied and diverse platforms.
  15684.  
  15685. Thanks to James Spath for both binaries and reporting many of the typos
  15686. noted below.  Also to Dat Thuc Nguyen for spotting several typos.
  15687.  
  15688. PAGE    REMARKS
  15689. COVER   "COS" is a misprint.  There is no COS.  Pretend it says "SCO" or "VOS".
  15690.         (This is fixed in the second printing.)
  15691.  xxi    Second line: Fred Smith's affiliation should be Computrition.
  15692.  83     Change "commands other" to "commands as other" (1st paragraph)
  15693.  87     Change "The the" to "The" (2nd paragraph)
  15694.  92     "set modem-type user-defined supra" should be "set modem type ..."
  15695.  95     Change "VI" to "vi" (1st paragraph)
  15696.  96     Change "it it" to "it is" (1st paragraph)
  15697.  97     Change "advantage a literal" to "advantage of a literal" (2nd
  15698.         paragraph)
  15699. 102     The call-waiting example would be better as SET DIAL PREFIX *70W
  15700.         (rather than "*70,") because the former will not cause an incorrect
  15701.         call to be placed with pulse dialing.
  15702. 123     Third paragraph from bottom: "..otherwise if a your local username.."
  15703.         should be "..otherwise your local username..".
  15704. 160     Delete the "it" between "and" and "to" (2nd paragraph)
  15705. 185     In "When TRANSFER DISPLAY is OFF, C-Kermit skips the display...",
  15706.         "OFF" should be "NONE".
  15707. 187     The last paragraph says the "A command" is ignored, should be "S".
  15708. 194     Change "it known" to "it is known" (4th paragraph).
  15709. 235     In C-Kermit 7.0, the syntax of the GET command changed.  MGET now
  15710.         must be used to get a list of files and there is no more multiline
  15711.         GET command.
  15712. 268     Last paragraph: "effect" should be "affect".
  15713. 275     In the SET PROTOCOL KERMIT description, the following sentence is
  15714.         incorrect and should be removed: 'If you omit the commands, the
  15715.         default ones are restored: "kermit -ir" and "kermit -r" respectively".
  15716.         The correct information is given at the bottom of page 281.
  15717. 279     9th line.  The decimal value of ST is 156, not 155.
  15718. 295     In the stepping stones, skip ahead to Chapter 17 on p. 327.
  15719. 298     Table 16-2, Portuguese entry.  Column 4/00 should show section sign,
  15720.         not acute accent.
  15721. 316     Other languages written in the Hebrew alphabet include Karaim (a Turkic
  15722.         language spoken in Lithuania and Poland), Judeo-Kurdish, and Judeo-
  15723.         Georgian.
  15724. 332     UNDEFINE definition, change "This just" to "This is just".
  15725. 344     It might be necessary to set the modem's pulse generation rate when
  15726.         sending numeric pages; most Hayes compatible modems use the S11
  15727.         register for this.
  15728. 350     Delete "is" from between "It" and "ceases" (4th paragraph)
  15729. 351     Top - both occurrences of "print \%a" should be "echo \%a".
  15730. 364     \v(input) and \v(query) out of alphabetical order.
  15731. 378     In the MYSEND macro, "if not \m(rc) goto bad" should be:
  15732.         "if \m(rc) goto bad" (remove the "not").
  15733. 382-383 It should be stated that the loop control variable must be of the \%a
  15734.         type, or else an array element; macro names can not be used for this.
  15735. 383     In line 3, "\%f[\%i]" should be "\&f[\%i]".
  15736. 383     In the sort example, it should be stated that the array is 1-based.
  15737. 387     Change "You can list" to "You can get a list" (5th paragraph)
  15738. 393     \Fverify() description.  The 3rd sentence could be stated more clearly
  15739.         as "If all characters in string2 are also in string1, 0 is returned."
  15740. 398     Copying \ffiles() results to an array before is not required as of
  15741.         C-Kermit 7.0 (see section 7.3).
  15742. 403     In "(\%a + 3) * (\%b  5)", a minus sign is missing between b and 5.
  15743. 407     C-Kermit 7.0 no longer supports multiline GET.  Change
  15744.         "get, \%1, \%2" to "get {\%1} {\%2}" or "get /as:{\%2} {\%1}".
  15745. 409     READ example while loop should be:
  15746.         while success { echo \m(line), read line }
  15747. 409     "WRITE file" should be "WRITE keyword" (you can't put a filename there)
  15748.         (The same applies to WRITE-LINE / WRITELN).
  15749. 414     \Funhexify() missing from Table 18-3.
  15750. 425     MINPUT definition, change 2nd "text2" to "text3".
  15751. 436     Several lines are missing from the UNIXLOGIN macro listing.
  15752.         After the "xif fail" block, insert:
  15753.  
  15754.       out \%1\13                    ; Send username, carriage return
  15755.       inp 5 Password:               ; Wait 5 sec for this prompt
  15756.       if fail end 1 No password prompt
  15757.       pause                         ; Wait a sec
  15758.       out \%2\13                    ; Send password
  15759.  
  15760. 440     Change "set terminal byteszie" to "set terminal bytesize".
  15761.         Change "input Password:" to "input 10 Password".
  15762. 448     Franchise script: "access line" should be "access \m(line)".
  15763. 453     There are two incorrectly coded IF statements in the DELIVER macro
  15764.         definition.  Replace both occurrences of "if > \%1 \%3 {" with
  15765.         "xif > \%i \%3 {" (replace "if" by "xif" and "\%1" with "\%i").
  15766. 453     "the the" (last paragraph) should be "the".
  15767. 454     EOT (last paragraph) is End of Transmission, not End of Text.
  15768. 457     _DEFINE definition: "name constructed" should be "name is constructed".
  15769. 457     "macro for and" (last paragraph) should be "macro and".
  15770. 459     Should explain that \v(user) is a legal abbreviation of \v(userid).
  15771. 480     Figure II-2 is backwards; the least-significant bit is transmitted
  15772.         first, then up to the highest, and the parity bit last.
  15773. 534     The VMS Appendix section on Odd Record Lengths no longer applies;
  15774.         C-Kermit 7.0 handles odd record lengths as well as even ones.
  15775. 559     Table VIII-3, Portuguese entry.  Column 4/00 should show section sign,
  15776.         not acute accent.
  15777. 560-563 HP-Roman8 missing from Table VII-4; there wasn't room to squeeze it in.
  15778.         It is listed in section II(6).
  15779. 565     "d stroke" in Table VII-5 has the wrong appearance; the stem should
  15780.         be upright.  The letter shown in the table is actually a lowercase
  15781.         Icelandic eth, which has a curved stem.
  15782. 601-604 BeBox, BeOS, Plan 9, and probably others not listed in trademarks.
  15783. 604     The words "SCRIBE TEXT FORMATTER" appear at the end of the last
  15784.         sentence of the first paragraph of the Colophon.  They should have
  15785.         been in the Index.
  15786. Index:  Missing entries: SET { SEND, RECEIVE } PATHNAMES, Call waiting, ...
  15787.     \F()            Page 605, add also 413-414
  15788.     \Fbreak         389
  15789.     \Fcapitalize    390
  15790.     \Fchecksum      414
  15791.     \Fcrc16         414
  15792.     \Fexecute       414
  15793.     \Fhexify        390
  15794.     \Fltrim         391
  15795.         \Frepeat        392
  15796.     \Fspawn         392
  15797.     \Ftod2secs      399
  15798.     \v() built_in   Page 606, add also 361-364
  15799.     \v(_line)       354, 361
  15800.     \v(apcactive)   361
  15801.     \v(charset)     362
  15802.     \v(cpu)         362
  15803.     \v(crc16)       357, 362
  15804.     \v(d$xxx)       add page 362
  15805.     \v(dialnumber)  362
  15806.     \v(dialresult)  362
  15807.     \v(errno)       362
  15808.     \v(errstring)   362
  15809.     \v(exedir)      362
  15810.     \v(inidir)      363
  15811.     \v(ipaddress)   363
  15812.     \v(keyboard)    363
  15813.     \v(macro)       363
  15814.     \v(minput)      363
  15815.     \v(m_xxx)       94, 363
  15816.     \v(password)    364
  15817.     \v(query)       364
  15818.     \v(prompt)      364
  15819.     \v(speed)       356, 364
  15820.     \v(startup)     364
  15821.     \v(status)      364
  15822.     \v(sysid)       364
  15823.     \v(system)      364
  15824.     \v(fsize)       at lower half page 606 should read \v(tfsize)
  15825.     \v(xversion)    364
  15826.         BEEP Command    40
  15827.         SET FLOW        62, 212
  15828.  
  15829. Figure II-5 on page 493.  The pin assignments of the Mini Din-8 connector
  15830. are not described anywhere.  As noted in the text, these tend to vary from
  15831. vendor to vendor.  One common arrangement is:
  15832.  
  15833.   1. HSKout (Handshake out -- definition depends on software)
  15834.   2. HSKin  (Handshake in or external clock)
  15835.   3. TxD-
  15836.   4. Not used
  15837.   5. RxD-
  15838.   6. TxD+
  15839.   7. Not used
  15840.   8. RxD+
  15841.  
  15842. Note the "balanced pairs" for Receive Data (RxD) and Transmit Data (TxD), and
  15843. the utter lack of modem signals.  These connectors follow the RS-423 standard,
  15844. rather than RS-232.  In some arrangements, Pin 1 is used for DTR and Pin 2 for
  15845. CD; in others Pin 1 is RTS and Pin 2 is CTS.
  15846.  
  15847. Please send reports of other errors to the authors, as well as suggestions for
  15848. improvements, additional index entries, and any other comments:
  15849.  
  15850.   kermit@columbia.edu
  15851.  
  15852. APPENDIX V. ADDITIONAL COPYRIGHT NOTICES
  15853.  
  15854. The following copyrights cover some of the source code used in the development
  15855. of C-Kermit, Kermit 95, or Kermit 95 support libraries.
  15856.  
  15857. /*****************************************************************************/
  15858. /*                                                                           */
  15859. /*              Copyright (c) 1995 by Oy Online Solutions Ltd.               */
  15860. /*                                                                           */
  15861. /*   Distribution of this source code is strictly forbbidden. Use of this    */
  15862. /*   source code is granted to the University of Columbia C-Kermit project   */
  15863. /*   to be distributed in binary format only. Please familiarize yourself    */
  15864. /*   with the accompanying LICENSE.P file.                                   */
  15865. /*                                                                           */
  15866. /*****************************************************************************/
  15867.  
  15868. used for Xmodem, Ymodem, and Zmodem protocol in Kermit 95 (p95.dll, p2.dll)
  15869.  
  15870. -----
  15871.  
  15872. Copyright (c) 1997 Stanford University
  15873.  
  15874. The use of this software for revenue-generating purposes may require a
  15875. license from the owners of the underlying intellectual property.
  15876. Specifically, the SRP-3 protocol may not be used for revenue-generating
  15877. purposes without a license.
  15878.  
  15879. Within that constraint, permission to use, copy, modify, and distribute
  15880. this software and its documentation for any purpose is hereby granted
  15881. without fee, provided that the above copyright notices and this permission
  15882. notice appear in all copies of the software and related documentation.
  15883.  
  15884. THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  15885. EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  15886. WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  15887.  
  15888. IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15889. INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  15890. RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
  15891. THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
  15892. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15893.  
  15894. Used for Secure Remote Password (TM) protocol (SRP) in C-Kermit,
  15895. Kermit 95 (k95.exe, k2.exe, k95crypt.dll, k2crypt.dll)
  15896.  
  15897. -----
  15898.  
  15899. Copyright 1990 by the Massachusetts Institute of Technology.
  15900. All Rights Reserved.
  15901.  
  15902. Export of this software from the United States of America may
  15903.   require a specific license from the United States Government.
  15904.   It is the responsibility of any person or organization contemplating
  15905.   export to obtain such a license before exporting.
  15906.  
  15907. WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  15908. distribute this software and its documentation for any purpose and
  15909. without fee is hereby granted, provided that the above copyright
  15910. notice appear in all copies and that both that copyright notice and
  15911. this permission notice appear in supporting documentation, and that
  15912. the name of M.I.T. not be used in advertising or publicity pertaining
  15913. to distribution of the software without specific, written prior
  15914. permission.  M.I.T. makes no representations about the suitability of
  15915. this software for any purpose.  It is provided "as is" without express
  15916. or implied warranty.
  15917.  
  15918.  
  15919. Used for Telnet Authentication Option, Telnet Encryption Option,
  15920. and Kerberos (TM) authentication in C-Kermit, Kermit 95 (k95.exe, k2.exe,
  15921. k95crypt.dll, k2crypt.dll)
  15922.  
  15923. -----
  15924.  
  15925. Copyright (c) 1991, 1993
  15926. The Regents of the University of California.  All rights reserved.
  15927.  
  15928. Redistribution and use in source and binary forms, with or without
  15929. modification, are permitted provided that the following conditions
  15930. are met:
  15931. 1. Redistributions of source code must retain the above copyright
  15932.    notice, this list of conditions and the following disclaimer.
  15933. 2. Redistributions in binary form must reproduce the above copyright
  15934.    notice, this list of conditions and the following disclaimer in the
  15935.    documentation and/or other materials provided with the distribution.
  15936. 3. All advertising materials mentioning features or use of this software
  15937.    must display the following acknowledgement:
  15938. This product includes software developed by the University of
  15939. California, Berkeley and its contributors.
  15940. 4. Neither the name of the University nor the names of its contributors
  15941.    may be used to endorse or promote products derived from this software
  15942.    without specific prior written permission.
  15943.  
  15944. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  15945. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15946. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15947. ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  15948. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15949. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  15950. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  15951. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  15952. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  15953. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15954. SUCH DAMAGE.
  15955.  
  15956. Used for Telnet Authentication Option, Telnet Encryption Option,
  15957. and Kerberos (TM) authentication in C-Kermit, Kermit 95 (k95.exe, k2.exe,
  15958. k95crypt.dll, k2crypt.dll)
  15959.  
  15960. -----
  15961.  
  15962. Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
  15963. All rights reserved.
  15964.  
  15965. This package is an DES implementation written by Eric Young
  15966. (eay@cryptsoft.com).  The implementation was written so as to conform with
  15967. MIT's libdes.
  15968.  
  15969. This library is free for commercial and non-commercial use as long as
  15970. the following conditions are aheared to.  The following conditions
  15971. apply to all code found in this distribution.
  15972.  
  15973. Copyright remains Eric Young's, and as such any Copyright notices in
  15974. the code are not to be removed.
  15975. If this package is used in a product, Eric Young should be given attribution
  15976. as the author of that the SSL library.  This can be in the form of a textual
  15977. message at program startup or in documentation (online or textual) provided
  15978. with the package.
  15979.  
  15980. Redistribution and use in source and binary forms, with or without
  15981. modification, are permitted provided that the following conditions
  15982. are met:
  15983. 1. Redistributions of source code must retain the copyright
  15984.    notice, this list of conditions and the following disclaimer.
  15985. 2. Redistributions in binary form must reproduce the above copyright
  15986.    notice, this list of conditions and the following disclaimer in the
  15987.    documentation and/or other materials provided with the distribution.
  15988. 3. All advertising materials mentioning features or use of this software
  15989.    must display the following acknowledgement:
  15990.    This product includes software developed by Eric Young (eay@cryptsoft.com)
  15991.  
  15992. THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  15993. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15994. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15995. ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  15996. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15997. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  15998. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  15999. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  16000. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  16001. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16002. SUCH DAMAGE.
  16003.  
  16004. The license and distribution terms for any publically available version or
  16005. derivative of this code cannot be changed.  i.e. this code cannot simply be
  16006. copied and put under another distrubution license
  16007. [including the GNU Public License.]
  16008.  
  16009. The reason behind this being stated in this direct manner is past
  16010. experience in code simply being copied and the attribution removed
  16011. from it and then being distributed as part of other packages. This
  16012. implementation was a non-trivial and unpaid effort.
  16013.  
  16014. Used DES encryption in Kermit 95 (k95crypt.dll, k2crypt.dll)
  16015.  
  16016. ----
  16017.  
  16018.  * This is version 1.1 of CryptoLib
  16019.  *
  16020.  * The authors of this software are Jack Lacy, Don Mitchell and Matt Blaze
  16021.  *              Copyright (c) 1991, 1992, 1993, 1994, 1995 by AT&T.
  16022.  * Permission to use, copy, and modify this software without fee
  16023.  * is hereby granted, provided that this entire notice is included in
  16024.  * all copies of any software which is or includes a copy or
  16025.  * modification of this software and in all copies of the supporting
  16026.  * documentation for such software.
  16027.  *
  16028.  * NOTE:
  16029.  * Some of the algorithms in cryptolib may be covered by patents.
  16030.  * It is the responsibility of the user to ensure that any required
  16031.  * licenses are obtained.
  16032.  *
  16033.  *
  16034.  * SOME PARTS OF CRYPTOLIB MAY BE RESTRICTED UNDER UNITED STATES EXPORT
  16035.  * REGULATIONS.
  16036.  *
  16037.  *
  16038.  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
  16039.  * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
  16040.  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  16041.  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  16042.  
  16043. Used for Big Number library in Kermit 95 (k95crypt.dll, k2crypt.dll).
  16044.  
  16045. ------------------------------
  16046. END OF CKERMIT2.TXT
  16047.