home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95 / ckermit2.txt < prev    next >
Text File  |  2020-01-01  |  684KB  |  16,074 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.197
  6. This file last updated:  8 February 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 Colin Allen, Mark
  107. Allen, Roger Allen, Ric Anderson, William Bader, Mitch Baker, Mitchell Bass,
  108. Nelson Beebe, Gerry Belanger, Jeff Bernsten, Mark Berryman, John Bigg, Volker
  109. Borchert, Jonathan Boswell, Tim Boyer, Frederick Bruckman, Kenneth Cochran,
  110. Jared Crapo, Bill Delaney, Igor Sobrado Delgado, Clarence Dold, Joe Doupnik,
  111. John Dunlap, Max Evarts, Patrick French, Carl Friedberg, Carl Friend, Hirofumi
  112. Fujii, Andrew Gabriel, Gabe Garza, Boyd Gerber, David Gerber, George Gilmer,
  113. Hunter Goatley, DJ Hagberg, Kevin Handy, Andy Harper, Randolph Herber, Sven
  114. Holstrum, Michal Jaegermann, Graham Jenkins, Dick Jones, Terry Kennedy, Robert
  115. D Keys, Nick Kisseberth, Igor Kovalenko, David Lane, Adam Laurie, Jeff
  116. Liebermann, Eric Lonvick, Hoi Wan Louis, Arthur Marsh, Gregorie Martin, Peter
  117. Mauzey, Dragan Milicic, Todd Miller, Christian Mondrup, Daniel Morato, Dat
  118. Nguyen, Herb Peyerl, Jean-Pierre Radley, Mitchell Pilot, Steve Rance, Stephen
  119. Riehm, Nigel Roles, Larry Rosenman, Jay S Rouman, David Sanderson, John
  120. Santos, Michael Schmitz, Steven Schultz, Bob Shair, Richard Shuford, Fred
  121. Smith, Michael Sokolov, Jim Spath, Peter Szell, Ted T'so, Brian Tillman, Linus
  122. Torvalds, Patrick Volkerding, Martin Vorlaender, Steve Walton, Ken Weaverling,
  123. John Weekley, Martin Whitaker, Jim Whitby, Matt Willman, Joellen Windsor,
  124. Farrell Woods, and many others for binaries, hosting, reviews, suggestions,
  125. advice, bug reports, and all the rest over the 3+ year C-Kermit 7.0
  126. development cycle.  Thanks to Russ Nelson and the board of the Open Software
  127. Initiative for their cooperation in developing the new C-Kermit license and to
  128. the proprietors of those free UNIX distributions that have incorporated
  129. C-Kermit 7.0 for their cooperation and support, especially FreeBSD's Joerg
  130. Wunsch.
  131.  
  132. -----------------------
  133. NOTE TO KERMIT 95 USERS
  134.  
  135. Like the book "Using C-Kermit", this file concentrates on the aspects of
  136. C-Kermit that are common to all versions: UNIX, VMS, VOS, AOS/VS, etc.  Please
  137. refer to your Kermit 95 documentation for information that is specific to
  138. Kermit 95.
  139.  
  140. C-Kermit 7.0 corresponds to Kermit 95 1.1.18.
  141.  
  142. -------------------------------------
  143. C-KERMIT VERSIONS AND VERSION NUMBERS
  144.  
  145. "C-Kermit" refers to all the many programs that are compiled in whole or in
  146. part from common C-language source code, comprising:
  147.  
  148.  . A Kermit file transfer protocol module
  149.  . A command parser and script execution module
  150.  . A modem-dialing module
  151.  . A network support module
  152.  . A character-set translation module.
  153.  
  154. and several others.  These "system-independent" modules are combined with
  155. system-dependent modules for each platform to provide the required
  156. input/output functions, and also in some cases overlaid with an alternative
  157. user interface, such as Macintosh Kermit's point-and-click interface, and in
  158. some cases also a terminal emulator, as Kermit 95.
  159.  
  160. The C-Kermit version number started as 1.0, ... 3.0, 4.0, 4.1 and then
  161. (because of confusion at the time with Berkeley UNIX 4.2), 4B, 4C, and so on,
  162. with the specific edit number in parentheses, for example 4E(072) or 5A(188).
  163. This scheme was used through 5A(191), but now we have gone back to the
  164. traditional numbering scheme with decimal points:  major.minor.edit; for
  165. example 7.0.196.  Internal version numbers (the \v(version) variable),
  166. however, are compatible in C-Kermit 5A upwards.
  167.  
  168. Meanwhile, C-Kermit derivatives for some platforms (Windows, Macintosh) might
  169. go through several releases while C-Kermit itself remains the same.  These
  170. versions have their own platform-specific version numbers, such as Kermit 95
  171. 1.1.1, 1.1.2, and so on.
  172.  
  173. C-Kermit Version History:
  174.  
  175.   1.0       1981-1982         Command-line only, 4.2 BSD UNIX only
  176.   2.0       (*)               (who remembers...)
  177.   3.0       May 1984          Command-line only, supports several platforms
  178.   4.0-4.1   Feb-Apr 1985 (*)  First interactive and modular version
  179.   4C(050)   May 1985
  180.   4D(060)   April 1986
  181.   4E(066)   August 1987       Long packets
  182.   4E(068)   January 1988
  183.   4E(072)   January 1989
  184.   4F(095)   August 1989 (*)   Attribute packets
  185.   5A(188)   November 1992     Scripting, TCP/IP, sliding windows, ANSI C (1)
  186.   5A(189)   September 1993    Control-char unprefixing
  187.   5A(190)   October 1994      Recovery
  188.   5A(191)   April 1995        OS/2 only - VT220 emulation
  189.   6.0.192   September 1996    Intelligent dialing, autodownload, lots more (2)
  190.   6.1.193   1997-98 (*)       Development only
  191.   6.1.194   June 1998         K95 only - switches, directory recursion, more
  192.   7.0.195   August 1999       IKSD + more (CU only as K95 1.1.18-CU)
  193.   7.0.196   1 January 2000    Unicode, lots more
  194.   7.0.197   8 February 2000   Same as 196 but builds on additional platforms(3)
  195.  
  196. (*) Never formally released (4.0 was a total rewrite)
  197. (1) "Using C-Kermit", 1st Edition.
  198. (2) "Using C-Kermit", 2nd Edition.
  199. (3) There is no functional difference between 196 and 197, not even bug fixes.
  200.     The only changes are to #ifdefs, declarations, and the makefile, sufficient
  201.     to make it build on several platforms where 196 did not build.  Binaries
  202.     that announce themselves as 197 are functionally identical to 196 binaries.
  203.  
  204. ------------------------------
  205. CONTENTS
  206.  
  207.  I.  C-KERMIT DOCUMENTATION: Information about the C-Kermit manual
  208.  
  209.  II. NEW FEATURES: Documentation for Features Added Since C-Kermit 6.0
  210.  
  211.      (0) INCOMPATIBILITIES WITH PREVIOUS RELEASES
  212.      (1) PROGRAM AND FILE MANAGEMENT AND COMMANDS
  213.          1.0.  Bug fixes
  214.          1.1.  Command Continuation
  215.          1.2.  Editor Interface
  216.          1.3.  Web Browser and FTP Interface
  217.          1.4.  Command Editing
  218.          1.5.  Command Switches
  219.                1.5.1. General Switch Syntax
  220.                1.5.2. Order and Effect of Switches
  221.                1.5.3. Distinguishing Switches from Other Fields
  222.                1.5.4. Standard File Selection Switches
  223.                1.5.5. Setting Preferences for Different Commands
  224.          1.6.  Dates and Times
  225.          1.7.  Partial Completion of Keywords
  226.          1.8.  Command Recall
  227.          1.9.  EXIT Messages
  228.          1.10. Managing Keyboard Interruptions
  229.          1.11. Taming the Wild Backslash -- Part Deux
  230.            1.11.1. Background
  231.            1.11.2. Kermit's Quoting Rules
  232.                1.11.3. Passing DOS Filenames from Kermit to Shell Commands
  233.            1.11.4. Using Variables to Hold DOS Filenames
  234.            1.11.5. Passing DOS Filenames as Parameters to Macros
  235.            1.11.6. Passing DOS File Names from Macro Parameters to
  236.                        the DOS Shell
  237.                1.11.7. Passing DOS Filenames to Kermit from the Shell
  238.          1.12. Debugging
  239.          1.13. Logs
  240.          1.14. Automatic File-Transfer Packet Recognition at the Command Prompt
  241.          1.15. The TYPE Command
  242.          1.16. The RESET Command
  243.          1.17. The COPY and RENAME Commands
  244.          1.18. The MANUAL Command
  245.          1.19. String and Filename Matching Patterns
  246.          1.20. Multiple Commands on One Line
  247.          1.21. What Do I Have?
  248.          1.22. Generalized File Input and Output
  249.            1.22.1. Why Another I/O System?
  250.            1.22.2. The FILE Command
  251.            1.22.3. FILE Command Examples
  252.            1.22.4. Channel Numbers
  253.            1.22.5. FILE Command Error Codes
  254.            1.22.6. File I/O Variables
  255.            1.22.7. File I/O Functions
  256.            1.22.8. File I/O Function Examples
  257.          1.23. The EXEC Command
  258.          1.24. Getting Keyword Lists with '?'
  259.      (2) MAKING AND USING CONNECTIONS
  260.          2.0. SET LINE and SET HOST Command Switches
  261.      2.1. Dialing
  262.           2.1.1. The Dial Result Message
  263.           2.1.2. Long-Distance Dialing Changes
  264.           2.1.3. Forcing Long-Distance Dialing
  265.           2.1.4. Exchange-Specific Dialing Decisions
  266.           2.1.5. Cautions about Cheapest-First Dialing
  267.           2.1.6. Blind Dialing (Dialing with No Dialtone)
  268.               2.1.7. Trimming the Dialing Dialog
  269.               2.1.8. Controlling the Dialing Speed
  270.               2.1.9. Pretesting Phone Number Conversions
  271.               2.1.10. Greater Control over Partial Dialing
  272.               2.1.11. New DIAL-related Variables and Functions
  273.               2.1.12. Increased Flexibility of PBX Dialing
  274.               2.1.13. The DIAL macro - Last-Minute Phone Number Conversions
  275.               2.1.14. Automatic Tone/Pulse Dialing Selection
  276.               2.1.15. Dial-Modifier Variables
  277.               2.1.16. Giving Multiple Numbers to the DIAL Command
  278.      2.2. Modems
  279.           2.2.1. New Modem Types
  280.           2.2.2. New Modem Controls
  281.      2.3. TELNET and RLOGIN
  282.               2.3.0. Bug Fixes
  283.           2.3.1. Telnet Binary Mode Bug Adjustments
  284.           2.3.2. VMS UCX Telnet Port Bug Adjustment
  285.           2.3.3. Telnet New Environment Option
  286.           2.3.4. Telnet Location Option
  287.               2.3.5. Connecting to Raw TCP Sockets
  288.               2.3.6. Incoming TCP Connections
  289.      2.4. The EIGHTBIT Command
  290.      2.5. The Services Directory
  291.          2.6. Closing Connections
  292.      2.7. Using C-Kermit with External Communication Programs
  293.               2.7.0. C-Kermit over tn3270 and tn5250
  294.           2.7.1. C-Kermit over Telnet
  295.           2.7.2. C-Kermit over Rlogin
  296.               2.7.3. C-Kermit over Serial Communication Programs
  297.           2.7.4. C-Kermit over Secure Network Clients
  298.           2.7.4.1. SSH
  299.           2.7.4.2. SSL
  300.           2.7.4.3. SRP
  301.           2.7.4.4. SOCKS
  302.               2.7.4.5. Kerberos and SRP
  303.          2.8. Scripting Local Programs
  304.          2.9. X.25 Networking
  305.               2.9.1. IBM AIXLink/X.25 Network Provider Interface for AIX
  306.               2.9.2. HP-UX X.25
  307.          2.10. Additional Serial Port Controls
  308.          2.11. Getting Access to the Dialout Device
  309.          2.12. The Connection Log
  310.          2.13. Automatic Connection-Specific Flow Control Selection
  311.          2.14. Trapping Connection Establishment and Loss
  312.          2.15. Contacting Web Servers with the HTTP Command
  313.      (3) TERMINAL CONNECTION
  314.          3.1. CONNECT Command Switches
  315.          3.2. Triggers
  316.          3.3. Transparent Printing
  317.          3.4. Binary and Text Session Logs
  318.      (4) FILE TRANSFER AND MANAGEMENT
  319.          4.0. Bug Fixes, Minor Changes, and Clarifications
  320.      4.1. File-Transfer Filename Templates
  321.      4.1.1. Templates in the As-Name
  322.      4.1.2. Templates on the Command Line
  323.      4.1.3. Post-Transfer Renaming
  324.      4.2. File-Transfer Pipes and Filters
  325.          4.2.1. Introduction
  326.      4.2.1.1. Terminology
  327.      4.2.1.2. Notation
  328.      4.2.1.3. Security
  329.      4.2.2. Commands for Transferring from and to Pipes
  330.      4.2.2.1. Sending from a Command
  331.      4.2.2.2. Receiving to a Command
  332.      4.2.3. Using File-Transfer Filters
  333.      4.2.3.1. The SEND Filter
  334.      4.2.3.2. The RECEIVE Filter
  335.      4.2.4. Implicit Use of Pipes
  336.      4.2.5. Success and Failure of Piped Commands
  337.          4.2.6. Cautions about Using Pipes to Transfer Directory Trees
  338.      4.2.7. Pipes and Encryption
  339.          4.2.8. Commands and Functions Related to Pipes
  340.      4.2.8.1. The OPEN !READ and OPEN !WRITE Commands
  341.      4.2.8.2. The REDIRECT Command
  342.          4.2.8.3. Receiving Mail and Print Jobs
  343.      4.2.8.4. Pipe-Related Functions
  344.          4.3. Automatic Per-File Text/Binary Mode Switching
  345.      4.3.1. Exceptions
  346.      4.3.2. Overview
  347.      4.3.3. Commands
  348.      4.3.4. Examples
  349.          4.4. File Permissions
  350.      4.4.1. When ATTRIBUTES PROTECTION is OFF
  351.      4.4.1.1. Unix
  352.      4.4.1.2. VMS
  353.      4.4.2. When ATTRIBUTES PROTECTION is ON
  354.      4.4.2.1. System-Specific Permissions
  355.      4.4.2.1.1. UNIX
  356.      4.4.2.1.2. VMS
  357.      4.4.2.2. System-Independent Permissions
  358.          4.5. File Management Commands
  359.          4.5.1. The DIRECTORY Command
  360.          4.5.2. The CD and BACK Commands
  361.          4.5.2.1. Parsing Improvements
  362.          4.5.2.2. The CDPATH
  363.      4.5.3. Creating and Removing Directories
  364.      4.5.4. The DELETE and PURGE Commands
  365.          4.6. Starting the Remote Kermit Server Automatically
  366.          4.7. File-Transfer Command Switches
  367.          4.7.1. SEND Command Switches
  368.          4.7.2. GET Command Switches
  369.          4.7.3. RECEIVE Command Switches
  370.          4.8. Kermit Protocol Improvements
  371.      4.8.1. Multiple Attribute Packets
  372.      4.8.2. Very Short Packets
  373.          4.9. Wildcard / File Group Expansion
  374.      4.9.1. In UNIX C-Kermit
  375.      4.9.2. In Kermit 95
  376.      4.9.3. In VMS, AOS/VS, OS-9, VOS, etc.
  377.          4.10. Additional Pathname Controls
  378.          4.11. Recursive SEND and GET: Transferring Directory Trees
  379.      4.11.1. Command-Line Options
  380.      4.11.2. The SEND /RECURSIVE Command
  381.      4.11.3. The GET /RECURSIVE Command
  382.      4.11.4. New and Changed Functions
  383.      4.11.5. Moving Directory Trees Between Like Systems
  384.      4.11.6. Moving Directory Trees Between Unlike Systems
  385.          4.12. Where Did My File Go?
  386.          4.13. File Output Buffer Control
  387.          4.14. Improved Responsiveness
  388.          4.15. Doubling and Ignoring Characters for Transparency
  389.          4.16. New File-Transfer Display Formats
  390.          4.17. New Transaction Log Formats
  391.          4.17.1. The BRIEF Format
  392.          4.17.2. The FTP Format
  393.          4.18. Unprefixing NUL
  394.          4.19. Clear-Channel Protocol
  395.          4.20. Streaming Protocol
  396.      4.20.1. Commands for Streaming
  397.      4.20.2. Examples of Streaming
  398.      4.20.2.1. Streaming on Socket-to-Socket Connections
  399.      4.20.2.2. Streaming on Telnet Connections
  400.          4.20.2.3. Streaming with Limited Packet Length
  401.          4.20.2.4. Streaming on Dialup Connections
  402.          4.20.2.5. Streaming on X.25 Connections
  403.          4.20.3. Streaming - Preliminary Conclusions
  404.          4.21. The TRANSMIT Command
  405.      4.22. Coping with Faulty Kermit Implementations
  406.      4.22.1. Failure to Accept Modern Negotiation Strings
  407.      4.22.2. Failure to Negotiate 8th-bit Prefixing
  408.      4.22.3. Corrupt Files
  409.      4.22.4. Spurious Cancellations
  410.      4.22.5. Spurious Refusals
  411.      4.22.6. Failures during the Data Transfer Phase
  412.      4.22.7. Fractured Filenames
  413.      4.22.8. Bad File Dates
  414.          4.23. File Transfer Recovery
  415.          4.24. FILE COLLISION UPDATE Clarification
  416.          4.25. Autodownload Improvements
  417.      (5) CLIENT/SERVER
  418.          5.0. Hints
  419.      5.1. New Command-Line Options
  420.      5.2. New Client Commands
  421.      5.3. New Server Capabilities
  422.          5.3.1. Creating and Removing Directories
  423.          5.3.2. Directory Listings
  424.          5.4. Syntax for Remote Filenames with Embedded Spaces
  425.          5.5. Automatic Orientation Messages upon Directory Change
  426.      5.6. New Server Controls
  427.      5.7. Timeouts during REMOTE HOST Command Execution
  428.      (6) INTERNATIONAL CHARACTER SETS
  429.          6.0. ISO 8859-15 Latin Alphabet 9
  430.          6.1. The HP-Roman8 Character Set
  431.          6.2. Greek Character Sets
  432.          6.3. Additional Latin-2 Character Sets
  433.          6.4. Additional Cyrillic Character Sets
  434.          6.5. Automatic Character-Set Switching
  435.          6.6. Unicode
  436.      6.6.1. Overview of Unicode
  437.      6.6.2. UCS Byte Order
  438.      6.6.2. UCS Transformation Formats
  439.      6.6.3. Conformance Levels
  440.      6.6.4. Relationship of Unicode with Kermit's Other Character Sets
  441.      6.6.5. Kermit's Unicode Features
  442.      6.6.5.1. File Transfer
  443.      6.6.5.2. The TRANSLATE Command
  444.      6.6.5.3. Terminal Connection
  445.      6.6.5.4. The TRANSMIT Command
  446.      6.6.5.5. Summary of Kermit Unicode Commands
  447.          6.7. Client/Server Character-Set Switching
  448.      (7) SCRIPT PROGRAMMING
  449.          7.0. Bug Fixes
  450.          7.1. The INPUT Command
  451.      7.1.1. INPUT Timeouts
  452.      7.1.2. New INPUT Controls
  453.      7.1.3. INPUT with Pattern Matching
  454.      7.1.4. The INPUT Match Result
  455.      7.2. New or Improved Built-In Variables
  456.      7.3. New or Improved Built-In Functions
  457.          7.4. New IF Conditions
  458.          7.5. Using More than Ten Macro Arguments
  459.          7.6. Clarification of Function Call Syntax
  460.          7.7. Autodownload during INPUT Command Execution
  461.          7.8. Built-in Help for Functions.
  462.      7.9. Variable Assignments
  463.      7.9.1. Assignment Operators
  464.      7.9.2. New Assignment Commands
  465.      7.10. Arrays
  466.      7.10.1. Array Initializers
  467.      7.10.2. Turning a String into an Array of Words
  468.      7.10.3. Arrays of Filenames
  469.      7.10.4. Automatic Arrays
  470.      7.10.5. Sorting Arrays
  471.      7.10.6. Displaying Arrays
  472.          7.10.7. Other Array Operations
  473.          7.10.8. Hints for Using Arrays
  474.          7.10.9. Do-It-Yourself Arrays
  475.          7.10.10. Associative Arrays
  476.          7.11. OUTPUT Command Improvements
  477.          7.12. Function and Variable Diagnostics
  478.          7.13. Return Value of Macros
  479.          7.14. The ASSERT, FAIL, and SUCCEED Commands.
  480.          7.15. Using Alarms
  481.          7.16. Passing Arguments to Command Files
  482.          7.17. Dialogs with Timed Responses
  483.          7.18. Increased Flexibility of SWITCH Case Labels
  484.          7.19. "Kerbang" Scripts
  485.          7.20. IF and XIF Statement Syntax
  486.          7.20.1. The IF/XIF Distinction
  487.          7.20.2. Boolean Expressions (The IF/WHILE Condition)
  488.          7.21. Screen Formatting and Cursor Control
  489.          7.22. Evaluating Arithmetic Expressions
  490.          7.23. Floating-Point Arithmetic
  491.          7.24. Tracing Script Execution
  492.          7.25. Compact Substring Notation
  493.          7.26. New WAIT Command Options
  494.          7.26.1. Waiting for Modem Signals
  495.          7.26.2. Waiting for File Events
  496.          7.27. Relaxed FOR and SWITCH Syntax
  497.      (8) USING OTHER FILE TRANSFER PROTOCOLS
  498.      (9) COMMAND-LINE OPTIONS
  499.          9.0. Extended-Format Command-Line Options
  500.      9.1. Command Line Personalities
  501.      9.2. Built-in Help for Command Line Options
  502.      9.3. New Command-Line Options
  503.     (10) C-KERMIT AND G-KERMIT
  504.  
  505. III. APPENDICES
  506.  
  507. III.1. Character Set Tables
  508. III.1.1. The Hewlett Packard Roman8 Character Set
  509. III.1.2. Greek Character Sets
  510. III.1.2.1. The ISO 8859-7 Latin / Greek Alphabet
  511. III.1.2.2. The ELOT 927 Character Set
  512. III.1.2.3. PC Code Page 869
  513. III.2. Updated Country Codes
  514.  
  515. IV. ERRATA & CORRIGENDA: Corrections to "Using C-Kermit" 2nd Edition.
  516. V. ADDITIONAL COPYRIGHT NOTICES
  517.  
  518. ------------------------------
  519. I. C-KERMIT DOCUMENTATION
  520.  
  521. The user manual for C-Kermit is:
  522.  
  523.   Frank da Cruz and Christine M. Gianone, "Using C-Kermit", Second Edition,
  524.   Digital Press /  Butterworth-Heinemann, Woburn, MA, 1997, 622 pages,
  525.   ISBN 1-55558-164-1.
  526.  
  527. The present document is a supplement to "Using C-Kermit" 2nd Ed, not a
  528. replacement for it.
  529.  
  530.   US single-copy price: $44.95; quantity discounts available.  Available in
  531.   bookstores or directly from Columbia University:
  532.  
  533.     The Kermit Project
  534.     Columbia University
  535.     612 West 115th Street
  536.     New York NY  10025-7799
  537.     USA
  538.     Telephone: +1 (212) 854-3703
  539.     Fax:       +1 (212) 663-8202
  540.  
  541.   Domestic and overseas orders accepted.  Price: US $44.95 (US, Canada, and
  542.   Mexico).  Shipping: $4.00 within the USA; $15.00 to all other countries.
  543.   Orders may be paid by MasterCard or Visa, or prepaid by check in US dollars.
  544.   Add $65 bank fee for checks not drawn on a US bank.  Do not include sales
  545.   tax.  Inquire about quantity discounts.
  546.  
  547.   You can also order by phone from the publisher, Digital Press /
  548.   Butterworth-Heinemann, with MasterCard, Visa, or American Express:
  549.  
  550.     +1 800 366-2665   (Woburn, Massachusetts office for USA & Canada)
  551.     +44 1865 314627   (Oxford, England distribution centre for UK & Europe)
  552.     +61 03 9245 7111  (Melbourne, Vic, office for Australia & NZ)
  553.     +65 356-1968      (Singapore office for Asia)
  554.     +27 (31) 2683111  (Durban office for South Africa)
  555.  
  556.   A German-language edition of the First Edition is also available:
  557.  
  558.     Frank da Cruz and Christine M. Gianone, "C-Kermit - Einfuehrung und
  559.     Referenz", Verlag Heinz Heise, Hannover, Germany (1994).
  560.     ISBN 3-88229-023-4.  Deutsch von Gisbert W. Selke.  Price: DM 88,00.
  561.     Verlag Heinz Heise GmbH & Co. KG, Helstorfer Strasse 7, D-30625 Hannover.
  562.     Tel. +49 (05 11) 53 52-0, Fax. +49 (05 11) 53 52-1 29.
  563.  
  564. The Kermit file transfer protocol is specified in:
  565.  
  566.   Frank da Cruz, "Kermit, A File Transfer Protocol", Digital Press,
  567.   Bedford, MA, 1987, 379 pages, ISBN 0-932376-88-6.
  568.   US single-copy price: $39.95.  Availability as above.
  569.  
  570. News and articles about Kermit software and protocol are published
  571. periodically in the journal, Kermit News.  Subscriptions are free; contact
  572. Columbia University at the address above.
  573.  
  574. Online news about Kermit is published in the comp.protocols.kermit.announce
  575. and comp.protocols.kermit.misc newsgroups.
  576.  
  577. ------------------------------
  578. II. NEW FEATURES
  579.  
  580. Support for the Bell Labs Plan 9 operating system was added to version 6.0
  581. too late to be mentioned in the book (although it does appear on the cover).
  582.  
  583. Specific changes and additions are grouped together by major topic, roughly
  584. corresponding to the chapters of "Using C-Kermit".
  585.  
  586. (0) INCOMPATIBILITIES WITH PREVIOUS RELEASES
  587.  
  588. C-Kermit 7.0 uses FAST Kermit protocol settings by default.  This includes
  589. "unprefixing" of certain control characters.  Because of this, file transfers
  590. that worked with previous releases might not work in the new release (but it
  591. is more likely that they will work, and much faster).  If a transfer fails,
  592. you'll get a context-sensitive hint suggesting possible causes and cures.
  593.  
  594. C-Kermit 7.0 transfers files in BINARY mode by default.  To restore the
  595. previous behavior, put SET FILE TYPE TEXT in your C-Kermit initialization
  596. file.
  597.  
  598. No matter whether FILE TYPE is BINARY or TEXT by default, C-Kermit 7.0 now
  599. switches between text and binary mode automatically on a per-file basis
  600. according to various criteria, including (a) which kind of platform is on the
  601. other end of the connection (if known), (b) the version of Kermit on the other
  602. end, and (c) the file's name (see Sections 4 and 4.3).  To disable this
  603. automatic switching and restore the earlier behavior, put SET TRANSFER MODE
  604. MANUAL in your C-Kermit initialization file.  To disable automatic switching
  605. for a particular transfer, include a /TEXT or /BINARY switch with your SEND or
  606. GET command.
  607.  
  608. The RESEND and REGET commands automatically switch to binary mode; previously
  609. if RESEND or REGET were attempted when FILE TYPE was TEXT, these commands
  610. would fail immediately, with a message telling you they work only when the
  611. FILE TYPE is BINARY.  Now they simply do this for you.  See section 4.23 for
  612. additional (important) information.
  613.  
  614. SET PREFIXING CAUTIOUS and MINIMAL now both prefix linefeed (10 and 138)
  615. in case rlogin or cu are "in the middle", since otherwise <LF>~ might appear
  616. in Kermit packets, and this would rlogin or cu to disconnect, suspend,
  617. escape back, or otherwise wreck the file transfer.  Xon and Xoff are now
  618. always prefixed too, even when Xon/Xoff flow control is not in effect, since
  619. unprefixing them has proven dangerous on TCP/IP connections.
  620.  
  621. In UNIX, VMS, Windows, and OS/2, the DIRECTORY command is built into C-Kermit
  622. itself rather than implemented by running an external command or program.
  623. The built-in command might not behave the way the platform-specific external
  624. one did, but many options are available for customization.  Of course the
  625. underlying platform-specific command can still be accessed with "!", "@",
  626. or "RUN" wherever the installation does not forbid.  In UNIX, the "ls"
  627. command can be accessed directly as "ls" in C-Kermit.  See Section 4.5.1 for
  628. details.
  629.  
  630. SEND ? prints a list of switches rather than a list of filenames.  If you want
  631. to see a list of filenames, use a (system-dependent) construction such as
  632. SEND ./? (for UNIX, Windows, or OS/2), SEND []? (VMS), etc.  See Sections 1.5
  633. and 4.7.1.
  634.  
  635. In UNIX, OS-9, and Kermit 95, the wildcard characters in previous versions
  636. were * and ?.  In C-Kermit 7.0 they are *, ?, [, ], {, and }, with dash used
  637. inside []'s to denote ranges and comma used inside {} to separate list
  638. elements.  If you need to include any of these characters literally in a
  639. filename, precede each one with backslash (\).  See Section 4.9.
  640.  
  641. SET QUIET { ON, OFF } is now on the command stack, just like SET INPUT CASE,
  642. SET COUNT, SET MACRO ERROR, etc, as described on p.458 of "Using C-Kermit",
  643. 2nd Edition.  This allows any macro or command file to SET QUIET ON or OFF
  644. without worrying about saving & restoring the global QUIET value.  For example,
  645. this lets you write a script that tries SET LINE on lots of devices until it
  646. finds one free without spewing out loads of error messages, and also without
  647. disturbing the global QUIET setting, whatever it was.
  648.  
  649. Because of the new "." operator (which introduces assignments), macros whose
  650. names begin with "." can not be invoked "by name".  However, they still can
  651. be invoked with DO.
  652.  
  653. The syntax of the EVALUATE command has changed.  See Section 7.9.2.  To
  654. restore the previous syntax, use SET EVALUATE OLD.
  655.  
  656. The \v(directory) variable now includes the trailing directory separator;
  657. in previous releases it did not.  This is to allow constructions such as:
  658.  
  659.   cd \v(dir)tmp
  660.  
  661. to work across platforms that might have different directory notation, such
  662. as UNIX, Windows, and VMS.
  663.  
  664. Prior to C-Kermit 7.0, the FLOW-CONTROL setting was global and sticky.
  665. In C-Kermit 7.0, there is an array of default flow-control values for each
  666. kind of connection, that are applied automatically at SET LINE/PORT/HOST time.
  667. Thus a SET FLOW command given before SET LINE/PORT/HOST is likely to be undone.
  668. Therefore SET FLOW can be guaranteed to have the desired effect only if given
  669. after the SET LINE/PORT/HOST command.
  670.  
  671. Character-set translation works differently in the TRANSMIT command when (a)
  672. the file character-set is not the same as the local end of the terminal
  673. character-set, or (b) when the terminal character-set is TRANSPARENT.
  674.  
  675.  
  676. (1) PROGRAM AND FILE MANAGEMENT AND COMMANDS
  677.  
  678. 1.0. Bug Fixes
  679.  
  680. The following patches were issued to correct bugs in C-Kermit 6.0.  These are
  681. described in detail in the 6.0 PATCHES file.  All of these fixes have been
  682. incorporated in C-Kermit 6.1 (never released except as K95 1.1.16-17) and 7.0.
  683.  
  684.  0001   All UNIX         C-Kermit mishandles timestamps on files before 1970
  685.  0002    Solaris 2.5++    Compilation error on Solaris 2.5 with Pro C
  686.  0003    All VMS          CKERMIT.INI Fix for VMS
  687.  0004    VMS/VAX/UCX 2.0  C-Kermit 6.0 can't TELNET on VAX/VMS with UCX 2.0
  688.  0005    All              C-Kermit Might Send Packets Outside Window
  689.  0006    All              MOVE from SEND-LIST does not delete original files
  690.  0007    Solaris 2.5++    Higher serial speeds on Solaris 2.5
  691.  0008   All              C-Kermit application file name can't contain spaces
  692.  0009   AT&T 7300 UNIXPC setuid and hardware flow-control problems
  693.  0010   Linux on Alpha   Patch to make ckutio.c compile on Linux/Alpha
  694.  0011   OS-9/68000 2.4   Patch to make ck9con.c compile on OS-9/68000 2.4
  695.  0012   MW Coherent 4.2  Patches for successful build on Coherent 4.2
  696.  0013   SINIX-Y 5.43     "delay" variable conflicts with <sys/clock.h>
  697.  0014   VMS/VAX/CMU-IP   Subject: Patches for VAX/VMS 5.x + CMU-IP
  698.  0015   All              XECHO doesn't flush its output
  699.  0016   VMS              CD and other directory operations might not work
  700.  0017   Linux 1.2.x++    Use standard POSIX interface for high serial speeds
  701.  0018   UNIX             SET WILDCARD-EXPANSION SHELL dumps core
  702.  0019   All              Hayes V.34 modem init string problem
  703.  0020   All              READ command does not fail if file not open
  704.  0021   All              Problems with long function arguments
  705.  0022   All              Certain \function()s can misbehave
  706.  0023   All              X MOD 0 crashes program
  707.  0024   All              Internal bulletproofing for lower() function
  708.  0025   OpenBSD          Real OpenBSD support for C-Kermit 6.0
  709.  0026   All              Incorrect checks for macro/command-file nesting depth
  710.  0027   All              ANSWER doesn't automatically CONNECT
  711.  0028   All              Overzealous EXIT warning
  712.  0029   All              OUTPUT doesn't echo when DUPLEX is HALF
  713.  0030   All              Minor problems with REMOTE DIRECTORY/DELETE/etc
  714.  0031   All              CHECK command broken
  715.  0032   All              Problem with SET TRANSMIT ECHO
  716.  0033   UNIX, VMS, etc   HELP SET SERVER says too much
  717.  0034   All              READ and !READ too picky about line terminators
  718.  0035   All              END from inside SWITCH doesn't work
  719.  0036   All              Problem telnetting to multihomed hosts
  720.  0037   All              Redirection failures in REMOTE xxx > file
  721.  
  722. REDIRECT was missing in many UNIX C-Kermit implementations; in version 7.0,
  723. it should be available in all of them.
  724.  
  725. 1.1. Command Continuation
  726.  
  727. Comments that start with ";" or "#" can no longer be continued.  In:
  728.  
  729.   ; this is a comment -
  730.   echo blah
  731.  
  732. the ECHO command will execute, rather than being taken as a continuation of
  733. the preceding comment line.  This allows easy "commenting out" of commands
  734. from macro definitions.
  735.  
  736. However, the text of the COMMENT command can still be continued onto
  737. subsequent lines:
  738.  
  739.   comment this is a comment -
  740.   echo blah
  741.  
  742. As of version 6.0, backslash is no longer a valid continuation character.
  743. Only hyphen should be used for command continuation.  This is to make it
  744. possible to issue commands like "cd a:\" on DOS-like systems.
  745.  
  746. As of version 7.0:
  747.  
  748.  . You can quote a final dash to prevent it from being a continuation
  749.    character:
  750.  
  751.       echo foo\-
  752.  
  753.    This prints "foo-".  The command is not continued.
  754.  
  755.  . You can enter commands such as:
  756.  
  757.      echo foo - ; this is a comment
  758.  
  759.    interactively and they will be properly treated as continued commands.
  760.    Previously this worked only in command files.
  761.  
  762. 1.2. Editor Interface
  763.  
  764. SET EDITOR <name> [ <options> ]
  765.   Lets you specify a text-editing program.  The <name> can be a fully
  766.   specified pathname like /usr/local/bin/emacs19/emacs, or it can be the
  767.   name of any program in your PATH, e.g. "set editor emacs".  In VMS, it
  768.   must be a DCL command like "edit", "edit/tpu", "emacs", etc.  If an
  769.   environment variable EDITOR is defined when Kermit starts, its value is
  770.   the default editor.  You can also specify options to be included on the
  771.   editor command line.  Returns to Kermit when the editor exits.
  772.  
  773. EDIT [ <filename> ]
  774.   If the EDIT command is given without a filename, then if a previous filename
  775.   had been given to an EDIT command, it is used; if not, the editor is started
  776.   without a file.  If a filename is given, the editor is started on that file,
  777.   and the filename is remembered for subsequent EDIT commands.
  778.  
  779. SHOW EDITOR
  780.   Displays the full pathname of your text editor, if any, along with any
  781.   command line options, and the file most recently edited (and therefore the
  782.   default filename for your next EDIT command).
  783.  
  784. Related variables: \v(editor), \v(editopts), \v(editfile).
  785.  
  786. 1.3. Web Browser and FTP Interface
  787.  
  788. C-Kermit includes an FTP command, which simply runs the FTP program; C-Kermit
  789. does not include any built-in support for Internet File Transfer Protocol,
  790. nor any method for interacting directly with an FTP server.  In version 7.0,
  791. however, C-Kermit lets you specify your FTP client:
  792.  
  793.   SET FTP-CLIENT [ <name> [ <options ] ]
  794.  
  795. The name is the name of the FTP executable.  In UNIX, Windows, or OS/2, it
  796. can be the filename of any executable program in your PATH (e.g. "ftp.exe" in
  797. Windows, "ftp" in UNIX); elsewhere (or if you do not have a PATH definition),
  798. it must be the fully specified pathname of the FTP program.  If the name
  799. contains any spaces, enclose it braces.  Include any options after the
  800. filename; these depend the particular ftp client.
  801.  
  802. The Web browser interface is covered in the following subsections.
  803.  
  804. 1.3.1. Invoking your Browser from C-Kermit
  805.  
  806. BROWSE [ <url> ]
  807.   Starts your preferred Web browser on the URL, if one is given, otherwise
  808.   on the most recently given URL, if any.  Returns to Kermit when the browser
  809.   exits.
  810.  
  811. SET BROWSER [ <name> [ <options> ] ]
  812.   Use this command to specify the name of your Web browser program, for
  813.   example: "set browser lynx".  The <name> must be in your PATH, or else
  814.   it must be a fully specified filename; in VMS it must be a DCL command.
  815.  
  816. SHOW BROWSER
  817.   Displays the current browser, options, and most recent URL.
  818.  
  819. Related variables: \v(browser), \v(browsopts), \v(browsurl).
  820.  
  821. Also see Section 2.15: Contacting Web Servers with the HTTP Command.
  822.  
  823. 1.3.2. Invoking C-Kermit from your Browser
  824.  
  825. The method for doing this depends, of course, on your browser.  Here are
  826. some examples:
  827.  
  828. Netscape on UNIX (X-based):
  829.   In the Options->Applications section, set your Telnet application to:
  830.  
  831.     xterm -e /usr/local/bin/kermit/kermit -J %h %p
  832.  
  833.   (replace "/usr/local/bin/kermit/kermit" by C-Kermit's actual pathname).
  834.   -J is C-Kermit's command-line option to "be like Telnet"; %h and %p are
  835.   Netscape placeholders for hostname and port.
  836.  
  837. Lynx:
  838.   As far as we know, this can be done only at compile time.  Add the
  839.   following line to the Lynx userdefs.h file before building the Lynx binary:
  840.  
  841. #define TELNET_COMMAND "/opt/bin/kermit -J"
  842.  
  843.   And then add lines like the following to the Lynx.cfg file:
  844.  
  845. DOWNLOADER:Kermit binary download:/opt/bin/kermit -i -V -s %s -a %s:TRUE
  846. DOWNLOADER:Kermit text download:/opt/bin/kermit -s %s -a %s:TRUE
  847.  
  848. UPLOADER:Kermit binary upload:/opt/bin/kermit -i -r -a %s:TRUE
  849. UPLOADER:Kermit text upload:/opt/bin/kermit -r -a %s:TRUE
  850. UPLOADER:Kermit text get:/opt/bin/kermit -g %s:TRUE
  851. UPLOADER:Kermit binary get:/opt/bin/kermit -ig %s:TRUE
  852.  
  853. 1.4. Command Editing
  854.  
  855. Ctrl-W ("Word delete") was changed in 7.0 to delete back to the previous
  856. non-alphanumeric, rather than all the way back to the previous space.
  857.  
  858. 1.5. Command Switches
  859.  
  860. As of 7.0, C-Kermit's command parser supports a new type of field, called
  861. a "switch".  This is an optional command modifier.
  862.  
  863. 1.5.1. General Switch Syntax
  864.  
  865. A switch is a keyword beginning with a slash (/).  If it takes a value, then
  866. the value is appended to it (with no intervening spaces), separated by a colon
  867. (:) or equal sign (=).  Depending on the switch, the value may be a number,
  868. a keyword, a filename, a date/time, etc.  Examples:
  869.  
  870.   send oofa.txt                              ; No switches
  871.   send /binary oofa.zip                      ; A switch without a value
  872.   send /protocol:zmodem oofa.zip             ; A switch with a value (:)
  873.   send /protocol=zmodem oofa.zip             ; A switch with a value (=)
  874.   send /text /delete /as-name:x.x oofa.txt   ; Several switches
  875.  
  876. Like other command fields, switches are separated from other fields, and from
  877. each other, by whitespace, as shown in the examples just above.  You can not
  878. put them together like so:
  879.  
  880.   send/text/delete/as-name:x.x oofa.txt
  881.  
  882. (as you might do in VMS or DOS, or as we might once have done in TOPS-10 or
  883. TOPS0-20, or PIP).  This is primarily due to ambiguity between "/" as switch
  884. introducer versus "/" as UNIX directory separator; e.g. in:
  885.  
  886.   send /delete/as-name:foo/text oofa.txt
  887.  
  888. Does "foo/text" mean the filename is "foo" and the transfer is to be in
  889. text mode, or does it mean the filename is "foo/text"?  Therefore we require
  890. whitespace between switches to resolve the ambiguity.  (That's only one of
  891. several possible ambiguities -- it is also conceivable that a file called
  892. "text" exists in the path "/delete/as-name:foo/").
  893.  
  894. In general, if a switch can take a value, but you omit it, then either a
  895. reasonable default value is supplied, or an error message is printed:
  896.  
  897.   send /print:-Plaserwriter oofa.txt         ; Value included = print options
  898.   send /print oofa.txt                       ; Value omitted, OK
  899.   send /mail:kermit@columbia.edu oofa.txt    ; Value included = address
  900.   send /mail oofa.txt                        ; Not OK - address required
  901.   ?Address required
  902.  
  903. Context-sensitive help (?) and completion (Esc or Tab) are available in the
  904. normal manner:
  905.  
  906.   C-Kermit> send /pr? Switch, one of the following:
  907.     /print /protocol
  908.   C-Kermit> send /pro<ESC>tocol:?  File-transfer protocol,
  909.    one of the following:
  910.     kermit   xmodem   ymodem   ymodem-g   zmodem
  911.   C-Kermit> send /protocol:k<TAB>ermit
  912.  
  913. If a switch takes a value and you use completion on it, a colon (:) is printed
  914. at the end of its name to indicate this.  If it does not take a value, a space
  915. is printed.
  916.  
  917. Also, if you type ? in a switch field, switches that take values are shown
  918. with a trailing colon; those that don't take values are shown without one.
  919.  
  920. 1.5.2. Order and Effect of Switches
  921.  
  922. The order of switches should not matter, except that they are evaluated from
  923. left to right, so if you give two switches with opposite effects, the
  924. rightmost one is used:
  925.  
  926.   send /text /binary oofa.zip                ; Sends oofa.zip in binary mode.
  927.  
  928. Like other command fields, switches have no effect whatsoever until the
  929. command is entered (by pressing the Return or Enter key).  Even then, switches
  930. affect only the command with which they are included; they do not have global
  931. effect or side effects.
  932.  
  933. 1.5.3. Distinguishing Switches from Other Fields
  934.  
  935. All switches are optional.  A command that uses switches lets you give any
  936. number of them, including none at all.  Example:
  937.  
  938.   send /binary oofa.zip
  939.   send /bin /delete oofa.zip
  940.   send /bin /as-name:mupeen.zip oofa.zip
  941.   send oofa.zip
  942.  
  943. But how does Kermit know when the first "non-switch" is given?  It has been
  944. told to look for both a switch and for something else, the data type of the
  945. next field (filename, number, etc).  In most cases, this works well.  But
  946. conflicts are not impossible.  Suppose, for example, in UNIX there was a file
  947. named "text" in the top-level directory.  The command to send it would be:
  948.  
  949.   send /text
  950.  
  951. But C-Kermit would think this was the "/text" switch.  To resolve the
  952. conflict, use braces:
  953.  
  954.   send {/text}
  955.  
  956. or other circumlocutions such as "send //text", "send /./text", etc.
  957.  
  958. The opposite problem can occur if you give an illegal switch that happens
  959. to match a directory name.  For example:
  960.  
  961.   send /f oofa.txt
  962.  
  963. There is no "/f" switch (there are several switches that begin with "/f",
  964. so "/f" is ambiguous).  Now suppose there is an "f" directory in the root
  965. directory; then this command would be interpreted as:
  966.  
  967.   Send all the files in the "/f" directory,
  968.   giving each one an as-name of "oofa.txt".
  969.  
  970. This could be a mistake, or it could be exactly what you intended; C-Kermit
  971. has no way of telling the difference.  To avoid situations like this, spell
  972. switches out in full until you are comfortable enough with them to know the
  973. minimum abbreviation for each one.  Hint: use ? and completion while typing
  974. switches to obtain the necessary feedback.
  975.  
  976. 1.5.4. Standard File Selection Switches
  977.  
  978. The following switches are used on different file-oriented commands (such as
  979. SEND, DIRECTORY, DELETE, PURGE) to refine the selection of files that match
  980. the given specification.
  981.  
  982.   /AFTER:<date-time>
  983.     Select only those files having a date-time later than the one given.
  984.     See Section 1.6 for date-time formats.  Synonym: /SINCE.
  985.  
  986.   /NOT-AFTER:<date-time>
  987.     Select only those files having a date-time not later than (i.e. earlier or
  988.     equal to) the one given.  Synonym: /NOT-SINCE.
  989.  
  990.   /BEFORE:<date-time>
  991.     Select only those files having a date-time earlier than the one given.
  992.  
  993.   /NOT-BEFORE:<date-time>
  994.     Select only those files having a date-time not earlier than (i.e. later or
  995.     equalto) the one given.
  996.  
  997.   /DOTFILES
  998.     UNIX and OS-9 only: The filespec is allowed to match files whose names
  999.     start with (dot) period.  Normally these files are not shown.
  1000.  
  1001.   /NODOTFILES
  1002.     (UNIX and OS-9 only) Don't show files whose names start with dot (period).
  1003.     This is the opposite of /DOTFILES, and is the default.  Note that when a
  1004.     directory name starts with a period, the directory and (in recursive
  1005.     operations) all its subdirectories are skipped.
  1006.  
  1007.   /LARGER-THAN:<number>
  1008.     Only select files larger than the given number of bytes.
  1009.  
  1010.   /SMALLER-THAN:<number>
  1011.     Only select files smaller than the given number of bytes.
  1012.  
  1013.   /EXCEPT:pattern
  1014.     Specifies that any files whose names match the pattern, which can be a
  1015.     regular filename, or may contain "*" and/or "?" metacharacters (wildcards),
  1016.     are not to be selected.  Example:
  1017.  
  1018.       send /except:*.log *.*
  1019.  
  1020.     sends all files in the current directory except those with a filetype of
  1021.     ".log".  Another:
  1022.  
  1023.       send /except:*.~*~ *.*
  1024.  
  1025.     sends all files except the ones that look like Kermit or EMACS backup
  1026.     files (such as "oofa.txt.~17~") (of course you can also use the /NOBACKUP
  1027.     switch for this).
  1028.  
  1029.     The pattern matcher is the same one used by IF MATCH <string> <pattern>
  1030.     (Section 7.4), so you can test your patterns using IF MATCH.  If you need
  1031.     to match a literal * or ? (etc), precede it by a backslash (\).  If the
  1032.     pattern contains any spaces, it must be enclosed in braces:
  1033.  
  1034.       send /except:{Foo bar} *.*
  1035.  
  1036.     The pattern can also be a list of up to 8 patterns.  In this case, the
  1037.     entire pattern must be enclosed in braces, and each sub-pattern must also
  1038.     be enclosed in braces; this eliminates the need for designating a
  1039.     separator character, which is likely to also be a legal filename character
  1040.     on some platform or other, and therefore a source of confusion.  You may
  1041.     include spaces between the subpatterns but they are not necessary.  The
  1042.     following two commands are equivalent:
  1043.  
  1044.       send /except:{{ck*.o} {ck*.c}} ck*.?
  1045.       send /except:{{ck*.o}{ck*.c}} ck*.?
  1046.  
  1047.     If a pattern is to include a literal brace character, precede it with \.
  1048.     Also note the apparent conflict of this list format and the string-list
  1049.     format described in section 4.9.1.  In case you want to include a wildcard
  1050.     string-list with braces on its outer ends as an /EXCEPT: argument, do it
  1051.     like this:
  1052.  
  1053.       send /except:{{{ckuusr.c,ckuus2.c,ckuus6.c}}} ckuus*.c
  1054.  
  1055. 1.5.5. Setting Preferences for Different Commands
  1056.  
  1057. Certain oft-used commands offer lots of switches because different people
  1058. have different requirements or preferences.  For example, some people want
  1059. to be able to delete files without having to watch a list of the deleted
  1060. files scroll past, while others want to be prompted for permission to delete
  1061. each file.  Different people prefer different directory-listing styles.  And
  1062. so on.  Such commands can be tailored with the SET OPTIONS command:
  1063.  
  1064. SET OPTIONS <command> [ switch [  switch [ ... ] ] ]
  1065.   Sets each switch as the default for the given command, replacing the
  1066.   "factory default".  Of course you can also override any defaults established
  1067.   by the SET OPTIONS command by including the relevant switches in the
  1068.   affected command any time you issue it.
  1069.  
  1070. SHOW OPTIONS
  1071.   Lists the commands that allows option-setting, and the options currently
  1072.   in effect, if any, for each.  Switches that have synonyms are shown under
  1073.   their primary name; for example. /LOG and /VERBOSE are shown as /LIST.
  1074.  
  1075. Commands for which options may be set include DIRECTORY, DELETE, PURGE,
  1076. and TYPE.  Examples:
  1077.  
  1078.   SET OPTIONS DIRECTORY /PAGE /NOBACKUP /HEADING /SORT:DATE /REVERSE
  1079.   SET OPTIONS DELETE /LIST /NOHEADING /NOPAGE /NOASK /NODOTFILES
  1080.   SET OPTIONS TYPE /PAGE
  1081.  
  1082. Not necessarily all of a command's switches can be set as options.  For
  1083. example, file selection switches, since these would normally be different for
  1084. each command.
  1085.  
  1086. Put the desired SET OPTIONS commands in your C-Kermit customization file for
  1087. each command whose default switches you want to change every time you run
  1088. C-Kermit.
  1089.  
  1090. 1.6. Dates and Times
  1091.  
  1092. Some commands and switches take date-time values, such as:
  1093.  
  1094.   send /after:{8-Feb-2000 10:28:01}
  1095.  
  1096. Various date-time formats are acceptable.  The rules for the date are:
  1097.  
  1098.  . The year must have 4 digits.
  1099.  . If the year comes first, the second field is the month.
  1100.  . The day, month, and year may be separated by spaces, /, -, or underscore.
  1101.  . The month may be numeric (1 = January) or spelled out or abbreviated in
  1102.    English.
  1103.  
  1104. If the date-time string contains any spaces, it must be enclosed in braces.
  1105. Examples of legal dates:
  1106.                            Interpretation:
  1107.   2000-Feb-8                8 February 2000
  1108.   {2000 Feb 8}              8 February 2000
  1109.   2000/Feb/8                8 February 2000
  1110.   2000_Feb_8                8 February 2000
  1111.   2000-2-8                  8 February 2000
  1112.   2000-02-08                8 February 2000
  1113.   8-Feb-2000                8 February 2000
  1114.   08-Feb-2000               8 February 2000
  1115.   12/25/2000                25 December 2000
  1116.   25/12/2000                25 December 2000
  1117.  
  1118. The last two examples show that when the year comes last, and the month is
  1119. given numerically, the order of the day and month doesn't matter as long as
  1120. the day is 13 or greater (mm/dd/yyyy is commonly used in the USA, whereas
  1121. dd/mm/yyyy is the norm in Europe).  However:
  1122.  
  1123.   08/02/2000                Is ambiguous and therefore not accepted.
  1124.  
  1125. If a date is given, the time is optional and defaults to 00:00:00.  If the
  1126. time is given with a date, it must follow the date, separated by space, /, -,
  1127. or underscore, and with hours, minutes, and seconds separated by colon (:).
  1128. Example:
  1129.  
  1130.   2000-Feb-8 10:28:01       Represents 8 February 2000, 10:28:01am
  1131.  
  1132. If a date is not given, the current date is used and a time is required.
  1133.  
  1134. Time format is hh:mm:ss or hh:mm or hh in 24-hour format, or followed by "am"
  1135. or "pm" (or "AM" or "PM") to indicate morning or afternoon.  Examples of times
  1136. that are acceptable:
  1137.                            Interpretation:
  1138.   3:23:56                    3:23:56am
  1139.   3:23:56am                  3:23:56am
  1140.   3:23:56pm                  3:23:56pm = 15:23:56
  1141.  15:23:56                    3:23:56pm = 15:23:56
  1142.   3:23pm                     3:23:00pm = 15:23:00
  1143.   3:23PM                     3:23:00pm = 15:23:00
  1144.   3pm                        3:00:00pm = 15:00:00
  1145.  
  1146. Examples of legal date-times:
  1147.  
  1148.   send /after:{8 Feb 2000 10:28:01}
  1149.   send /after:8_Feb_2000_10:28:01
  1150.   send /after:8-Feb-2000/10:28:01
  1151.   send /after:2000/02/08/10:28:01
  1152.   send /after:2000/02/08_10:28:01
  1153.   send /after:2000/02/08_10:28:01am
  1154.   send /after:2000/02/08_10:28:01pm
  1155.   send /after:2000/02/08_10:28pm
  1156.   send /after:2000/02/08_10pm
  1157.   send /after:10:00:00pm
  1158.   send /after:10:00pm
  1159.   send /after:10pm
  1160.   send /after:22
  1161.  
  1162. Finally, there is a special all-numeric format you can use:
  1163.  
  1164.   yyyymmdd hh:mm:ss
  1165.  
  1166. For example:
  1167.  
  1168.   20000208 10:28:01
  1169.  
  1170. This is Kermit's standard date-time format (based on ISO 8601), and is
  1171. accepted (among other formats) by any command or switch that requires a
  1172. date-time, and is output by any function whose result is a calendar date-time.
  1173.  
  1174. There are no optional parts to this format and it must be exactly 17
  1175. characters long, punctuated as shown (except you can substitute underscore
  1176. for space in contexts where a single "word" is required).  The time is in
  1177. 24-hour format (23:00:00 is 11:00pm).  This is the format returned by
  1178. \fdate(filename), so you can also use constructions like this:
  1179.  
  1180.   send /after:\fdate(oofa.txt)
  1181.  
  1182. which means "all files newer than oofa.txt".
  1183.  
  1184. Besides explicit dates, you can also use the any of the following shortcuts:
  1185.  
  1186. TODAY
  1187.   Stands for the current date at 00:00:00.
  1188.  
  1189. TODAY 12:34:56
  1190.   Stands for the current date at the given time.
  1191.  
  1192. YESTERDAY
  1193.   Stands for yesterday's date at 00:00:00.  A time may also be given.
  1194.  
  1195. TOMORROW
  1196.   Stands for tomorrow's date at 00:00:00.  A time may also be given.
  1197.  
  1198. + <number> { DAYS, WEEKS, MONTHS, YEARS } [ time ]
  1199.   Is replaced by the future date indicated, relative to the current date.
  1200.   If the time is omitted, 00:00:00 is used.  Examples: +3days, +2weeks,
  1201.   +1year, +37months.
  1202.  
  1203. - <number> { DAYS, WEEKS, MONTHS, YEARS } [ time ]
  1204.   Is replaced by the past date indicated, relative to the current date.
  1205.   If the time is omitted, 00:00:00 is used.
  1206.  
  1207. The time can be separated from the date shortcut by any of the same separators
  1208. that are allowed for explicit date-times: space, hyphen, slash, period, or
  1209. underscore.  In switches and other space-delimited fields, use non-spaces
  1210. to separate date/time fields, or enclose the date-time in braces, e.g.:
  1211.  
  1212.   purge /before:-4days_12:00:00
  1213.  
  1214. or:
  1215.  
  1216.   purge /before:{- 4 days 12:00:00}
  1217.  
  1218. Of course you can also use variables:
  1219.  
  1220.   define \%n 43
  1221.   purge /before:-\%ndays_12:00:00
  1222.  
  1223. Shortcut names can be abbreviated to any length that still distinguishes them
  1224. from any other name that can appear in the same context, e.g. "TOD" for today,
  1225. "Y" for yesterday.  Also, the special abbreviation "wks" is accepted for
  1226. WEEKS, and "yrs" for "YEARS".
  1227.  
  1228. (To see how to specify dates relative to a specific date, rather than the
  1229. current one, see the \fmjd() function description below.)
  1230.  
  1231. You can check date formats with the DATE command.  DATE by itself prints the
  1232. current date and time in standard format: yyyymmdd hh:mm:ss.  DATE followed by
  1233. a date and/or time (including shortcuts) converts it to standard format if it
  1234. can understand it, otherwise it prints an error message.
  1235.  
  1236. The following variables and functions deal with dates and times; any function
  1237. argument designated as "date-time" can be in any of the formats described
  1238. above.
  1239.  
  1240. \v(day)
  1241.   The first three letters of the English word for the current day of the
  1242.   week, e.g. "Wed".
  1243.  
  1244. \fday(date-time)
  1245.   The first three letters of the English word for day of the week of
  1246.   the given date.  If a time is included, it is ignored.  Example:
  1247.   \fday(8 Feb 1988) = "Mon".
  1248.  
  1249. \v(nday)
  1250.   The numeric day of the week: 0 = Sunday, 1 = Monday, ..., 6 = Saturday.
  1251.  
  1252. \fnday(date-time)
  1253.   The numeric day of the week for the given date.  If a time is included, it
  1254.   is ignored.  Example: \fnday(8 Feb 1988) = "1".
  1255.  
  1256. \v(date)
  1257.   The current date as dd mmm yyyy, e.g. "08 Feb 2000" (as in this example,
  1258.   a leading zero is supplied for day-of-month less than 10).
  1259.  
  1260. \v(ndate)
  1261.   The current date in numeric format: yyyymmdd, e.g. "20000208".
  1262.  
  1263. \v(time)
  1264.   The current time as hh:mm:ss, e.g. "15:27:14".
  1265.  
  1266. \ftime(time)
  1267.   The given free-format date and/or time (e.g. "3pm") returns the time
  1268.   (without the date) converted to hh:mm:ss 24-hour format, e.g. "15:00:00"
  1269.   (the date, if given, is ignored).
  1270.  
  1271. \v(ntime)
  1272.   The current time as seconds since midnight, e.g. "55634".
  1273.  
  1274. \v(tftime)
  1275.   The elapsed time of the most recent file-transfer operation in seconds.
  1276.  
  1277. \v(intime)
  1278.   The elapsed time for the most recent INPUT command to complete, in
  1279.   milliseconds.
  1280.  
  1281. \fntime(time)
  1282.   The given free-format date and/or time is converted to seconds since
  1283.   midnight (the date, if given, is ignored).  This function replaces
  1284.   \ftod2secs(), which is now a synonym for \fntime().  Unlike \ftod2secs(),
  1285.   \fntime() allows a date to be included, and it allows the time to be in
  1286.   free format (like 3pm), and it allows the amount of time to be more than
  1287.   24 hours.  E.g. \fntime(48:00:00) = 172800.  Example of use:
  1288.     set alarm \fntime(48:00:00) ; set alarm 48 hours from now.
  1289.  
  1290. \fn2time(seconds)
  1291.   The given number of seconds is converted to hh:mm:ss format.
  1292.  
  1293. \fdate(filename)
  1294.   Returns the modification date-time of the given file in standard format:
  1295.   yyyymmdd hh:mm:ss.
  1296.  
  1297. \fcvtdate(date-time)
  1298.   Converts a free-format date and/or time to Kermit standard format: yyyymmdd
  1299.   hh:mm:ss.  If no argument is given, returns the current date-time in
  1300.   standard format.  If a date is given but no time, the converted date is
  1301.   returned without a time.  If a time is given with no date, the current
  1302.   date is supplied.  Examples:
  1303.     \fcvtdate(4 Jul 2000 2:21:17pm) = 20000704 14:21:17
  1304.     \fcvtdate() = 20000704 14:21:17 (on 4 Jul 2000 at 2:21:17pm).
  1305.     \fcvtd(4 Jul 2000) = 20000704
  1306.     \fcvtd(6pm) = 20000704 18:00:00 (on 4 Jul 2000 at 6:00pm).
  1307.  
  1308. \fdayofyear(date-time)
  1309. \fdoy(date-time)
  1310.   Converts a free-format date and/or time to yyyyddd, where ddd is the 3-digit
  1311.   day of the year, where 1 January is Day 1.  If a time is included with the
  1312.   date, it is returned in standard format.  If a date is included but no time,
  1313.   the date is returned without a time.  If a time is given with no date, the
  1314.   time is converted and the current date is supplied.  If no argument is
  1315.   given, the current date-time is returned.  Synonym: \fdoy().  Examples:
  1316.     \fddayofyear(4 Jul 2000 2:21:17pm) = 2000185 14:21:17
  1317.     \fdoy() = 2000185 14:21:17 (on 4 Jul 2000 at 2:21:17pm).
  1318.     \fdoy(4 Jul 2000) = 2000185
  1319.     \fdoy(6pm) = 2000185 18:00:00 (on 4 Jul 2000 at 6:00pm).
  1320.  
  1321. Note: The yyyyddd day-of-year format is often erroneously referred to as a
  1322. Julian date.  However, a true Julian date is a simple counting number, the
  1323. number of days since a certain fixed day in the past.  See \fmjd() below.
  1324.  
  1325. \fdoy2date(date-time)
  1326.   Converts a date or date-time in day-of-year format to a standard format
  1327.   date.  A yyyyddd-format date must be supplied; time is optional.  The
  1328.   given date is converted to yyyymmdd format.  If a time is given, it is
  1329.   converted to 24-hour format.  Examples:
  1330.     \fdoy2date(2000185) = 20000704
  1331.     \fdoy2(2000185 3pm) = 20000704 15:00:00
  1332.  
  1333. \fmjd(date-time)
  1334.   Converts free-format date and/or time to a Modified Julian Date (MJD),
  1335.   the number of days since 17 Nov 1858 00:00:00.  If a time is given, it is
  1336.   ignored.  Examples:
  1337.      \fmjd(4 Jul 2000) = 50998
  1338.      \fmjd(17 Nov 1858) = 0
  1339.      \fmjd(16 Nov 1858) = -1
  1340.  
  1341. \fmjd2date(mjd)
  1342.   Converts an MJD (integer) to standard date format, yyyymmdd:
  1343.      \fmjd2(50998) = 4 Jul 1998
  1344.      \fmjd2(0) = 17 Nov 1858
  1345.      \fmjd2(-1) = 16 Nov 1858
  1346.      \fmjd2(-365) = 17 Nov 1857
  1347.  
  1348. MJDs are normal integers and, unlike DOYs, may be added, subtracted, etc, with
  1349. each other or with other integers, to obtain meaningful results.  For example,
  1350. to find out the date 212 days ago:
  1351.  
  1352.   echo \fmjd2date(\fmjd()-212)
  1353.  
  1354. Constructions such as this can be used in any command where a date-time
  1355. is required, e.g.:
  1356.  
  1357.   send /after:\fmjd2date(\fmjd()-212)
  1358.  
  1359. to send all files that are not older than 212 days (this is equivalent to
  1360. "send /after:-212days").
  1361.  
  1362. MJDs also have other regularities not exhibited by other date formats.  For
  1363. example, \fmodulus(\fmjd(any-date),7) gives the day of the week for any date
  1364. (where 4=Sun, 5=Mon, ..., 3=Sat).  (However, it is easier to use \fnday() for
  1365. this purpose, and it gives the more conventional result of 0=Sun, 1=Mon, ...,
  1366. 6=Sat).
  1367.  
  1368. Note that if MJDs are to be compared, they must be compared numerically
  1369. (IF <, =, >) and not lexically (IF LLT, EQUAL, LGT), whereas DOYs must be
  1370. compared lexically if they include a time (which contains ":" characters);
  1371. however, if DOYs do not include a time, they may also be compared numerically.
  1372.  
  1373. In any case, lexical comparison of DOYs always produces the appropriate
  1374. result, as does numeric comparison of MJDs.
  1375.  
  1376. The same comments apply to sorting.  Also note that DOYs are fixed length, but
  1377. MJDs can vary in length.  However, all MJDs between 3 April 1886 and 30 Aug
  1378. 2132 are 5 decimal digits long.  (MJDs become 6 digits long on 31 Aug 2132,
  1379. and 7 digits long on 13 Oct 4596).
  1380.  
  1381. 1.7. Partial Completion of Keywords
  1382.  
  1383. Partial completion of keywords was added in C-Kermit 7.0.  In prior versions,
  1384. if completion was attempted (by pressing the Esc or Tab key) on a string that
  1385. matched different keywords, you'd just get a beep.  Now Kermit completes up to
  1386. the first character where the possibly matching keywords differ and then
  1387. beeps.  For example:
  1388.  
  1389.   send /n<Tab>
  1390.  
  1391. which matches /NOT-BEFORE and /NOT-AFTER, now completes up to the dash:
  1392.  
  1393.   send /n<Tab>ot-<Beep>
  1394.  
  1395. Partial completion works for filenames too (as it has for some years).
  1396.  
  1397. 1.8. Command Recall
  1398.  
  1399. C-Kermit has had a command history buffer for some time, which could be
  1400. scrolled interactively using control characters or (in Kermit 95 only) arrow
  1401. keys.  Version 7.0 adds a REDO command that allows the most recent command
  1402. matching a given pattern to be re-executed:
  1403.  
  1404. { REDO, RR, ^ } [ <pattern> ]
  1405.   Search the command history list for the most recent command that matches
  1406.   the given pattern, and if one is found, execute it again.
  1407.  
  1408. The pattern can be a simple string (like "send"), in which case the last SEND
  1409. command is re-executed.  Or it can contain wildcard characters "*" and/or "?",
  1410. which match any string and any single character, respectively (note that "?"
  1411. must be preceded by backslash to override its normal function of giving help),
  1412. and in most C-Kermit versions may also include [] character lists and {}
  1413. string lists (see Section 4.9).
  1414.  
  1415. The match works by appending "*" to the end of the given pattern (if you
  1416. didn't put one there yourself).  Thus "redo *oofa" becomes "redo *oofa*" and
  1417. therefore matches the most recent command that contains "oofa" anywhere within
  1418. the command.  If you want to inhibit the application of the trailing "*",
  1419. e.g. to force matching a string at the end of a command, enclose the pattern
  1420. in braces:
  1421.  
  1422.   redo {*oofa}
  1423.  
  1424. matches the most recent command that ends with "oofa".
  1425.  
  1426. REDO commands themselves are not entered into the command history list.  If no
  1427. pattern is given, the previous (non-REDO) command is re-executed.  The REDOne
  1428. command is reinserted at the end of the command history buffer, so the command
  1429. scrollback character (Ctrl-P, Ctrl-B, or Uparrow) can retrieve it.
  1430.  
  1431. Examples:
  1432.  
  1433.   C-Kermit>echo foo
  1434.   foo
  1435.   C-Kermit>show alarm
  1436.   (no alarm set)
  1437.   C-Kermit>echo blah
  1438.   blah
  1439.   C-Kermit>redo          ; Most recent command
  1440.   blah
  1441.   C-Kermit>redo s        ; Most recent command starting with "s"
  1442.   (no alarm set)
  1443.   C-Kermit>redo echo f   ; Most recent command starting with "echo f"
  1444.   foo
  1445.   C-Kermit>redo *foo     ; Most recent command that has "foo" in it
  1446.   foo
  1447.   C-Kermit><Ctrl-P>      ; Scroll back
  1448.   C-Kermit>echo foo      ; The REDOne command is there
  1449.   C-Kermit>redo {*foo}   ; Most recent command that ends with "foo"
  1450.   foo
  1451.   C-Kermit>
  1452.  
  1453. Since REDO, REDIAL, and REDIRECT all start the same way, and RED is the
  1454. designated non-unique abbreviation for REDIAL, REDO must be spelled out in
  1455. full.  For convenience, RR is included as an invisible easy-to-type synonym
  1456. for REDO.  You can also use the "^" character for this:
  1457.  
  1458.   C-Kermit>^             ; Most recent command
  1459.   C-Kermit>^ s           ; Most recent command starting with "s"
  1460.   C-Kermit>^s            ; Ditto (space not required after "^").
  1461.   C-Kermit>^*foo         ; Most recent command that has "foo" in it.
  1462.   C-Kermit>^{*foo}       ; Most recent command ends with "foo".
  1463.  
  1464. Unlike the manual command-history-scrolling keys, the REDO command can be
  1465. used in a script, but it's not recommended (since the command to be REDOne
  1466. might not be found, so if the REDO command fails, you can't tell whether it
  1467. was because REDO failed to find the requested command, or because the command
  1468. was found but it failed).
  1469.  
  1470. 1.9. EXIT Messages
  1471.  
  1472. The EXIT and QUIT commands now accept an optional message to be printed.
  1473. This makes the syntax of EXIT and QUIT just like END and STOP:
  1474.  
  1475.   { EXIT, QUIT, END, STOP } [ <status-code> [ <message> ] ]
  1476.  
  1477. where <status-code> is a number (0 indicating success, nonzero indicating
  1478. failure).  This is handy in scripts that are never supposed to enter
  1479. interactive mode:
  1480.  
  1481.   dial 7654321
  1482.   if fail exit 1 Can't make connection - try again later.
  1483.  
  1484. Previously this could only be done in two steps:
  1485.  
  1486.   dial 7654321
  1487.   xif fail { echo Can't make connection - try again later, exit 1 }
  1488.  
  1489. A status code must be included in order to specify a message.  In the case
  1490. of EXIT and QUIT, the default status code is contained in the variable
  1491. \v(exitstatus), and is set automatically by various events (file transfer
  1492. failures, etc; it can also be set explicitly with the SET EXIT STATUS
  1493. command).  If you want to give an EXIT or QUIT command with a message, but
  1494. without changing the exit status from what it normally would have been, use
  1495. the \v(exitstatus) variable, e.g.:
  1496.  
  1497.    exit \v(existatus) Goodbye from \v(cmdfile).
  1498.  
  1499. The EXIT status is returned to the system shell or whatever other process
  1500. invoked C-Kermit, e.g. in UNIX:
  1501.  
  1502.   C-Kermit> exit 97 bye bye
  1503.   bye bye
  1504.   $ echo $?
  1505.   97
  1506.   $
  1507.  
  1508. 1.10. Managing Keyboard Interruptions
  1509.  
  1510. When C-Kermit is in command or file-transfer mode (as opposed to CONNECT
  1511. mode), it can be interrupted with Ctrl-C.  Version 7.0 adds the ability to
  1512. disarm the Ctrl-C interrupt:
  1513.  
  1514. SET COMMAND INTERRUPT { ON, OFF }
  1515.   COMMAND INTERRUPT is ON by default, meaning the Ctrl-C can be used to
  1516.   interrupt a command or a file transfer in progress.  Use OFF to disable
  1517.   these interruptions, and use it with great caution for obvious reasons.
  1518.  
  1519. SET TRANSFER INTERRUPT { ON, OFF }
  1520.   This can be used to disable keyboard interruption of file transfer when
  1521.   C-Kermit is in local mode, or to re-enable it after it has been disabled.
  1522.   This applies to the X, Z, E, and similar keys as well as to the system
  1523.   interrupt character, usually Ctrl-C.  This is distinct from SET TRANSFER
  1524.   CANCELLATION, which tells whether packet mode can be exited by sending a
  1525.   special sequence of characters.
  1526.  
  1527. Several other commands can be interrupted by pressing any key while they are
  1528. active.  Version 7.0 adds the ability to disable this form of interruption
  1529. also:
  1530.  
  1531. SET INPUT CANCELLATION { ON, OFF }
  1532.   Whether an INPUT command in progress can be interrupted by pressing a key.
  1533.   Normally ON.  Setting INPUT CANCELLATION OFF makes INPUT commands
  1534.   uninterruptible except by Ctrl-C (unless COMMAND INTERRUPTION is also OFF).
  1535.  
  1536. SET SLEEP CANCELLATION { ON, OFF }
  1537.   Whether a SLEEP, PAUSE, or WAIT command in progress can be interrupted by
  1538.   pressing a key.  Normally ON.  Setting SLEEP CANCELLATION OFF makes these
  1539.   commands uninterruptible except by Ctrl-C (unless COMMAND INTERRUPTION is
  1540.   also OFF).  Synonyms: SET PAUSE CANCELLATION, SET WAIT CANCELLATION.
  1541.  
  1542. So to make certain a script is not interruptible by the user, include these
  1543. commands:
  1544.  
  1545.   SET TRANSFER INTERRUPT OFF
  1546.   SET SLEEP CANCELLATION OFF
  1547.   SET INPUT CANCELLATION OFF
  1548.   SET COMMAND INTERRUPTION OFF
  1549.  
  1550. Make sure to turn them back on afterwards.
  1551.  
  1552. When a PAUSE, SLEEP, WAIT, or INPUT command is interrupted from the keyboard,
  1553. the new variable \v(kbchar) contains a copy of the (first) character that was
  1554. typed and caused the interruption, provided it was not the command interrupt
  1555. character (usually Ctrl-C).  If these commands complete successfully or time
  1556. out without a keyboard interruption, the \v(kbchar) variable is empty.
  1557.  
  1558. The \v(kbchar) variable (like any other variable) can be tested with:
  1559.  
  1560.   if defined \v(kbchar) <command>
  1561.  
  1562. The <command> is executed if the variable is not empty.
  1563.  
  1564. The \v(kbchar) variable can be reset with WAIT 0 (PAUSE 0, SLEEP 0, etc).
  1565.  
  1566. 1.11. Taming The Wild Backslash -- Part Deux
  1567.  
  1568. "Using C-Kermit", 2nd Edition, contains a brief section, "Taming the Wild
  1569. Backslash", on page 48, which subsequent experience has shown to be inadequate
  1570. for Kermit users intent on writing scripts that deal with Windows, DOS, and
  1571. OS/2 filenames, in which backslash (\) is used as the directory separator.
  1572. This section fills in the blanks.
  1573.  
  1574. 1.11.1. Background
  1575.  
  1576. The Kermit command language shares a certain unavoidable but annoying
  1577. characteristic with most other command languages that are capable of string
  1578. replacement, namely the necessity to "quote" certain characters when you want
  1579. them to be taken literally.  This is a consequence of the facts that:
  1580.  
  1581.  a. One or more characters must be set aside to denote replacement, rather
  1582.     than acting as literal text.
  1583.  
  1584.  b. We have only 96 printable characters to work with in ASCII, which is
  1585.     still the only universally portable character set.
  1586.  
  1587.  c. There is no single printable character that is unused everywhere.
  1588.  
  1589.  d. Variables are not restricted to certain contexts, as they are
  1590.     in formal programming languages like C and Fortran, but can appear
  1591.     anywhere at all within a command, and therefore require special syntax.
  1592.  
  1593. Thus there can be conflicts.  To illustrate, the standard UNIX shell uses
  1594. dollar sign ($) to introduce variables.  So the shell command:
  1595.  
  1596.   echo $TERM
  1597.  
  1598. displays the value of the TERM variable, e.g. vt320.  But suppose you want to
  1599. display a real dollar sign:
  1600.  
  1601.   echo The price is $10.20
  1602.  
  1603. This causes the shell to evaluate the variable "$1", which might or might not
  1604. exist, and substitute its value, e.g.:
  1605.  
  1606.   The price is 0.20
  1607.  
  1608. (in this case the $1 variable had no value.)  This is probably not what you
  1609. wanted.  To force the dollar sign to be taken literally, you must apply a
  1610. "quoting rule", such as "precede a character by backslash (\) to force the
  1611. shell to take the character literally":
  1612.  
  1613.   echo The price is \$10.20
  1614.   The price is $10.20
  1615.  
  1616. But now suppose you want the backslash AND the dollar sign to be taken
  1617. literally:
  1618.  
  1619.   echo The price is \\$10.20
  1620.  
  1621. This doesn't work, since the first backslash quotes the second one, thereby
  1622. leaving the dollar sign unquoted again:
  1623.  
  1624.   The price is \0.20
  1625.  
  1626. Quoting the dollar sign requires addition of a third backslash:
  1627.  
  1628.   echo The price is \\\$10.20
  1629.   The price is \$10.20
  1630.  
  1631. The first backslash quotes the second one, and the third backslash quotes
  1632. the dollar sign.
  1633.  
  1634. Every command language -- all UNIX shells, VMS DCL, DOS Batch, AOS/VS CLI, etc
  1635. etc -- has similar rules.  UNIX shell rules are probably the most complicated,
  1636. since many printable characters -- not just one -- are special there: dollar
  1637. sign, single quote, double quote, backslash, asterisk, accent grave, number
  1638. sign, ampersand, question mark, parentheses, brackets, braces, etc --
  1639. practically every non-alphanumeric character needs some form of quoting if it
  1640. is to be taken literally.  And to add to the confusion, the UNIX shell offers
  1641. many forms of quoting, and many alternative UNIX shells are available, each
  1642. using slightly different syntax.
  1643.  
  1644. 1.11.2. Kermit's Quoting Rules
  1645.  
  1646. Kermit's basic quoting rules are simple by comparison (there are, of course,
  1647. additional syntax requirements for macro definitions, command blocks, function
  1648. calls, etc, but they are not relevant here).
  1649.  
  1650. The following characters are special in Kermit commands:
  1651.  
  1652. Backslash (\)
  1653.   Introduces a variable, or the numeric representation of a special character,
  1654.   or a function, or other item for substitution.  If the backslash is followed
  1655.   by a digit or by any of the following characters:
  1656.  
  1657.     x, o, d, m, f, v, $, %, &, {
  1658.  
  1659.   this indicates a special substitution item; otherwise the following
  1660.   character is to be taken literally (exceptions: \ at end of line is taken
  1661.   literally; \n, \b, and \n are special items in the OUTPUT command only).
  1662.  
  1663. Semicolon (;)
  1664.   (Only when at the beginning of a line or preceded by at least one space
  1665.   or tab)  Introduces a comment.
  1666.  
  1667. Number sign (#)
  1668.   (Only when at the beginning of a line or preceded by at least one space
  1669.   or tab)  Just like semicolon; introduces a comment.
  1670.  
  1671. Question mark (?)
  1672.   (Only at the command prompt - not in command files or macros)  Requests
  1673.   context-sensitive help.
  1674.  
  1675. To force Kermit to take any of these characters literally, simply precede it
  1676. by a backslash (\).
  1677.  
  1678. Sounds easy!  And it is, except when backslash also has a special meaning to
  1679. the underlying operating system, as it does in DOS, Windows, and OS/2, where
  1680. it serves as the directory separator in filenames such as:
  1681.  
  1682.   D:\K95\KEYMAPS\READ.ME
  1683.  
  1684. Using our rule, we would need to refer to this file in Kermit commands as
  1685. follows:
  1686.  
  1687.   D:\\K95\\KEYMAPS\\READ.ME
  1688.  
  1689. But this would not be obvious to new users of Kermit software on DOS, Windows,
  1690. or OS/2, and it would be annoying to seasoned ones.  Thus MS-DOS Kermit and
  1691. Kermit 95 go to rather extreme lengths to allow the more natural notation, as
  1692. in:
  1693.  
  1694.   send d:\k95\keymaps\read.me
  1695.  
  1696. The reason this is tricky is that we also need to allow for variables and
  1697. other expressions introduced by backslash in the same command.  For example,
  1698. suppose \%a is a variable whose value is "oofa" (without the quotes).  What
  1699. does the following command do?
  1700.  
  1701.   send d:\%a
  1702.  
  1703. Does it send the file named "oofa" in the current directory of the D: disk, or
  1704. does it send a file named "%a" in the root directory of the D: disk?  This is
  1705. the kind of trouble we get into when we attempt to bend the rules in the
  1706. interest of user friendliness.  (The answer is: if the variable \%a has
  1707. definition that is the name of an existing file, that file is sent; if a file
  1708. d:\%a exists, it is sent; otherwise if both conditions are true, the variable
  1709. takes precedence, and the literal filename can be forced by quoting: \\%a.)
  1710.  
  1711. In Kermit 95 (but not MS-DOS Kermit), we also bend the rules another way by
  1712. allowing you to use forward slash (/) rather than backslash (\) as the
  1713. directory separator:
  1714.  
  1715.   send d:/k95/keymaps/read.me
  1716.  
  1717. This looks more natural to UNIX users, and in fact is perfectly acceptable to
  1718. the Windows 95/98/NT and OS/2 operating systems on the API level.  BUT (there
  1719. is always a "but") the Microsoft shell, COMMAND.COM, for Windows 95/98 and NT
  1720. does not allow this notation, and therefore it can not be used in any Kermit
  1721. command -- such as RUN -- that invokes the Windows command shell AND your
  1722. command shell is COMMAND.COM or any other shell that does not allow forward
  1723. slash as directory separator (some alternative shells do allow this).
  1724.  
  1725.   NOTE: There exists a wide variety of alternative shells from third
  1726.   parties that do not have this restriction.  If you are using a shell
  1727.   that accepts forward slash as a directory separator, you can stop
  1728.   reading right now -- UNLESS (there is always an "unless") you want your
  1729.   scripts to be portable to systems that have other shells.  Also note
  1730.   that some Windows shells might actually REQUIRE forward slashes
  1731.   (instead of backslashes) as directory separators; we do not treat this
  1732.   situation below, but the treatment is obvious -- use slash rather
  1733.   backslash as the directory separator.
  1734.  
  1735. 1.11.3. Passing DOS Filenames from Kermit to Shell Commands
  1736.  
  1737. The following Kermit commands invoke the system command shell:
  1738.  
  1739.   RUN (and its synonyms ! and @)
  1740.   REDIRECT
  1741.   PIPE
  1742.  
  1743. Each of these commands takes a shell command as an operand.  These shell
  1744. commands are not, and can not be, parsed by Kermit since Kermit does not know
  1745. the syntax of shell commands, and so can't tell the difference between a
  1746. keyword, a filename, a variable, a switch, or other item.  Therefore the rules
  1747. can not be bent since Kermit doesn't know where or how to bend them.  To
  1748. illustrate (using the regular Windows shell):
  1749.  
  1750.   run c:\\windows\\command\\chkdsk.exe
  1751.  
  1752. works OK, but:
  1753.  
  1754.   run c:/windows/command/chkdsk.exe
  1755.  
  1756. is not accepted by COMMAND.COM.  But:
  1757.  
  1758.   run c:\windows\command\chkdsk.exe
  1759.  
  1760. results in Kermit applying its quoting rules before sending the text to the
  1761. shell.  Since "w" and "c" are not in the list of backslash-item codes, the
  1762. backslash means "take the following character literally".  Thus, by the
  1763. time this filename gets to the Windows shell, it has become:
  1764.  
  1765.   c:windowscommandchkdsk.exe
  1766.  
  1767. which is probably not what you wanted.  (If "w" and "c" were in the list,
  1768. the results could be even stranger.)  Even more confusing is the case where
  1769. a directory or filename starts with one or more digits:
  1770.  
  1771.   run c:\123\lotus.exe
  1772.  
  1773. in which "\123" is the Kermit notation for ASCII character 123, which happens
  1774. to be left brace ({), resulting in "c:{lotus.exe".
  1775.  
  1776. So when passing filenames to a Windows shell, always use double backslashes as
  1777. directory separators, to ensure that the shell gets single backslashes:
  1778.  
  1779.   run c:\\windows\\command\\chkdsk.exe
  1780.   run c:\\123\\lotus.exe
  1781.  
  1782. Similar problems might occur with the built-in EDIT, BROWSE, and FTP commands.
  1783. These commands result in Kermit building a shell command internally to invoke
  1784. the associated helper program; the form of this command might conflict with
  1785. the form demanded by certain alternative shells.
  1786.  
  1787. 1.11.4. Using Variables to Hold DOS Filenames
  1788.  
  1789. Now to the next level.  Suppose you want to write a script in which filenames
  1790. are parameters, and therefore are stored in variables.  Example:
  1791.  
  1792.   define \%f c:\windows\command\chkdsk.exe
  1793.   ...
  1794.   run \%f
  1795.  
  1796. Obviously this won't work for the reasons just noted; the RUN command requires
  1797. directory separators be coded as double backslashes:
  1798.  
  1799.   define \%f c:\\windows\\command\\chkdsk.exe
  1800.   ...
  1801.   run \%f
  1802.  
  1803. This will work; no surprises here.  However, if you had used ASSIGN rather
  1804. than DEFINE, you might have been surprised after all; review pages 348-349 of
  1805. "Using C-Kermit" (2nd Ed) for the difference between DEFINE and ASSIGN.
  1806.  
  1807. We have said that any Kermit 95 or MS-DOS Kermit command that parses filenames
  1808. itself -- SEND, for example -- does not require double backslashes since it
  1809. knows it is parsing a filename.  So since the following works:
  1810.  
  1811.   send c:\windows\command\chkdsk.exe
  1812.  
  1813. Should the following also work?
  1814.  
  1815.   define \%f c:\windows\command\chkdsk.exe
  1816.   ...
  1817.   send \%f
  1818.  
  1819. Answer: No.  Why?  Because \%f is evaluated "recursively", to allow for the
  1820. possibility that its definition contains further variable references.  This is
  1821. true of all "backslash-percent-letter" (or -digit) variables, and also for
  1822. array references.  So \%f becomes c:\windows\command\chkdsk.exe, which
  1823. becomes c:windowscommandchkdsk.exe.
  1824.  
  1825. The trick here is to use the "other" kind of variable, that is evaluated
  1826. only "one level deep" rather than recursively:
  1827.  
  1828.   define filename c:\windows\command\chkdsk.exe
  1829.   ...
  1830.   send \m(filename)
  1831.  
  1832. Similarly if you want to prompt the user for a filename:
  1833.  
  1834.   ask filename { Please type a filename: }
  1835.    Please type a filename: c:\windows\command\chkdsk.exe
  1836.   send \m(filename)
  1837.  
  1838. 1.11.5. Passing DOS Filenames as Parameters to Macros
  1839.  
  1840. Suppose you want to pass a DOS filename containing backslashes as a parameter
  1841. to a Kermit macro.  This raises two issues:
  1842.  
  1843.  1. Parameters to macros are "just text" and so are fully evaluated before
  1844.     they are passed to the macro.
  1845.  
  1846.  2. Once inside the macro, the formal parameters \%1, \%2, ... \%9 are the
  1847.     type of variable that is evaluated recursively.
  1848.  
  1849. Thus a DOS filename is ruined once in the act of parsing the macro invocation,
  1850. and again when referring to it from within the macro.  To illustrate, suppose
  1851. "test" is a macro.  Then in the invocation:
  1852.  
  1853.   test c:\mydir\blah.txt
  1854.  
  1855. "c:mydirblah.txt" is assigned to \%1.  However, if we double the backslashes:
  1856.  
  1857.   test c:\\mydir\\blah.txt
  1858.  
  1859. "c:\mydir\blah.txt" is assigned to \%1.  But then when you refer to \%1 in
  1860. the macro, it is evaluated recursively, resulting in "c:mydirblah.txt".
  1861. To illustrate:
  1862.  
  1863.   define test echo \%1
  1864.   test c:\mydir\blah.txt
  1865.   c:mydirblah.txt
  1866.   test c:\\mydir\\blah.txt
  1867.   c:mydirblah.txt
  1868.   test c:\\\\mydir\\\\blah.txt
  1869.   c:\mydir\blah.txt
  1870.  
  1871. Let's address each part of the problem separately.  First, inside the macro.
  1872. You can use the \fcontents() function to force a backslash-percent variable
  1873. (such as a macro argument) to be evaluated one level deep instead of
  1874. recursively, for example:
  1875.  
  1876.   define test echo { The filename is "\fcontents(\%1)"}
  1877.  
  1878.   test c:\mydir\blah.txt               ; We don't expect this to work
  1879.    The filename is "c:mydirblah.txt"   ; and it doesn't.
  1880.   test c:\\mydir\\blah.txt             ; But this does...
  1881.    The filename is "c:\mydir\blah.txt"
  1882.  
  1883. Thus if the filename arrives inside the macro with single backslashes, the
  1884. backslashes are preserved if you always refer to the parameter through the
  1885. \fcontents() function.
  1886.  
  1887. Now how to ensure that backslashes are not stripped or misinterpreted when
  1888. passing a filename to a macro?  This brings us back to what we learned in
  1889. earlier sections:
  1890.  
  1891.  1. If it is a literal filename, either double the backslashes, or (if the
  1892.     filename is to be used only within Kermit itself and not passed to a
  1893.     DOS shell, or it is to be passed to an alternative shell that accepts
  1894.     forward slash as a directory separator), use forward slash instead of
  1895.     backslash as the directory separator.
  1896.  
  1897.  2. If it is a variable that contains a filename, make sure you use a
  1898.     macro-style variable name, rather than a backslash-percent-character
  1899.     name.
  1900.  
  1901. Examples:
  1902.  
  1903.   define test echo \fcontents(\%1)
  1904.   define filename c:\mydir\blah.txt
  1905.  
  1906.   test c:\\mydir\\blah.txt  ; Literal filename with double backslashes
  1907.   c:\mydir\blah.txt
  1908.  
  1909.   test c:/mydir/blah.txt    ; Literal filename with forward slashes
  1910.   c:/mydir/blah.txt
  1911.  
  1912.   test \m(filename)         ; Variable
  1913.   c:\mydir\blah.txt
  1914.  
  1915. But what if you don't like these rules and you still want to pass a literal
  1916. filename containing single backslashes to a macro?  This is possible too, but
  1917. a bit tricky: turn command quoting off before invoking the macro, and then
  1918. turn it back on inside the macro.  Example:
  1919.  
  1920.   define test set command quoting on, echo \fcontents(\%1)
  1921.  
  1922.   set command quoting off
  1923.   test c:\mydir\blah.txt
  1924.   c:\mydir\blah.txt
  1925.  
  1926. Upon return from the macro, command quoting is back on (since the macro
  1927. turned it on).
  1928.  
  1929. Obviously this trick can not be used if the filename is stored in a variable,
  1930. since it prevents the variable from being evaluated.
  1931.  
  1932. 1.11.6. Passing DOS File Names from Macro Parameters to the DOS Shell
  1933.  
  1934. Now suppose you need to pass a DOS filename to a macro, and the macro needs
  1935. to pass it, in turn, to the Windows shell via (say) Kermit's RUN command.
  1936. This works too:
  1937.  
  1938.   define xrun run \fcontents(\%1)
  1939.   xrun c:\\windows\\command\\chkdsk.exe
  1940.  
  1941. (or you can use the SET COMMAND QUOTING OFF / ON technique described above
  1942. to avoid the double backslashes.)  But..
  1943.  
  1944.   xrun c:/windows/command/chkdsk.exe
  1945.  
  1946. does not work if the Windows shell does not recognize "/" as a directory
  1947. separator.  If there is a chance that a filename might be passed to the macro
  1948. in this form, the macro will need to convert it to a form acceptable to the
  1949. shell:
  1950.  
  1951.   define xrun run \freplace(\fcontents(\%1),/,\\)
  1952.  
  1953. Here we replace all occurrences (if any) of "/" in the argument with "\" prior
  1954. to issuing the RUN command.  Of course, in order to specify "\" as a literal
  1955. character in the \freplace() argument list, we have to double it.
  1956.  
  1957. 1.11.7. Passing DOS Filenames to Kermit from the Shell
  1958.  
  1959. As noted in the manual, the \&@[] array contains Kermit's command-line
  1960. arguments.  Suppose one of these arguments, say \&@[3], is a DOS filename
  1961. such as C:\FOO\BAR\BAZ\OOFA.TXT.  (Note: In C-Kermit 7.0 and K95 1.1.18
  1962. and later, command-line arguments after "=" or "--" are also available in
  1963. the top-level \%1..9 variables; see Section 7.5.)
  1964.  
  1965. Of course you can eliminate any problems by using forward slashes rather
  1966. than backslashes in the filename, but sometimes this is not possible, as when
  1967. the Kermit command line is being generated by another program than can only
  1968. generate "native" format DOS filenames.
  1969.  
  1970. As noted in the manual, "\%x" variables and \&x[] arrays are always evaluated
  1971. "all the way" (recursively).  If the contents of one of these variables
  1972. contains backslashes, this causes another level of evaluation.
  1973.  
  1974. There is another kind of variable, which is evaluated only "one level deep".
  1975. You can use this to prevent interpretation of the backslashes in the
  1976. filenames.
  1977.  
  1978. Example:
  1979.  
  1980.   assign filename \fcontents(\&@[3])  ; Transfer contents
  1981.   ...
  1982.   send \m(filename)
  1983.  
  1984. Or, more simply:
  1985.  
  1986.   send \fcontents(\&@[3])
  1987.  
  1988. 1.12. Debugging
  1989.  
  1990. The debug log is produced when you give a "log debug" command.  This is
  1991. normally done at the request of the Kermit help desk, for forwarding to the
  1992. Kermit developers for analysis as a last resort in troubleshooting problems.
  1993. (Last resort because it can grow quite huge in a very short time.)  In cases
  1994. where timing information is critical to understanding a problem, you can
  1995. tell C-Kermit to put a timestamp on each debug log line by giving the command:
  1996.  
  1997.   SET DEBUG TIMESTAMP ON
  1998.  
  1999. At any time before or after activating the debug log (SET DEBUG TIMESTAMP OFF
  2000. turns off timestamping).  Timestamps can be turned off and on as desired while
  2001. logging.  Obviously, they increase the size and growth rate of the log
  2002. significantly, and so should be used sparingly.  Timestamps are of the form
  2003. hh:mm:ss.xxx, where .xxx is thousands of a second (but is included only on
  2004. platforms that include this feature).
  2005.  
  2006. 1.13. Logs
  2007.  
  2008. In UNIX C-Kermit and in K-95, you can now direct any log to a pipe.  This
  2009. not only lets you send your logs to places other than disk files, but also
  2010. lets you customize them to any desired degree.
  2011.  
  2012. LOG { DEBUG, PACKETS, SESSION, TRANSACTION, CONNECTION } { file, pipe } ...
  2013.   A "pipe" is the name of a command, preceded by a vertical bar.  If the
  2014.   pipe contains any spaces, it must be enclosed in braces.
  2015.  
  2016. Here are some examples for UNIX (always remember the importance of getting
  2017. the UNIX shell quoting rules right):
  2018.  
  2019. LOG TRANSACTIONS |lpr
  2020.   This sends the transaction log to the default UNIX printer, rather than
  2021.   to a file (use "lp" rather than "lpr" if necessary).
  2022.  
  2023. LOG TRANSACTIONS {| myfilter > t.log}
  2024.   For those who don't like the format of the transaction log, or want to
  2025.   extract certain information from it; write your own output filter.
  2026.  
  2027. LOG SESSION {| lpr -Plaserwriter}
  2028.   This sends the session log to a specific UNIX printer, rather than to a
  2029.   file.  Note the braces around the pipeline.  These are required because
  2030.   it contains spaces.
  2031.  
  2032. LOG DEBUG {| tail -100 > debug.log}
  2033.   This causes the debug log file to contain only the final 100 lines.
  2034.   Suppose C-Kermit crashes under some unpredictable circumstances, and
  2035.   you need a debug log to catch it in the act.  But the debug log can grow
  2036.   to huge proportions very quickly, possibly filling up the disk.  Piping
  2037.   the debug log through "tail" results in keeping only the last 100 lines
  2038.   (or other number of your choice).
  2039.  
  2040. LOG DEBUG {| grep "^TELNET" > debug.log}
  2041.   This one shows how to log only Telnet negotiations.  Piping the debug log
  2042.   through grep or egrep lets you log only specific information, rather than
  2043.   everything.  "man grep" for further info.
  2044.  
  2045. LOG DEBUG {| gzip -c > debug.log.gz}
  2046.   Creates a full debug log, but compressed by gzip to save space.
  2047.  
  2048. LOG PACKETS {| tr "\\01" "X" | cut -c9- > packet.log}
  2049.   This one writes the regular packet log, but translates the Ctrl-A that
  2050.   starts each packet to the letter "X" and removes the s-nn-nn- notation
  2051.   from the beginning of each line.  Note the double backslash (normal Kermit
  2052.   quoting rules).  "man tr" and "man cut" for further info.
  2053.  
  2054. See Section 2.12 for information about the new connection log.
  2055.  
  2056. 1.14. Automatic File-Transfer Packet Recognition at the Command Prompt
  2057.  
  2058. Beginning in version 7.0, C-Kermit can recognize Kermit (and in some cases
  2059. also Zmodem) file-transfer packets while at its command prompt.  This is
  2060. convenient (for example), if you escaped back from a remote Kermit program
  2061. and told the local Kermit program to send a file, but forgot to tell the
  2062. remote Kermit program to receive it (and the local Kermit did not have the
  2063. "send a Kermit receive command" feature available).  This feature is
  2064. controlled by the following command:
  2065.  
  2066. SET COMMAND AUTODOWNLOAD { ON, OFF }
  2067.   When ON, which is the default, the command parser recognizes Kermit
  2068.   packets when Kermit is in remote mode.  An S packet makes it go into
  2069.   receive mode, an I packet makes it go into server mode.  When OFF, packet
  2070.   recognition is disabled and the behavior when a packet is received at the
  2071.   command prompt is as it was in C-Kermit 6.1 and earlier (namely to print
  2072.   an error message).
  2073.  
  2074. COMMAND AUTODOWNLOAD is the command-mode equivalent of TERMINAL AUTODOWNLOAD,
  2075. which is effective during CONNECT mode.
  2076.  
  2077. 1.15. The TYPE Command
  2078.  
  2079. The TYPE command now accepts a selection of optional switches (Section 1.5),
  2080. and also sets several variables.
  2081.  
  2082. Syntax: TYPE [ switches... ] filename
  2083.  
  2084. Variables:
  2085.  
  2086.   \v(ty_ln)  Line number of current line (during TYPE command; see /PREFIX)
  2087.   \v(ty_lc)  Line count of file most recently TYPEd.
  2088.   \v(ty_mc)  Match count of file most recently TYPEd (see /MATCH).
  2089.  
  2090. Switches:
  2091.  
  2092. /PAGE
  2093.   If /PAGE is included, Kermit pauses at the end of each screenful and issues
  2094.   a "more?" prompt.  You may press the space bar to view the next page
  2095.   (screenful), or press "q" or "n" to return to the C-Kermit prompt.  If this
  2096.   switch is given, it overrides the COMMAND MORE-PROMPTING setting for this
  2097.   command only.  If it is not given, paging is according to COMMAND
  2098.   MORE-PROMPTING.
  2099.  
  2100. /NOPAGE
  2101.   Do not pause at the end of each screenful; show the whole file (or all
  2102.   selected lines) at once.  If this switch is given, it overrides the COMMAND
  2103.   MORE-PROMPTING setting for this command only.  If it is not given, paging is
  2104.   according to COMMAND MORE-PROMPTING.
  2105.  
  2106. /HEAD[:n]
  2107.   Only show the first "n" lines of the file (where n is a number).
  2108.   If n is omitted, 10 is used.
  2109.  
  2110. /TAIL[:n]
  2111.   Only show the last "n" lines of the file (where n is a number).  If n is
  2112.   omitted, 10 is used.  Note: /HEAD and /TAIL can't be combined; if you give
  2113.   both switches, only the most recent one is used.
  2114.  
  2115. /MATCH:pattern
  2116.   Only type lines from the file that match the given pattern (see Section
  2117.   4.9.1 for pattern notation).  UNIX users familiar with grep should note
  2118.   a significant difference: there is no implied "*" at the beginning and end
  2119.   of the pattern.  Thus:
  2120.  
  2121.     TYPE /MATCH:foo    Lists lines whose entire contents are "foo".
  2122.     TYPE /MATCH:foo*   Lists lines that start with "foo".
  2123.     TYPE /MATCH:*foo   Lists lines that end with "foo".
  2124.     TYPE /MATCH:*foo*  Lists lines that have "foo" anywhere in them.
  2125.  
  2126.   /HEAD and /TAIL apply after /MATCH, so "type /tail:20 /match:x*" shows the
  2127.   last 20 lines in the file that start with "x".
  2128.  
  2129. /PREFIX:string
  2130.   Print the given string at the beginning of each line.  The string may be a
  2131.   constant, a variable, or a quoted variable.  If it's an unquoted variable,
  2132.   its value at the time the TYPE command was given is used as a constant.
  2133.   If it is a quoted variable, it is re-evaluated for each line; a useful
  2134.   variable for this context is \v(ty_ln) (the line number of the current line
  2135.   being typed).  If the prefix is to include spaces, it must be enclosed in
  2136.   braces.  Examples:
  2137.  
  2138.   type /prefix:{oofa.txt: } /match:*thing* oofa.txt
  2139.     Prints all lines in oofa.txt that contain "thing" with the filename
  2140.     itself as the prefix (similar to UNIX grep).
  2141.  
  2142.   type /prefix:{\v(time). } oofa.txt
  2143.     Prefixes each line of oofa.txt with the time at which the TYPE command
  2144.     was given (one backslash)
  2145.  
  2146.   type /prefix:{\\v(time). } oofa.txt
  2147.     Prefixes each line of oofa.txt with the time at which that line is
  2148.     being typed (two backslashes).
  2149.  
  2150.   type /prefix:{\\v(ty_ln). } oofa.txt
  2151.     Prefixes each line of oofa.txt with its line number.
  2152.  
  2153.   type /prefix:{\\flpad(\\v(ty_ln),4). } oofa.txt
  2154.     Same as the previous example, except the line number is right-adjusted
  2155.     in a 4-column field.
  2156.  
  2157. /WIDTH[:n]
  2158.   Truncates each line at column "n" (which must be a number) prior to printing
  2159.   it.  This option can be used for long lines when you don't want them to wrap.
  2160.   If n is omitted, your current screen width is used.
  2161.  
  2162. /COUNT
  2163.   Counts lines and -- if /MATCH was included, matches -- but does not print
  2164.   any lines from the file.  The line and match count is shown at the end,
  2165.   and the variables \v(ty_lc) and \v(ty_lm) are set accordingly.
  2166.  
  2167. SET OPTIONS TYPE { /PAGE, /NOPAGE, /WIDTH:n }
  2168.   Sets the paging default for TYPE commands, which can be overridden in any
  2169.   particular TYPE command by including the desired switch.
  2170.  
  2171. If a TYPE command is given with no switch, and no SET OPTIONS TYPE selection
  2172. is in effect, paging is according to your COMMAND MORE-PROMPTING setting
  2173. (SHOW COMMAND).
  2174.  
  2175. 1.16. The RESET Command
  2176.  
  2177. The RESET command, added in 7.0, closes all open files and logs, but does not
  2178. affect the open connection (if any).
  2179.  
  2180. 1.17. The COPY and RENAME Commands
  2181.  
  2182. As of C-Kermit 7.0, in the UNIX version only, the COPY and RENAME commands are
  2183. built in and do not call the underlying platform's COPY or RENAME command.
  2184. This allows them to work in "NOPUSH" versions and other circumstances where it
  2185. can't access system commands, and it allows file copying and renaming to be
  2186. done portably in scripts.  The characteristics of the built-in COPY or RENAME
  2187. include:
  2188.  
  2189.  . It fails if the source file is a directory or is wild or lacks read access.
  2190.  . It fails if the source file is the destination file.
  2191.  . It allows the destination file to be a directory, in which case the source
  2192.    file is copied (or renamed) into it with the same name.
  2193.  . It overwrites an existing destination file if its permission allows.
  2194.  . It sets the new file's permission according to umask but also carries
  2195.    forward the source file's execute permission bits if the destination file
  2196.    did not already exist.
  2197.  . It fails if interrupted by Ctrl-C.
  2198.  . Upon error, it prints an appropriate message.
  2199.  . It returns standardized error codes that can be tested by IF SUCCESS / FAIL.
  2200.  
  2201. These commands now also accept the following switches:
  2202.  
  2203.   /LIST (/LOG, /VERBOSE)    = Print "file1 => file2 (OK)" (or error message).
  2204.   /NOLIST (/NOLOG, /QUIET)  = Don't print anything (except error messages).
  2205.  
  2206. /NOLIST is the default.
  2207.  
  2208. The same built-in code is used by the UNIX C-Kermit server to execute REMOTE
  2209. COPY commands (except in this case no switches are available).
  2210.  
  2211. The COPY command also accepts the following additional switches.  When any of
  2212. these are given (and they can be used in any combination except /SWAP and
  2213. /APPEND), some of the checks listed above are relaxed, and thus it might be
  2214. possible to get into trouble in certain cases, e.g. when the source and target
  2215. files are the same file:
  2216.  
  2217.   /APPEND                   = Append source file to destination file.
  2218.   /SWAP-BYTES               = Swap bytes (see Section 6.6.5).
  2219.   /FROMB64                  = Decode the source file from Base64 encoding.
  2220.   /TOB64                    = Encode the target file in Base64.
  2221.  
  2222. Base64 is the encoding commonly used for enclosures in Internet email.
  2223.  
  2224. 1.18. The MANUAL Command
  2225.  
  2226. The MANUAL command can be used to access the appropriate Kermit manual or
  2227. other manual.  The general syntax is:
  2228.  
  2229. MANUAL [ string ]
  2230.   If the string is omitted, C-Kermit asks the underlying system to access the
  2231.   C-Kermit manual using whatever method is appropriate for the system.
  2232.  
  2233. The specific action depends on the system.  In UNIX, a "man" command is
  2234. issued; "kermit" is the default argument but other manual topics may be
  2235. specified.  If the "man" command allows index or string searching, the
  2236. appropriate syntax may be included.
  2237.  
  2238. In Kermit 95, the MANUAL command brings up the HTML online K95 manual.
  2239.  
  2240. In VMS and elsewhere, "man" is simply translated to "help", with a default
  2241. argument of "kermit"; other and/or additional arguments may be included
  2242. according to the definition of the system's "help" command.
  2243.  
  2244. Correct operation of the "man" command in C-Kermit depends on the appropriate
  2245. man page or help topic having been installed in the right place with the
  2246. right permissions and format.
  2247.  
  2248. 1.19. String and Filename Matching Patterns
  2249.  
  2250. A pattern is a string that includes special notation for matching classes or
  2251. sequences of characters.  C-Kermit 7.0 / K95 1.1.18 supports patterns in
  2252. several places:
  2253.  
  2254.  . Filenames (Section 4.9)
  2255.  . SWITCH case labels (Section 7.18)
  2256.  . The new IF MATCH statement (Section 7.4)
  2257.  . TYPE /MATCH (Section 1.15)
  2258.  . SET FILE TEXT-PATTERNS and BINARY-PATTERNS (Section 4.3)
  2259.  . The \fsearch() and \farraylook() functions (Sections 7.3 and 7.10.7)
  2260.  . The \fpattern() function used with [M,RE]INPUT (Section 7.1)
  2261.  
  2262. Patterns are also called wildcards, especially when used for filename
  2263. matching.  C-Kermit's pattern syntax is explained in Section 4.9.1, and also
  2264. by the HELP WILDCARDS command.
  2265.  
  2266. 1.20. Multiple Commands on One Line
  2267.  
  2268. As of C-Kermit 7.0, commands can be grouped together on one line by separating
  2269. the commands with commas and enclosing the list in braces.  For example:
  2270.  
  2271.   { echo One, echo Two, echo Three }
  2272.  
  2273. or:
  2274.  
  2275.   do { echo One, echo Two, echo Three }
  2276.  
  2277. Command lists can be nested:
  2278.  
  2279.   [ do ] { echo One, echo Two, if true { echo A, echo B}, echo Three }
  2280.  
  2281. and the END command works as it does in macros:
  2282.  
  2283.   [ do ] { echo One, echo Two, if true end, echo Three }
  2284.  
  2285. The "one line" stricture is, of course, pliant to line-continuation
  2286. conventions, namely that lines ending in hyphen (-) or left brace ({) are
  2287. to be continued.  Thus the first example can also be rendered:
  2288.  
  2289.   [ do ] {
  2290.       echo One
  2291.       echo Two
  2292.       echo Three
  2293.   }
  2294.  
  2295. (the "do" is optional).
  2296.  
  2297. 1.21. What Do I Have?
  2298.  
  2299. C-Kermit can be built for hundreds of different platforms with practically
  2300. countless configuration options.  Certain commands might not be available in
  2301. certain configurations, etc.  Even on the same platform, different builds are
  2302. possible: "maximum functionality", "minimum size", "maximum performance", and
  2303. so on.  You can find out a lot about the configuration of your C-Kermit
  2304. program with the SHOW FEATURES command.  Of course, a lot of what it says,
  2305. especially in the bottom part, might seem like gibberish, but can be
  2306. deciphered with a Rosetta Stone (such as the C-Kermit source or the ckccfg.txt
  2307. file).  In any case, the output from SHOW FEATURES might easily explain why
  2308. some expected feature is missing, or some buffer is smaller than expected.
  2309. Here's a sample of the bottom section for the SunOS version:
  2310.  
  2311. C-Kermit 7.0.196, 1 Jan 2000
  2312.  
  2313. Major optional features included:
  2314.  Network support (type SHOW NET for further info)
  2315.  Telnet Kermit Option
  2316.  Hardware flow control
  2317.  External XYZMODEM protocol support
  2318.  Latin-1 (West European) character-set translation
  2319.  Latin-2 (East European) character-set translation
  2320.  Cyrillic (Russian, Ukrainian, etc) character-set translation
  2321.  Greek character-set translation
  2322.  Hebrew character-set translation
  2323.  Japanese character-set translation
  2324.  Unicode character-set translation
  2325.  Pseudoterminal control
  2326.  REDIRECT command
  2327.  RESEND command
  2328.  Fullscreen file transfer display
  2329.  Control-character unprefixing
  2330.  Streaming
  2331.  Autodownload
  2332.  
  2333. Major optional features not included:
  2334.  No Kerberos(TM) authentication
  2335.  No SRP(TM) (Secure Remote Password) protocol
  2336.  No Secure Sockets Layer (SSL) protocol
  2337.  No Transport Layer Security (TLS) protocol
  2338.  No encryption
  2339.  No X Windows forwarding
  2340.  
  2341. Host info:
  2342.  Machine:    sun4m
  2343.  Model:      (unknown)
  2344.  OS:         SunOS
  2345.  OS Release: 4.1.3_U1
  2346.  OS Version: 4
  2347.  
  2348. Target: sunos41gsc
  2349. GCC version: 2.7.2
  2350. Compiled Dec 31 1999 10:38:54, options:
  2351.  __GNUC__ __STDC__ _POSIX_JOB_CONTROL _SC_JOB_CONTROL ARRAYREFLEN=1024 BIGBUFOK
  2352.  BROWSER BSD4 CK_ANSIC CK_APC CK_AUTODL CK_CURSES CK_DNS_SRV CK_ENVIRONMENT
  2353.  CK_FAST CK_LOGIN CK_MKDIR CK_NAWS CK_PCT_BAR CK_PERMS CK_RECALL CK_RTSCTS
  2354.  CK_SPEED CK_TIMERS CK_TMPDIR CK_TTGWSIZ CK_TTYFD CK_WREFRESH CKEXEC
  2355.  CKFLOAT=double CKGHNLHOST ckmaxfiles=64 CKMAXOPEN=64 CKMAXPATH=1023 CKREALPATH
  2356.  CKREGEX CKSYSLOG CKTUNING CMDBL=32763 CMDDEP=64 CONGSPD DCMDBUF DIRENT DYNAMIC
  2357.  FNFLOAT FORDEPTH=32 GFTIMER HADDRLIST HDBUUCP IFDEBUG IKS_OPTION IKSDB
  2358.  IKSDCONF INBUFSIZE=32768 INPBUFSIZ=4096 MAC_MAX=16384 MACLEVEL=128 MAXDDIR=32
  2359.  MAXDNUMS=4095 MAXGETPATH=128 MAXTAKE=54 MAXWLD=102400 MSENDMAX=1024 NETCMD
  2360.  NETCONN NETPTY NOKVERBS NOSETBUF OBUFSIZE=32768 PARSENSE PATTERNS PIPESEND
  2361.  RENAME RLOGCODE SAVEDUID SELECT SIG_V SOL_SOCKET sparc STREAMING sun SUNOS4
  2362.  SYSTIMEH TCPSOCKET TIMEH TLOG TNCODE TTLEBUF TTSPDLIST UIDBUFLEN=256 UNIX
  2363.  UNPREFIXZERO USE_LSTAT USE_MEMCPY VNAML=4096 WHATAMI XFRCAN Z_MAXCHAN=46
  2364.  z_maxchan=46 ZXREWIND
  2365.  
  2366.  byte order: big endian
  2367.  
  2368.  sizeofs: int=4 long=4 short=2 char=1 char*=4 float=4 double=8
  2369.  
  2370.  floating-point: precision=16 rounding=1
  2371.  
  2372. Without going into detail about what all the notation means, notice a couple
  2373. things:
  2374.  
  2375.  . The Options section shows symbols ("macros") in effect during compilation,
  2376.    together with their values (for those that have values).  The options are
  2377.    listed in alphabetical order to make any particular option easier to find.
  2378.  
  2379.  . MAXWLD is the maximum number of files that a wildcard can expand to.
  2380.  
  2381.  . Anything starting with "NO" is a feature (or something other than a
  2382.    feature) that has been deliberately "compiled out", or omitted.
  2383.  
  2384.  . Important items for script writers include: CMDBL=32763 (the size of the
  2385.    command buffer and therefore the maximum length for a macro or variable
  2386.    definition; CMDDEP=64 (the limit on recursion depth); FORDEPTH=32 (the
  2387.    nesting limit on FOR loops); INBUFSIZE=32768 (the size of the INPUT command
  2388.    circular buffer); MAC_MAX=16384 (the maximum number of macros), etc.
  2389.  
  2390. See the ckccfg.txt file for details.
  2391.  
  2392. 1.22. Generalized File Input and Output
  2393.  
  2394. C-Kermit 7.0 adds a new generalized I/O system for stream files, augmenting
  2395. (and to some extent, overlapping with) the older OPEN, READ, WRITE, and CLOSE
  2396. commands.  In the new file i/o system, which can be used simultaneously with
  2397. the old one, all commands are grouped together under the new FILE keyword,
  2398. and some related functions and variables are added.
  2399.  
  2400. 1.22.1. Why Another I/O System?
  2401.  
  2402. The well-known LOG, OPEN, READ, WRITE, and CLOSE commands have the following
  2403. restrictions:
  2404.  
  2405.  a. Only one READ file and one WRITE file can be open at a time.
  2406.  b. The READ and WRITE commands are strictly line oriented.
  2407.  c. These commands can not be used with binary files.
  2408.  d. They do not support read/write access or random access.
  2409.  e. The syntax is a bit counterintuitive for programmers.
  2410.  
  2411. The new file i/o system allows multiple files to be open at once, in any
  2412. desired combination of modes (read/write/append) supported by the operating
  2413. system, for line, block (record), or character i/o, for sequential or random
  2414. access, using consistent syntax and conventions.
  2415.  
  2416. The new system, however, does not replace the old one, since the old system
  2417. still must be used for:
  2418.  
  2419.  a. The session, packet, debug, transaction, and connection logs.
  2420.  b. Reading and writing commands rather than files.
  2421.  c. Existing scripts.
  2422.  
  2423. The new system works only with regular files, not with commands or pipes or
  2424. mailboxes or pseudoterminals.  No special provisions are made in the FILE
  2425. commands for handling devices or network connections, nor for preventing you
  2426. from trying to open them; if the underlying operating system treats them
  2427. like regular stream disk files, the FILE commands (except, of course SEEK,
  2428. REWIND, and COUNT) might work with them.  (In C programming terms, the FILE
  2429. commands are, at present, nothing more than a front end to fopen() / fread()
  2430. / fwrite() / fclose() and friends, which are a portable API to sequential
  2431. files, but this might change in the future for platforms like VMS and VOS
  2432. that have more complicated file systems.)
  2433.  
  2434. Definitions:
  2435.  
  2436. Channel
  2437.   A number assigned to a file when it is opened, by which it must be referred
  2438.   to in all input/output operations.
  2439.  
  2440. Read/Write Pointer
  2441.   The current position in an open file, expressed as the 0-based byte count
  2442.   from the beginning.
  2443.  
  2444. 1.22.2. The FILE Command
  2445.  
  2446. The FILE command has the following syntax:
  2447.  
  2448.   FILE <keyword> [ <switches> ] <channel> [ <data> ]
  2449.  
  2450. The <keyword> specifies the function: FILE OPEN, FILE READ, FILE WRITE, FILE
  2451. CLOSE, etc.  For convenience (and for familiarity to C programmers), the
  2452. two-word FILE commands can be shortened to the single words FOPEN, FREAD,
  2453. FWRITE, FCLOSE, and so on.  Switches are optional, and modify or amplify the
  2454. requested file function.
  2455.  
  2456. As in C, Fortran, and other programming languages, open files are referred to
  2457. by "channels", integers such as 0, 1, 2, 3, and so on.  A channel number is
  2458. assigned when you open a file.  The number of available channels depends on
  2459. the underlying operating system, and can be seen in the variable:
  2460.  
  2461.   \v(f_max)
  2462.  
  2463. or by giving the FILE LIST (FLIST) command.  Channels are discussed in
  2464. greater detail in Section 1.22.4.
  2465.  
  2466. FILE command errors can be caught with IF FAIL after the FILE command.  In
  2467. addition, the \v(f_error) variable is set to the completion code of the
  2468. command: 0 if no error, or a negative number if there was an error.  The error
  2469. codes are listed in Section 1.22.5.
  2470.  
  2471. The command to open a file is:
  2472.  
  2473. FILE OPEN [ switches ] <variable> <filename>
  2474.   Opens a file for the type of access specified by the switches, or for
  2475.   read-only access if no switches are given.  Upon success, a channel number
  2476.   is assigned to this file and stored in the given variable so you can refer
  2477.   to the open file in subsequent i/o commands.  If the file can not be opened,
  2478.   the FILE OPEN command fails.  Synonym: FOPEN.
  2479.  
  2480. The FILE OPEN switches are:
  2481.  
  2482. /READ
  2483.   Open the file for read access.  If no switches are given, /READ is assumed.
  2484.   If the file does not exist or can't be opened for read access, the FILE OPEN
  2485.   command fails.
  2486.  
  2487. /WRITE
  2488.   Allow writing.  If a file of the same name already exists, it is
  2489.   overwritten unless /READ or /APPEND is also included.  If a file of the
  2490.   given name does not exist, it is created.
  2491.  
  2492. /APPEND
  2493.   Equivalent to /WRITE, except that if the file exists, it is not destroyed.
  2494.   The read/write pointer is set to the end of the file, so unless you change
  2495.   it with FILE SEEK or REWIND (see below), the first FILE WRITE command adds
  2496.   to the end of the file, preserving what was there already.  If /WRITE is
  2497.   also given, it is ignored.
  2498.  
  2499. /BINARY
  2500.   Open the file in "binary" mode, rather than text mode.  This switch is
  2501.   meaningless (but still can be used) in UNIX.  In VMS, Windows, and OS/2,
  2502.   it inhibits end-of-line processing and conversion, and so should be used
  2503.   for binary files and/or files that are to be accessed in record or
  2504.   character mode rather than line by line.
  2505.  
  2506. The variable for the channel number can be any kind of variable: the \%x kind,
  2507. a macro name, or an array element.  But it must be a variable, not a number --
  2508. C-Kermit assigns the channel number; you can't tell it what number to use.
  2509.  
  2510. Example:
  2511.  
  2512.   FILE OPEN \%c oofa.txt                  ; Open oofa.txt for reading.
  2513.   IF FAIL exit 1 Can't open oofa.txt      ; Always check to see if it worked.
  2514.   ECHO oofa.txt: channel = \%c
  2515.  
  2516. If the file oofa.txt is opened successfully, a channel number is assigned
  2517. to the variable \%c.  Here's another example using a macro name for the
  2518. channel number:
  2519.  
  2520.   FILE OPEN channel oofa.txt              ; Open oofa.txt for reading.
  2521.   IF SUCCESS ECHO oofa.txt: channel = \m(channel)
  2522.  
  2523. Switches can be combined when it makes sense and the underlying operating
  2524. system allows it.  For example, to open a file in binary mode for reading and
  2525. writing (sometimes called "update"):
  2526.  
  2527.   FILE OPEN /READ /WRITE /BINARY \%c budget.db
  2528.  
  2529. Some combinations might be allowed, others not.  For example /READ /APPEND
  2530. will usually not be allowed.  /WRITE /APPEND is treated as /APPEND.
  2531.  
  2532. A major advantage of the new system over the older one is that you can have
  2533. multiple files open at once.  Suppose, for example, that you want to open all
  2534. the files in a certain directory at once:
  2535.  
  2536.   .\%n := \ffiles(/usr/olga*,&f)          ; Get file list into array.
  2537.   if ( > \%n \v(f_max) ) {                ; Make sure there aren't too many.
  2538.       exit 1 {\v(dir): \%n = Too many files}
  2539.   }
  2540.   declare \&c[\%n]                        ; Make array for channel numbers.
  2541.   for \%i 1 \%n 1 {                       ; Loop to open every file...
  2542.       file open \&c[\%i] \&f[\%i]         ; Try to open this one
  2543.       if fail exit 1 Open error: \&f[\%i] ; Check for failure
  2544.   }
  2545.  
  2546. If this loop completes successfully, the \&c[] array will contain \%n
  2547. channel numbers of open files in elements 1 through \%n.
  2548.  
  2549. Any file that you open with FILE OPEN stays open until you close it.  The
  2550. command to close a file is:
  2551.  
  2552. FILE CLOSE { ALL, <channel> }
  2553.   If a channel number is given and the channel refers to an open file, the
  2554.   file is closed and the channel is freed for reuse; if the channel does not
  2555.   refer to an open file, an error message is printed and the command fails.
  2556.   If ALL is specified instead of a specific channel, all files opened with
  2557.   FILE OPEN are closed and if all open files were closed successfully (even
  2558.   if no files were open), the command succeeds; if any open file could not be
  2559.   closed, the command fails; however, all open files that could be closed are
  2560.   still closed.  Synonym: FCLOSE.
  2561.  
  2562. FILE CLOSE might fail because, for example, the disk filled up or a quota
  2563. was exceeded.
  2564.  
  2565. Example:
  2566.   fopen /write \%c new.txt                ; Open new.txt for writing.
  2567.   if fail exit 1                          ; Check for error.
  2568.   fclose \%c                              ; Close the file we just opened.
  2569.  
  2570. This creates a 0-length file called new.txt.
  2571.  
  2572. Note that FILE OPEN /WRITE (without /READ or /APPEND) always creates a new
  2573. file, and therefore destroys any file with the same name that might already
  2574. exist (assuming you have permission to delete it).  To avoid overwriting
  2575. existing files, simply check first:
  2576.  
  2577.   if exist new.txt exit 1 {Fatal - new.txt already exists}
  2578.   fopen /write \%c new.txt
  2579.   if fail ...
  2580.  
  2581. The next two commands give information about open files:
  2582.  
  2583. FILE STATUS <channel>
  2584.   Tells the name of the file, if any, open on the given channel and the
  2585.   switches it was opened with.  The read/write pointer is also shown; this is
  2586.   where the next read or write will occur; "[EOF]" is shown if the current
  2587.   position in the open file is the end -- i.e. the next read will fail if the
  2588.   file was opened in /READ mode; the next write will add material to the end.
  2589.   The current line number (0-based) is also shown if known.  The FILE STATUS
  2590.   command succeeds if the <channel> is open, and fails if there is no open
  2591.   file on the given channel, or if the channel number is invalid or out of
  2592.   range.  Synonym FSTATUS.
  2593.  
  2594. FILE LIST
  2595.   Lists the channel number and name of each open file, along with its OPEN
  2596.   modes (R, W, A, B, RW, etc) and its current read/write pointer or "[EOF]" if
  2597.   it is at the end.  Also tells the number of files currently opened with FILE
  2598.   OPEN, plus the maximum number of open files allowed by the system and the
  2599.   maximum number allowed for FILE OPEN.  Synonym: FLIST.
  2600.  
  2601. Next come the commands for reading and writing files:
  2602.  
  2603. FILE READ [ switches ] <channel> [ <variable> ]
  2604.   Reads data from the file on the given channel number into the <variable>,
  2605.   if one was given; if no variable was given, the result is printed on the
  2606.   screen.  IMPORTANT: The variable should normally be a macro name rather
  2607.   than a \%x or \&x[] variable if you want backslash characters in the file
  2608.   to be taken literally (see pp.408-412 of "Using C-Kermit" for an
  2609.   explanation; you can also read into a \%x or \&x[] variable, but then you
  2610.   must remember to protect future references to it by \fcontents() if you
  2611.   don't want C-Kermit to process any backslashes it might contain).  The
  2612.   desired amount of data (according to the switches) is read from the file at
  2613.   the current read/write pointer, and upon completion the read/write position
  2614.   is updated to first byte after the data that was read, no matter what
  2615.   switches were given.  Synonym: FREAD.
  2616.  
  2617. FILE WRITE [ switches ] <channel> <text>
  2618.   Writes the given text to the file on the given channel number.  The <text>,
  2619.   of course, can be literal text or a variable, or any combination.  If the
  2620.   text might contain leading or trailing spaces, it must be enclosed in braces
  2621.   if you want to preserve them.  Synonym: FWRITE.
  2622.  
  2623. Before proceeding, a caution about the NUL character.  C-Kermit is so named
  2624. because it is a Kermit program written in the C language.  In C, character
  2625. strings are represented as a sequence of non-NUL bytes terminated by a NUL
  2626. byte (a byte in which all bits are 0).  Thus a C string can not contain NUL
  2627. bytes; it always ends with the first NUL byte.  C-Kermit variables are
  2628. implemented as C strings and therefore can't contain NUL bytes either, so the
  2629. FILE READ and FILE WRITE commands do not handle files or strings that contain
  2630. NUL bytes, except when the /CHARACTER switch is included with the FILE READ or
  2631. WRITE command, or when /LPAD:0 or /RPAD:0 is given with the FILE WRITE command;
  2632. these switches are explained below.
  2633.  
  2634. Also note that Kermit can not be used read or write binary numbers in the
  2635. machine's internal format (integer or floating-point); in general, numbers can
  2636. be processed only when represented as numeric or floating-point strings.
  2637.  
  2638. FILE READ switches are:
  2639.  
  2640. /LINE
  2641.   Specifies that a line of text is to be read.  A line is defined according
  2642.   to the underlying operating system's text-file format.  For example, in
  2643.   UNIX a line is a sequence of characters up to and including a linefeed,
  2644.   or the end of the file, which ever comes first.  The line terminator (if
  2645.   any) is removed before assigning the text to the variable.  If no switches
  2646.   are included with the FILE READ command, /LINE is assumed.  Normally this
  2647.   switch should not be used with files opened in /BINARY mode (but nothing
  2648.   prevents it either).
  2649.  
  2650. /SIZE:number
  2651.   Specifies that the given number of bytes (characters) is to be read.  The
  2652.   actual number of bytes returned will be less if the end of file is reached
  2653.   (or a NUL byte is encountered).  For example, if a file is 514 bytes long,
  2654.   FILE READ /SIZE:512 returns 512 bytes the first time and 2 bytes the second
  2655.   time.  FILE READ /SIZE provides a kind of "record i/o" for files that do not
  2656.   necessarily contain lines.  The resulting block of characters is assigned to
  2657.   the variable without any editing.  Synonym: /BLOCK.
  2658.  
  2659. /CHARACTER
  2660.   Equivalent to /SIZE:1.  If FILE READ /CHAR succeeds but the <variable> is
  2661.   empty, this indicates a NUL byte was read.  Synonym: BYTE.
  2662.  
  2663. FILE WRITE switches are:
  2664.  
  2665. /LINE
  2666.   Specifies that an appropriate line terminator is to be added to the
  2667.   end of the <text>.  If no switches are included, /LINE is assumed.
  2668.  
  2669. /SIZE:number
  2670.   Specifies that the given number of bytes (characters) is to be written.
  2671.   If the given <text> is longer than the requested size, it is truncated;
  2672.   if is shorter, it is padded according /LPAD and /RPAD switches.  Synonym:
  2673.   /BLOCK.
  2674.  
  2675. /LPAD[:value]
  2676.   If /SIZE was given, but the <text> is shorter than the requested size, the
  2677.   text is padded on the left with sufficient copies of the character whose
  2678.   ASCII value is given to write the given length.  If no value is specified,
  2679.   32 (the code for Space) is used.  The value can also be 0 to write the
  2680.   indicated number of NUL bytes.  If /SIZE was not given, this switch is
  2681.   ignored.
  2682.  
  2683. /RPAD[:value]
  2684.   Like LPAD, but pads on the right.
  2685.  
  2686. /CHARACTER
  2687.   Specifies that one character should be written.  If the <text> is empty or
  2688.   not given, a NUL character is written; otherwise the first character of
  2689.   <text> is given.  Synonym: /BYTE.
  2690.  
  2691. /STRING
  2692.   Specifies that the <text> is to be written as-is, with no terminator added.
  2693.  
  2694. Here's an example in which we copy a text file line by line:
  2695.  
  2696.   file open /read \%c oofa.txt            ; Open input file
  2697.   if fail exit 1 Can't open input file    ; Check that it's open
  2698.   file open /write \%d new.txt            ; Open output file
  2699.   if fail exit 1 Can't open output file   ; Check
  2700.   while true {                            ; Loop to copy lines
  2701.       file read /line \%c line            ; Read a line
  2702.       if fail break                       ; Assume failure = end of file
  2703.       file write /line \%d {\m(line)}     ; Write the line to output file
  2704.       if fail exit 1 Write failure        ; Failure here is fatal
  2705.   }
  2706.   file close \%c                          ; Close the two files
  2707.   file close \%d
  2708.  
  2709. Note that since /LINE is the default for both FILE READ and FILE WRITE, it can
  2710. be omitted as in the following example, where we also use the short names for
  2711. the FILE commands.
  2712.  
  2713.   fopen /read \%c oofa.txt                ; Open input file
  2714.   if fail exit 1 Can't open input file    ; Check that it's open
  2715.   fopen /write \%d new.txt                ; Open output file
  2716.   if fail exit 1 Can't open output file   ; Check
  2717.   while true {                            ; Loop to copy lines
  2718.       fread \%c line                      ; Read a line
  2719.       if fail break                       ; Assume failure = end of file
  2720.       fwrite \%d {\m(line)}               ; Write the line to output file
  2721.       if fail exit 1 Write failure        ; Failure here is fatal
  2722.   }
  2723.   fclose \%c                              ; Close the two files
  2724.   fclose \%d
  2725.  
  2726. Here's the same example using "record i/o" (the open and close sequences are
  2727. are omitted since they are the same as above).  The result is the same, but
  2728. execution is much faster:
  2729.  
  2730.   while true {                            ; Loop to copy blocks
  2731.       fread /size:512 \%c block           ; Read a block into \%a
  2732.       if fail break                       ; Assume failure = end of file
  2733.       fwrite /string \%d {\m(block)}      ; Write the block to output file
  2734.       if fail exit 1 Write failure        ; Failure here is fatal
  2735.   }
  2736.  
  2737. Although record i/o is faster, it should not be used in line-oriented
  2738. applications, since it returns arbitrary chunks of the file to your script,
  2739. rather than lines.  In this example, FWRITE /STRING is used rather than FWRITE
  2740. /SIZE:512 to avoid the last output block being padded beyond the original
  2741. file's length.
  2742.  
  2743. A file can also be copied character by character, but this is much slower than
  2744. line i/o and VERY much slower than block i/o:
  2745.  
  2746.   while true {                            ; Loop to copy blocks
  2747.       fread /char \%c c                   ; Read a character into c
  2748.       if fail break                       ; Assume failure = end of file
  2749.       fwrite /char \%d {\m(c)}            ; Write character to output file
  2750.       if fail exit 1 Write failure        ; Failure is fatal
  2751.   }
  2752.  
  2753. Although character i/o is slow, it is the only way to process files that
  2754. contain NUL characters (i.e. bytes composed of only zero bits).  In the
  2755. example above, when "fread /char \%c c" returns a NUL, the c variable is
  2756. empty.  But since the FREAD /CHAR command did not fail, we know the result was
  2757. really a NUL.  FWRITE /CHAR, when given an empty variable (or no variable at
  2758. all) writes a NUL.  Thus the loop above will copy any file at all (very
  2759. slowly).  In non-copying applications, NULs are detected like this:
  2760.  
  2761.   fread /char \%c c
  2762.   if fail (do something)
  2763.   if not def c (a NUL byte was read)
  2764.  
  2765. Finally some advanced file operations:
  2766.  
  2767. FILE FLUSH <channel>
  2768.   For output files only: commits all previous writes to disk,
  2769.   in case the computer was buffering them.  Synonym: FFLUSH.
  2770.  
  2771. FILE COUNT [ { /BYTES, /LINES, /LIST, /NOLIST } ] <channel>
  2772.   By default, or if the /BYTES switch is given, counts the bytes in the
  2773.   file, if any, open on the given channel.  If the /LINES switch is given,
  2774.   counts lines in the file.  If the /LIST switch is given, the result is
  2775.   printed.  If the /NOLIST switch is given, the result is not printed.
  2776.   /QUIET is a synonym for /NOLIST.  If neither /LIST nor /NOLIST is given,
  2777.   the result is printed if the command is given at top level, i.e. not from
  2778.   a command file or macro.  In all cases, the result of the most recent FILE
  2779.   COUNT command is stored in the variable \v(f_count).  Note that FILE COUNT
  2780.   /LINE works (and can only work) by reading the entire file; expect it to
  2781.   take some time if the file is large.  Synonym: FCOUNT.
  2782.  
  2783. FILE REWIND <channel>
  2784.   Moves the read/write pointer to the beginning of the file.  Equivalent to
  2785.   FILE SEEK <channel> 0.  Synonym: FREWIND.
  2786.  
  2787. FILE SEEK [ switches ] <channel> { [{+,-}]<number>, LAST, EOF }
  2788.   Moves the read/write pointer for the file on this channel to the given
  2789.   position, which may be a byte (character) number or a line number,
  2790.   expressed in either absolute or relative terms.  Switches:
  2791.  
  2792.    /BYTE     - The number given is a byte number.  Synonym: /CHARACTER.
  2793.    /LINE     - The number given is a line number.
  2794.    /ABSOLUTE - The number given is absolute.
  2795.    /RELATIVE - The number given is relative to the current position.
  2796.  
  2797.   By default, or if the /BYTE switch is given, the <number> is a
  2798.   byte number (0 = first byte).  If /LINE is given, the <number> is a line
  2799.   number (0 = first line).  EOF means to move to the end of the file.
  2800.   LAST means to move to the last line or character of the file, depending
  2801.   on whether it's a line or character seek.
  2802.  
  2803.   If neither the /RELATIVE nor the /ABSOLUTE switch is given, then if a
  2804.   signed number is given, the motion is relative to the current position.
  2805.   An expression that evaluates to a negative number is not considered signed
  2806.   for this purpose; that is, a sign (+ or -) must be included as the first
  2807.   character of the <number> in the command itself to force a relative seek
  2808.   (in the absence of /RELATIVE or /ABSOLUTE).
  2809.  
  2810.   If the number has no sign, or if the /ABSOLUTE switch is given, the number
  2811.   represents an absolute position (relative to the beginning of the file).
  2812.   Subsequent FILE READs or WRITEs will take place at the new position.
  2813.  
  2814.   If the read/write pointer is placed after the end of the file, a
  2815.   subsequent FILE READ will fail, but a FILE WRITE will succeed (possibly
  2816.   creating a file with "holes").  If a FILE SEEK /BYTE command is given, the
  2817.   current line becomes unknown (unless the position is 0) and subsequent
  2818.   FILE SEEK /RELATIVE /LINE commands will fail until the next non-relative
  2819.   FILE SEEK /LINE command is given.  Synonym: FSEEK.
  2820.  
  2821. An absolute FILE SEEK to a negative position fails silently, as does a
  2822. relative seek to a position before the beginning of the file.
  2823.  
  2824. A caution about relative SEEKs: remember that the number is relative to the
  2825. current position.  Whenever you read or write, this changes the position.
  2826. In each of the following examples, assume the file open on channel \%c is
  2827. positioned at line "n" (the FREAD target variable is omitted for lack of
  2828. space):
  2829.  
  2830.   { FREAD \%c, FSEEK /LINE \%c -1, FREAD \%c }  <-- Reads line n twice
  2831.   { FREAD \%c, FSEEK /LINE \%c +0, FREAD \%c }  <-- Reads lines n and n+1
  2832.   { FREAD \%c, FSEEK /LINE \%c +1, FREAD \%c }  <-- Reads lines n and n+2
  2833.   { FREAD \%c, FSEEK /LINE \%c -2, FREAD \%c }  <-- Reads lines n and n-1
  2834.   { FREAD \%c, FSEEK /LINE \%c -3, FREAD \%c }  <-- Reads lines n and n-2
  2835.  
  2836. Another caution: Using FSEEK and FREAD /SIZE to repeatedly read the same disk
  2837. block (e.g. when sampling a database record that is frequently updated) might
  2838. not give you updated disk blocks due to the internal buffering and caching of
  2839. the C library (this probably varies from one platform/compiler combination to
  2840. another).  If necessary you can force a fresh disk read with a close/open
  2841. sequence:
  2842.  
  2843.   FCLOS \%c
  2844.   FOPEN \%c <samefilename>
  2845.   FSEEK \%c <samespot>
  2846.   FREAD /SIZE:<howmanybytes> \%c <variable>
  2847.  
  2848. 1.22.3. FILE Command Examples
  2849.  
  2850. To read the last 10 lines of a text file into an array:
  2851.  
  2852.   fopen /read \%c oofa.txt                ; Open the file
  2853.   if fail exit 1 Can't open oofa.txt      ; Always check for failure
  2854.   dcl \&a[10]                             ; Declare a 10-element array
  2855.   fcount /line \%c                        ; Count lines in the file
  2856.   fseek /line \%c \v(f_count)-10          ; Seek to 10 lines from the end
  2857.   if fail exit 1 Can't seek               ; Check for failure
  2858.   for \%i 1 10 1 { fread \%c \&a[\%i] }   ; Read the last 10 lines
  2859.   fclose \%c                              ; Close the file
  2860.  
  2861. Note that blank lines show up as empty (undefined) array elements, for example
  2862. if you give a "show array a" command at this point.  This is normal.  You
  2863. can still use these elements; e.g.:
  2864.  
  2865.   for \%i 1 10 1 { echo \%i. \&a[\%i] }   ; Display the 10 lines
  2866.  
  2867. Here is how to read the last line of a file (already open on channel \%c):
  2868.  
  2869.   fseek /line \%c last                    ; Seek directly to last line
  2870.  
  2871. Alternatively:
  2872.  
  2873.   fseek /line \%c eof                     ; Seek to end of file
  2874.   fseek /line \%c -1                      ; Seek to beginning of last line
  2875.  
  2876. Alternatively:
  2877.  
  2878.   fcount /line \%c                        ; Count the file's lines
  2879.   fseek /line \%c \v(f_count)-1           ; Seek to last line
  2880.   fread \%c                               ; Read it
  2881.  
  2882. To read every other line from the file (using relative SEEK), skipping
  2883. the first line:
  2884.  
  2885.   fopen /read \%c oofa.txt                ; Open the file
  2886.   while ( success ) {                     ; Loop through lines
  2887.       fseek /line \%c +1                  ; Skip a line
  2888.       if success fread \%c                ; Read & display a line
  2889.   }
  2890.   fclose \%c                              ; Close the file
  2891.  
  2892. Here is how to read the lines of a file in reverse order:
  2893.  
  2894.   fopen /read \%c oofa.txt                ; Open
  2895.   if fail exit 1                          ; Check
  2896.   fseek /line \%c last                    ; Seek to last line
  2897.   while success {                         ; Loop
  2898.       fread \%c                           ; Read line
  2899.       fseek /line \%c -2                  ; Seek backwards two lines
  2900.   }
  2901.   fclose \%c                              ; Close the file
  2902.  
  2903. The loop works because a relative SEEK outside the file fails.
  2904.  
  2905. It is also possible to use block i/o to manage random-access files with
  2906. fixed-length records (as long as they don't contain NUL characters).  Suppose,
  2907. for example, you have a file of "card image" records with fixed-field
  2908. information about customers, such as:
  2909.  
  2910.   Name:     Columns  1-32  (column numbers are 1-based)
  2911.   Address:  Columns 33-72
  2912.   Balance:  Columns 73-80
  2913.  
  2914. The records are indexed by customer number, starting with 0.  There are no
  2915. line terminators separating them.  Therefore the record for customer number
  2916. n starts at position n x 80 (\%n*80).
  2917.  
  2918. Now suppose we received a payment from customer number 173 and want to update
  2919. the balance:
  2920.  
  2921.   .\%n = 173                               ; Customer (record) number
  2922.   .\%a = 12.72                             ; Amount
  2923.   fopen /read /write \%c customer.db       ; Open the file
  2924.   if fail stop 1 OPEN FAILED: \f_errmsg()  ; Check
  2925.   fseek /byte \%c 80*\%n                   ; Seek to record
  2926.   fread /size:80 \%c r                     ; Read the record
  2927.   if fail stop 1 READ FAILED: \f_errmsg()  ; Check (IMPORTANT)
  2928.   .\%b := \fright(\m(r),8)                 ; Extract the balance
  2929.   .\%b := \ffpadd(\%b,\%a,2)               ; Add the new payment
  2930.   if fail stop 1 ARITHMETIC ERROR: \%b/\%a ; Catch bad records
  2931.   .r := {\fleft(\m(r),72)\flpad(\%b,8)}    ; Update the record
  2932.   fseek /byte \%c 80*\%n                   ; Reposition to same spot
  2933.   fwrite /size:80 \%c {\m(r)}              ; Replace the record
  2934.   if fail stop 1 WRITE FAILED: \f_errmsg() ; Check
  2935.   fclose \%c                               ; Close the file
  2936.  
  2937. REMEMBER: Using FILE SEEK to move beyond the end of file can result in a file
  2938. with holes when writing; when reading, an end-of-file error will occur --
  2939. be sure to check for it.
  2940.  
  2941. 1.22.4. Channel Numbers
  2942.  
  2943. C-Kermit's channel numbers are integers from 0 to some platform-dependent
  2944. limit, such as 46 or 1985 (the value of \v(f_max)).  This is the limit placed
  2945. by the operating system on the number of files that may be opened by one
  2946. process or user or job, minus the standard input, output, and error files, and
  2947. minus the number of files reserved by C-Kermit for logs, OPEN READ and WRITE,
  2948. and file transfer (and maybe some command files -- the \v(f_max) number can't
  2949. be exact).
  2950.  
  2951. Although you must include a variable in the FILE OPEN command, to which the
  2952. channel number is assigned, you don't have to use a variable in the other FILE
  2953. commands if you know what the number is -- you can just put the number.  This
  2954. saves you a few keystrokes when typing commands at the prompt:
  2955.  
  2956.   fopen \%c oofa.txt
  2957.   flist
  2958.   0. /usr/olga.oofa.txt (R) 0
  2959.  
  2960. This tells the channel number is 0 (the number on the left is the channel
  2961. file's channel number).  Of course you can also find it by echoing the
  2962. variable:
  2963.  
  2964.   echo \%c
  2965.   0
  2966.  
  2967. Or with "fstatus \%c".  Now you can type commands like:
  2968.  
  2969.   fread 0
  2970.  
  2971. to read a line from the file.  Obviously, however, using digits rather than
  2972. a variable for the channel number  would be poor practice in a script.
  2973.  
  2974. If in commands like:
  2975.  
  2976.   fread \%c \%a
  2977.  
  2978. you have trouble remembering which variable is which, note that the channel
  2979. number is, indeed, a number.  Anywhere C-Kermit accepts a number it can also
  2980. accept an expression, so you can put parentheses around the channel number to
  2981. remind you it's the channel number and not the variable into which data is to
  2982. be read:
  2983.  
  2984.   fread (\%c) \%a
  2985.  
  2986. Normally channel numbers are assigned sequentially as 0, 1, 2, ... up to the
  2987. limit.  However, once you start closing files, there can be holes in the
  2988. sequence.  New channels are assigned to fill in the holes.  Thus you can't
  2989. depend on channel numbers being in any particular sequence.
  2990.  
  2991. 1.22.5. FILE Command Errors
  2992.  
  2993. Each FILE command sets the variable \v(f_error) to one of the following values:
  2994.  
  2995.     0 = No error
  2996.    -1 = System error
  2997.    -2 = Attempt to read after end of file
  2998.    -3 = Channel not open
  2999.    -4 = Channel number out of range (negative or too large)
  3000.    -5 = Numeric argument (size, ...) out of range
  3001.    -6 = File not found
  3002.    -7 = Bad or missing filename
  3003.    -8 = Too many files are already open (FILE OPEN only)
  3004.    -9 = Forbidden operation (e.g. write to a read-only file)
  3005.   -10 = Access denied
  3006.   -11 = Illegal combination of OPEN modes (FILE OPEN only)
  3007.   -12 = Buffer overflow
  3008.   -13 = Current line number unknown (for relative line seeks)
  3009.   -14 through -98: Reserved.
  3010.   -99 = Requested operation not implemented in this version of C-Kermit
  3011.  -999 = Unknown error
  3012.  
  3013. When \v(f_error) is -1, this means the FILE command failed because because
  3014. of a system error, in which case you can examine the following variables:
  3015.  
  3016.   \v(errno)     = System error number.
  3017.   \v(errstring) = Error message corresponding to \v(errno).
  3018.  
  3019. A special function is available for translating the \v(f_error) code to an
  3020. error message string:
  3021.  
  3022. \f_errmsg([code])
  3023.   If the code is -1, returns error message of the most recent system
  3024.   error; otherwise if the code is a valid \v(f_error) value, the associated
  3025.   message is returned.  If the code is omitted, the status message
  3026.   corresponding to the current \v(f_error) value is returned.
  3027.  
  3028. A FILE command that fails prints the appropriate error message automatically,
  3029. except when the command is READ or SEEK and the error is -2 (end of file); in
  3030. that case, the command still fails, but does not print a message.  This allows
  3031. constructions such as:
  3032.  
  3033.   fopen \%c oofa.txt
  3034.   while success { fread \%c }
  3035.   fclose \%c
  3036.  
  3037. to work as expected, i.e. without an annoying message when the end of file
  3038. is reached.
  3039.  
  3040. 1.22.6. File I/O Variables
  3041.  
  3042. The variables associated with the file i/o package are:
  3043.  
  3044.   \v(f_count) - Result of the most recent FILE COUNT (FCOUNT) command.
  3045.   \v(f_error) - Numeric error code of most recent FILE command (0 = no error).
  3046.   \v(f_max)   - Maximum number of files open simultaneously.
  3047.  
  3048. 1.22.7. File I/O Functions
  3049.  
  3050. Some of the FILE commands can also be issued as function calls, which makes
  3051. script writing a bit more convenient, especially for C programmers.  Also,
  3052. several functions are provided that do not have command equivalents.  Each of
  3053. these functions takes a channel number as the first argument.  These functions
  3054. do not work for OPEN { READ, !READ, WRITE, !WRITE, and APPEND } files.
  3055.  
  3056. \f_status(channel)
  3057.   Returns 0 if the channel is not open, otherwise a number between 1 and 15
  3058.   which is the sum of the OPEN modes:
  3059.     1 = /READ
  3060.     2 = /WRITE
  3061.     4 = /APPEND
  3062.     8 = /BINARY
  3063.  
  3064. The remaining functions work only for open channels.  Each of these functions
  3065. can fail for the applicable reasons listed in Section 1.22.5.  For instructions
  3066. on handling function errors, see Section 7.12.
  3067.  
  3068. \f_pos(channel)
  3069.   Returns the file's current read/write pointer (0-based).  There is no FILE
  3070.   command equivalent.
  3071.  
  3072. \f_line(channel)
  3073.   Returns the file's current line number (0-based), if known, otherwise -1.
  3074.   There is no FILE command equivalent.  The line number is known as long as
  3075.   no character or block i/o has been done on the channel.
  3076.  
  3077. \f_handle(channel)
  3078.   Returns the "file handle" of the file.  That is, it translates the portable
  3079.   C-Kermit channel number into a system-specific file handle or number that
  3080.   can be passed to other programs on the same platform.  In UNIX this is a
  3081.   file descriptor.  There is no FILE command equivalent.
  3082.  
  3083. \f_eof(channel)
  3084.   Returns 1 if the read/write pointer of the file on the given channel is at
  3085.   the end of the file, 0 otherwise.  Convenient in WHILE statements, e.g.:
  3086.  
  3087.     while not \f_eof(\%c) { fread \%c }
  3088.  
  3089. \f_getchar(channel)
  3090.   Equivalent to FREAD /CHAR.  Returns the character actually read.
  3091.   If \f_getchar() does not fail but the return value is empty, this means
  3092.   a NULL character was read.
  3093.  
  3094. \f_getline(channel)
  3095.   Equivalent to FREAD /LINE.  Returns the line actually read, but with the line
  3096.   terminator stripped.  If \f_getline() does not fail but the return value is
  3097.   empty, this normally means an empty line was read.
  3098.  
  3099. \f_getblock(channel,n)
  3100.   Equivalent to FREAD /SIZE:n.  Returns the block of characters actually read.
  3101.   If the returned block is smaller than n, it indicates either that the end
  3102.   of file was reached or a NUL character is in the block.
  3103.  
  3104. \f_putchar(channel,c)
  3105.   Equivalent to FWRITE /CHARACTER.  Writes the character c.  If c contains
  3106.   more than one character, only the first is written.  If c is empty a NUL
  3107.   is written.  Returns the number of characters written on success, or a
  3108.   negative error code upon failure.
  3109.  
  3110. \f_putline(channel,string)
  3111.   Equivalent to FWRITE /LINE.  Writes the string and adds the appropriate line
  3112.   termination character or sequence.  If the string is empty or omitted, an
  3113.   empty line is written.  Returns the number of characters written on success,
  3114.   or a negative error code upon failure.
  3115.  
  3116. \f_putblock(channel,string)
  3117.   Equivalent to FWRITE /STRING.  Writes the string as given.  If the string is
  3118.   empty or omitted, nothing is written.  Returns the number of characters
  3119.   written on success, or a negative error code upon failure.
  3120.  
  3121. 1.22.8. File I/O Function Examples
  3122.  
  3123.   fopen /read \%c oofa.txt            ; Open our favorite file for reading
  3124.   if failure exit 1                   ; Check that it's open
  3125.   while not \f_eof(\%c) {             ; Loop until EOF
  3126.       .line := \f_getline(\%c)        ; Get a line
  3127.       if success echo {\m(line)}      ; Echo it
  3128.   }
  3129.   if not \f_eof(\%c) {                ; Check reason for loop exit
  3130.       exit 1 File Error: \f_errmsg()  ; If not EOF say so.
  3131.   }
  3132.  
  3133.   frewind \%c                         ; Rewind the file
  3134.   while not \f_eof(\%c) {             ; Same thing but with block i/o
  3135.       .block := \f_getblock(\%c,256)  ; (much faster than line i/o)
  3136.       if success xecho {\m(block)}
  3137.   }
  3138.  
  3139.   frewind \%c                         ; Rewind again
  3140.   while not \f_eof(\%c) {             ; Same deal but with character i/o
  3141.       .c := \f_getchar(\%c)           ; (much slower than line i/o)
  3142.       if success xecho {\m(c)}
  3143.   }
  3144.   close \%c
  3145.  
  3146. To close all open files (equivalent to FCLOSE ALL):
  3147.  
  3148.   for \%i 0 \v(f_max)-1 1 {
  3149.       if \f_status(\%i) fclose \%i
  3150.   }
  3151.  
  3152. 1.23. The EXEC Command
  3153.  
  3154. The EXEC command is available only in UNIX.
  3155.  
  3156. EXEC [ /REDIRECT ] <command> [ <arg1> [ <arg2> [ ... ] ]
  3157.   Runs the given command with the arguments in such a way that the <command>
  3158.   replaces C-Kermit in memory, and C-Kermit ceases to execute.  EXEC is like
  3159.   RUN, except instead of returning to C-Kermit when finished, the <command>
  3160.   returns to whatever process invoked Kermit.
  3161.  
  3162. In the normal case, no files are closed, so the EXEC'd command inherits the
  3163. open files, read/write pointers, working directory, process ID, user ID
  3164. (unless <command> is SUID), group ID (unless command is SGID), groups, etc.
  3165. (In UNIX, the EXEC command is simply a front end for execvp().)
  3166.  
  3167. If the /REDIRECT switch is included, then if a connection is open (SET LINE
  3168. or SET HOST), it becomes the standard input and output of the EXEC'd program.
  3169. If no connection is open, the /REDIRECT switch has no effect.  For example
  3170. to use C-Kermit for PPP dialing in Linux:
  3171.  
  3172.   set modem type usr          ; Specify the kind of modem you have
  3173.   set line /dev/ttyS1         ; Specify the device it's connected to
  3174.   set speed 57600             ; and the speed
  3175.   set flow rts/cts            ; and flow control.
  3176.   set dial retries 100        ; Try the dial sequence up to 100 times.
  3177.   dial {{9-212-555-1212}{9-212-555-1213}{9-212-555-1214}{9-212-555-1215}}
  3178.   if fail exit 1
  3179.   for \%i 1 16 1 {            ; Try up to 16 times to get login prompt
  3180.       input 10 Login:         ; Wait 10 sec for it to appear
  3181.       if success break        ; Got it - proceed...
  3182.       output \13              ; Send a carriage return and try again
  3183.   }
  3184.   if ( > \%i 16 ) stop 1 NO LOGIN PROMPT
  3185.   lineout \(myuserid)         ; Send user ID
  3186.   input 30 assword:           ; Wait for Password prompt
  3187.   if fail stop 1 NO PASSWORD PROMPT
  3188.   lineout \m(mypassword)      ; Send the password.
  3189.   exec /redirect pppd         ; Replace ourselves with pppd.
  3190.  
  3191. In this example we assume that the script has already set up the myuserid and
  3192. mypassword variables -- normally the password should be prompted for, rather
  3193. than stored on disk.  Notice the advantages over the well-known "chat script":
  3194.  
  3195.  . You don't have to control the modem itself with AT commands; Kermit's
  3196.    DIAL command does this for you.
  3197.  . You can have Kermit automatically redial as many times as you want
  3198.    until it gets a connection (if this is legal in your country).
  3199.  . You can have Kermit fetch the number or numbers from a dialing directory.
  3200.  . You can have Kermit cycle through a list of phone numbers (this is new
  3201.    to C-Kermit 7.0; see Section 2.1.16) without having to enter the numbers
  3202.    in a dialing directory.
  3203.  . Dialing is location-independent; you can use the same script to dial from
  3204.    different areas or countries.
  3205.  . Once the connection is made, the full power of Kermit's script language
  3206.    is available to manage the dialog with the terminal server or other
  3207.    device that answers the phone call.
  3208.  
  3209. 1.24. Getting Keyword Lists with '?'
  3210.  
  3211. Suppose you type "te" at the C-Kermit> prompt and then Esc or Tab to request
  3212. keyword completion.  Kermit beeps, indicating that more than one command
  3213. starts with "te".  But if you type '?'  to see what they are, Kermit shows
  3214. only "telnet".  So why the beep?  Because of invisible keywords like "telopt",
  3215. "terminal", and "text".  Lots of keywords are invisible because they are
  3216. either synonyms for other keywords or else esoteric options to be used only
  3217. in special circumstances, so we don't want them cluttering up the menus.
  3218.  
  3219. But then there is no way for you to discover them.  So in C-Kermit 7.0, if you
  3220. type '?' AFTER the beginning of a keyword field, then invisible keywords are
  3221. shown too:
  3222.  
  3223.   C-Kermit>te<Esc><BEEP>
  3224.   C-Kermit>te? Command, one of the following:
  3225.    telnet    telopt    terminal  text
  3226.   C-Kermit>te
  3227.  
  3228. But if '?' is typed at the beginning of a field, only visible keywords are
  3229. shown, as before (so, in this example, if '?' is typed at the C-Kermit>
  3230. prompt, "telnet" is the only command shown that starts with "te").
  3231.  
  3232.  
  3233. (2) MAKING AND USING CONNECTIONS
  3234.  
  3235. The SET LINE, SET HOST, and SET PORT (a synonym for SET LINE) commands have
  3236. new synonyms, in which the word SET is replaced by the word OPEN: OPEN LINE,
  3237. etc.  There is no new functionality here, but OPEN is a better verb, since SET
  3238. generally takes no action, whereas these commands actually try to open a
  3239. connection.  Furthermore, there is the symmetry with CLOSE.
  3240.  
  3241. 2.0. SET LINE and SET HOST Command Switches
  3242.  
  3243. The SET LINE (SET PORT) and SET HOST commands now allow switches before the
  3244. device or host name, in most cases, and under certain circumstances, also at
  3245. the end.  The new syntax is backwards compatible with the previous syntax;
  3246. thus SET LINE, SET PORT, and SET HOST commands in command files written for
  3247. C-Kermit 6.0 or earlier still work.  The expanded syntax is:
  3248.  
  3249.  { OPEN,SET } { LINE,PORT,HOST } [ switches ] <device-or-address> [ switches ]
  3250.  
  3251. The first group of switches is:
  3252.  
  3253. /NETWORK-TYPE:{TCP/IP,X.25,PIPE,PTY...}
  3254.   When more than one network type is available, this lets you specify the
  3255.   type of network to use for this connection without affecting your global
  3256.   SET NETWORK TYPE.  See Section 2.7 about pipes and ptys.
  3257.  
  3258. /USERID:[string]
  3259.   This switch is equivalent to SET LOGIN USERID.  If a string is given, it
  3260.   sent to host during Telnet negotiations; if this switch is given but the
  3261.   string is omitted, no user ID is sent to the host.  If this switch is not
  3262.   given, your current LOGIN USERID (\v(userid) value), if any, is sent.
  3263.   Unlike most other switches, this one is "sticky", since the value must
  3264.   persist throughout the session in case the server requests the ID string
  3265.   at a later time.
  3266.  
  3267. /CONNECT
  3268.   Enter CONNECT mode immediately and automatically after the device or
  3269.   connection is open.  On serial devices, however, when CARRIER-WATCH is
  3270.   not OFF, wait up to 1 second for the Carrier Detect signal to appear
  3271.   before trying to connect, to give the device time to react DTR, which
  3272.   might have been off prior to opening the device.
  3273.  
  3274. /SERVER
  3275.   Enter server mode immediately and automatically after the device or
  3276.   connection is open.  Treatment of carrier is the same as for /CONNECT.
  3277.  
  3278. /WAIT
  3279. /NOWAIT
  3280.   For Telnet connections only: Like SET TELNET WAIT { ON, OFF }, but applies
  3281.   only to this connection, and in fact applies only when OPENing this
  3282.   connection (which is usually the only place it matters).  Typically you
  3283.   would use TELNET /NOWAIT to make a connection to a misbehaving Telnet
  3284.   server that does not reply to negotiations as required by the Telnet
  3285.   protocol definition.
  3286.  
  3287. Note: /CONNECT and /SERVER switches are not available in the RLOGIN and TELNET
  3288. commands, since these commands already include an implicit /CONNECT and
  3289. preclude automatic entry into server mode.
  3290.  
  3291. The /CONNECT and /SERVER switches are especially useful with "set host *"
  3292. connections.  For example, suppose you want to start a Kermit server on socket
  3293. 3000 of your TCP host.  Normally you would have to give the command:
  3294.  
  3295.   set host * 3000
  3296.  
  3297. and then wait for a connection to come in, and only then could you give the
  3298. SERVER command (or else define a macro to do this, and then execute the macro).
  3299. Now you can do it in one step:
  3300.  
  3301.   set host /server * 3000
  3302.  
  3303. This tells C-Kermit to wait for the connection and then enter server mode
  3304. once it comes in, no matter how long it takes.  Similarly, "set host /conn *"
  3305. can be used to wait for a "chat" connection to come in.
  3306.  
  3307. Another set of switches is available in VMS only, for use only with SET LINE:
  3308.  
  3309. /SHARE
  3310.   Allows the SET LINE device to be opened in shared mode.  Normally it makes
  3311.   no sense to open a serial device in shared mode, but it's necessary when
  3312.   C-Kermit is running in an environment such as DECIntact, that opens your
  3313.   job's controlling terminal in such a way that C-Kermit can't open it too,
  3314.   unless it enables SHARE privilege.  Note: SHARE privilege is required.
  3315.  
  3316. /NOSHARE
  3317.   Requires that the SET LINE device not be in use by any other process in
  3318.   order for it to be successfully opened by C-Kermit.  If neither /SHARE nor
  3319.   /NOSHARE is specified, /NOSHARE is used.
  3320.  
  3321. The second group of switches is:
  3322.  
  3323. /NO-TELNET-INIT
  3324.   Do not send initial Telnet negotiations even if this is a Telnet port.
  3325.  
  3326. /RAW-SOCKET
  3327.   This is a connection to a raw TCP socket (Section 2.3.5).
  3328.  
  3329. /RLOGIN
  3330.   Use Rlogin protocol even if this is not an Rlogin port.
  3331.  
  3332. /TELNET
  3333.   Send initial Telnet negotiations even if this is not a Telnet port.
  3334.  
  3335. As of C-Kermit 7.0 and K95 1.1.18, the TELNET command includes an implicit
  3336. /TELNET switch.  So if you TELNET to a non-TELNET port, Kermit sends initial
  3337. Telnet negotiations.  This makes sense, since that's what "telnet" means.
  3338.  
  3339. If you want to make a connection to a non-Telnet port without sending initial
  3340. Telnet negotiations, use:
  3341.  
  3342.   set host [ /connect ] <name-or-address> <port>
  3343.  
  3344. or:
  3345.  
  3346.   telnet <name-or-address> <port> /no-telnet-init
  3347.  
  3348. Additional switches might be added in the future; type "set host ?" or "set
  3349. line ?" to see a current list.
  3350.  
  3351. 2.1. Dialing
  3352.  
  3353. Automatic redialing is illegal or restricted in many countries, so until
  3354. C-Kermit 7.0, it was disabled by default, i.e. until a SET DIAL RETRIES
  3355. command was given.  In C-Kermit 7.0, if no SET DIAL RETRIES command has been
  3356. given, a default is picked dynamically at DIAL time based on the calling
  3357. country code, if known.  At this writing, the only country code known to have
  3358. no restrictions on automatic redialing is 1.  So in this case a limit of 10
  3359. is chosen; otherwise 1.  If you have not given an explicit SET DIAL RETRIES
  3360. command, SHOW DIAL shows the value as "(auto)", and then the value actually
  3361. used is shown when you give the DIAL command.
  3362.  
  3363. As of C-Kermit 7.0, automatic redialing is automatically canceled if the
  3364. call could not be placed because no dialtone was detected.
  3365.  
  3366. 2.1.1. The Dial Result Message
  3367.  
  3368. If DIAL DISPLAY is not ON, the "Call complete" message now shows the modem's
  3369. call result message, for example:
  3370.  
  3371.   Dialing: ...
  3372.   Call complete: "CONNECT 31200/ARQ/V32/LAPM/V42BIS"
  3373.  
  3374. The exact format and contents of this message, of course, depends on the
  3375. make, model, and configuration of your modem, so use your modem manual to
  3376. interpret it.  The call result message is also available in C-Kermit's
  3377. \v(dialresult) variable.
  3378.  
  3379.   C-Kermit> echo \v(dialresult)
  3380.   CONNECT 31200/ARQ/V32/LAPM/V42BIS
  3381.   C-Kermit> echo Speed = \fword(\v(dialresult),2)
  3382.   Speed = 31200
  3383.   C-Kermit>
  3384.  
  3385. Suppose your modem reports the modulation speed as shown above and you want to
  3386. ensure your call is completed at (say) 24000 bps or more.  You can use a
  3387. little macro to do the job:
  3388.  
  3389. define HSDIAL {                ; High Speed DIAL
  3390.     local \%s
  3391.     if < \v(argc) 1 if not def \v(dialnumber) end 1 Usage: \%0 number
  3392.     set dial retries 100
  3393.     set dial interval 1
  3394.     while true {
  3395.     dial \%*
  3396.     if fail end 1 DIAL failed.
  3397.     asg \%s \fword(\v(dialresult),2)
  3398.     if def \%s if numeric \%s if not < \%s 24000 break
  3399.     }
  3400. }
  3401.  
  3402. (See section 7.5 about the \%* variable.)
  3403.  
  3404. 2.1.2. Long-Distance Dialing Changes
  3405.  
  3406. Due to the glut of cell phones, pagers, fax machines, ISPs, etc, area codes
  3407. and dialing rules are changing all the time.  In the North American Numbering
  3408. Plan (NANP) countries (USA, Canada, etc), area codes are split or overlayed
  3409. with increasing frequency, and 10- and 11-digit dialing is gradually becoming
  3410. the norm for local calls.  Changes are occurring In Europe, too, partly for
  3411. these reasons and partly because of some new EC rules.
  3412.  
  3413. In France, effective 18 October 1996, all calls, even local ones, must be
  3414. dialed with an area code.  French area codes are presently 1-digit numbers,
  3415. 1-6, and the long-distance dialing prefix is 0.  All calls within France are
  3416. considered long distance and begin with 01, 02, ..., 06.
  3417.  
  3418. Effective 1 May 1997, all calls within the US state of Maryland, even local
  3419. ones, must be dialed with an area code but WITHOUT the long-distance prefix --
  3420. this is the now widely-known North American phenomenon of "ten digit dialing".
  3421. The same is happening elsewhere -- many cities in Florida adopted 10-digit
  3422. dialing in 1998.
  3423.  
  3424. In Italy beginning 19 June 1998, all calls to fixed (as opposed to mobile)
  3425. numbers must be prefixed by 0.  When calling into Italy from outside, the 0
  3426. must follow the country code (39).  Calls to cell phones, however, must be
  3427. placed without the 0.  Then on 29 December 2000, the 0 will become a 4 (for
  3428. calling fixed numbers) and a prefix of 3 must used for calling mobile phones.
  3429. More info at: http://www.telecomitalia.it/npnn/.
  3430.  
  3431. In Spain, effective 4 April 1998, with hard cutover on 18 July 1998, all
  3432. calls within the country must be dialed with 9 digits, and all calls from
  3433. outside Spain must also be dialed with 9 digits (after the country code, 34).
  3434. The new 9-digit numbers all begin with "9".  More info at:
  3435. http://www.telefonica.es/cambiodenumeracion/
  3436.  
  3437. Several new dialing features and commands have been added in version 6.1 and
  3438. 7.0 to address these changes.
  3439.  
  3440. C-Kermit 6.0 and Kermit 95 1.1.11 and earlier handle the French situation
  3441. via a reasonable subterfuge (setting the local area code to a nonexistent
  3442. one), but did not handle "ten-digit dialing" well at all; the recommended
  3443. technique was to change the long-distance dialing prefix to nothing, but this
  3444. defeated Kermit's "list numbers for one name" feature when the numbers were in
  3445. different locations.  For example:
  3446.  
  3447.   set dial ld-prefix
  3448.   dial onlineservice
  3449.  
  3450. where "onlineservice" is a dialing directory entry name corresponding to
  3451. entries that are in (say) Maryland as well as other states, would not
  3452. correctly dial the numbers not in Maryland.
  3453.  
  3454. A new command lets you specify a list of area codes to be considered local,
  3455. except that the area code must be dialed:
  3456.  
  3457.   SET DIAL LC-AREA-CODES [ areacode [ areacode [ areacode [ ... ] ] ] ]
  3458.  
  3459. The list may include up to 32 area codes.  If a number is called whose area
  3460. code is in this list, it is dialed WITHOUT the long-distance prefix, but WITH
  3461. the area code.  So in Maryland, which (last time we looked) has two area
  3462. codes, 410 and 301, the setup would be:
  3463.  
  3464.   SET DIAL LC-AREA-CODES 410 301
  3465.  
  3466. Example:
  3467.  
  3468.   SET DIAL LD-PREFIX 1
  3469.   SET DIAL AREA-CODE 301
  3470.   SET DIAL LC-AREA-CODES 410 301 <-- Area codes in 10-digit dialing region
  3471.   DIAL +1 (301) 765-4321         <-- Dials 3017654321  (local with area code)
  3472.   DIAL +1 (410) 765-4321         <-- Dials 4107654321  (local with area code)
  3473.   DIAL +1 (212) 765-4321         <-- Dials 12127654321 (long distance)
  3474.  
  3475. The SET DIAL LC-AREA-CODES command does not replace the SET DIAL AREA-CODE
  3476. command.  The latter specifies the area code you are dialing from.  If the
  3477. called number is in the same area code, then the area code is dialed if it is
  3478. also in the LC-AREA-CODES list, and it is not dialed otherwise.  So if "301"
  3479. had not appeared in the LC-AREA-CODES list in the previous example:
  3480.  
  3481.   SET DIAL LD-PREFIX 1
  3482.   SET DIAL AREA-CODE 301
  3483.   SET DIAL LC-AREA-CODES 410     <-- Area codes in 10-digit dialing region
  3484.   DIAL +1 (301) 765-4321         <-- Dials 7654321     (local)
  3485.   DIAL +1 (410) 765-4321         <-- Dials 4107654321  (local with area code)
  3486.   DIAL +1 (212) 765-4321         <-- Dials 12127654321 (long distance)
  3487.  
  3488. The new Kermit versions also add a Local Call Prefix and Local Call Suffix, in
  3489. case you have any need for it.  These are added to the beginning and of local
  3490. phone numbers (i.e. numbers that are not long-distance or international).
  3491. Examples:
  3492.  
  3493.   SET DIAL LD-PREFIX 1
  3494.   SET DIAL LC-PREFIX 9
  3495.   SET DIAL LC-SUFFIX *
  3496.   SET DIAL LC-AREA-CODES 410     <-- Area codes in 10-digit dialing region
  3497.   SET DIAL AREA-CODE 301
  3498.   DIAL +1 (301) 765-4321         <-- Dials 97654321*     (local)
  3499.   DIAL +1 (410) 765-4321         <-- Dials 94107654321*  (local with area code)
  3500.   DIAL +1 (212) 765-4321         <-- Dials 12127654321   (long distance)
  3501.  
  3502. 2.1.3. Forcing Long-Distance Dialing
  3503.  
  3504. Suppose a number is in your country and area, but for some reason you need to
  3505. dial it long-distance anyway (as is always the case in France).  There have
  3506. always been various ways to handle this:
  3507.  
  3508.  1. Temporarily set your area code to a different (or nonexistent or
  3509.     impossible) one (but this required knowledge of which area codes were
  3510.     nonexistent or impossible in each country).
  3511.  
  3512.  2. Dial the number literally instead of using the portable format, but this
  3513.     defeats the purpose of the portable dialing directory.
  3514.  
  3515. Now there is also a new command that, very simply, can force long-distance
  3516. dialing:
  3517.  
  3518. SET DIAL FORCE-LONG-DISTANCE { ON, OFF }
  3519.   If a call is placed to a portable phone number within the same country
  3520.   code as the calling number, it is dialed with the long-distance prefix
  3521.   and the area code if FORCE-LONG-DISTANCE is ON.  If OFF, the regular
  3522.   rules and procedures apply.
  3523.  
  3524. Example (France):
  3525.  
  3526.   SET DIAL COUNTRY-CODE 33
  3527.   SET DIAL AREA-CODE 6
  3528.   SET DIAL FORCE-LONG-DISTANCE ON
  3529.  
  3530. (In fact, SET DIAL COUNTRY-CODE 33 automatically sets DIAL FORCE-LONG-DISTANCE
  3531. ON...)
  3532.  
  3533. Example (USA, for a certain type of reverse-charge calling in which the
  3534. called number must always be fully specified):
  3535.  
  3536.   SET DIAL PREFIX 18002666328$     ; 1-800-COLLECT
  3537.   SET DIAL COUNTRY-CODE 1
  3538.   SET DIAL AREA-CODE 212
  3539.   SET DIAL FORCE-LONG-DISTANCE ON
  3540.  
  3541. Example (Toronto, where calls to exchange 976 within area code 416 must be
  3542. dialed as long distance, even when you are dialing from area code 416):
  3543.  
  3544.   SET DIAL COUNTRY-CODE 1
  3545.   SET DIAL AREA-CODE 416
  3546.   SET DIAL FORCE-LONG-DISTANCE ON
  3547.   DIAL +1 (416) 976-xxxx
  3548.  
  3549. If dialing methods were consistent and sensible, of course it would be
  3550. possible to always dial every domestic call as if it were long distance.  But
  3551. in many locations this doesn't work or if it does, it costs extra.  The
  3552. following macro can be used for dialing any given number with forced
  3553. long-distance format:
  3554.  
  3555.   define LDIAL {
  3556.       local \%x
  3557.       set dial force-long-distance on
  3558.       dial \%*
  3559.       asg \%x \v(success)
  3560.       set dial force-long-distance off
  3561.       end \%x
  3562.   }
  3563.  
  3564. (See section 7.5 about the \%* variable.)
  3565.  
  3566. 2.1.4. Exchange-Specific Dialing Decisions
  3567.  
  3568. This applies mainly to the North American Numbering Plan (NANP).  Refer to the
  3569. section "Alternative notations" in "Using C-Kermit" 2nd Edition, pages
  3570. 106-107, and the story about Toronto on page 110.  Using the new LC-AREA-CODES
  3571. list, we can address the problem by treating the exchange as part of the area
  3572. code:
  3573.  
  3574.   SET DIAL LD-PREFIX 1
  3575.   SET DIAL AREA-CODE 416
  3576.   SET DIAL LC-AREA-CODES 905276
  3577.   DIAL +1 416 765 4321               <-- 7654321      (local)
  3578.   DIAL +1 905 276 4321               <-- 9052764321   (local with area code)
  3579.   DIAL +1 905 528 4321               <-- 19055284321  (long distance)
  3580.  
  3581. The same technique can be used in Massachusetts (story at top of page 111)
  3582. and in any other place where dialing to some exchanges within a particular
  3583. area code is local, but to others in the same area code is long distance.
  3584.  
  3585. 2.1.5. Cautions about Cheapest-First Dialing
  3586.  
  3587. Kermit does not maintain a knowledge base of telephony information; it only
  3588. provides the tools to let you enter a phone number in a standard format and
  3589. dial it correctly from any location in most cases.
  3590.  
  3591. In particular, Kermit does not differentiate the charging method from the
  3592. dialing method.  If a call that is DIALED as long-distance (e.g. from 212 to
  3593. 718 in country code 1) is not CHARGED as long distance, we have no way of
  3594. knowing that without keeping a matrix of charging information for every
  3595. area-code combination within every country, and any such matrix would be
  3596. obsolete five minutes after it was constructed.  Thus, "cheapest-first"
  3597. sorting is only as reliable as our assumption that the charging method follows
  3598. the dialing method.  A good illustration would be certain online services that
  3599. have toll-free dialup numbers which they charge you a premium (in your online
  3600. service bill) for using.
  3601.  
  3602. 2.1.6. Blind Dialing (Dialing with No Dialtone)
  3603.  
  3604. C-Kermit's init string for Hayes-like modems generally includes an X4 command
  3605. to enable as many result codes as possible, so that Kermit can react
  3606. appropriately to different failure reasons.  One of the result codes that X4
  3607. enables is "NO DIALTONE".  A perhaps not obvious side effect of enabling this
  3608. result code that the modem must hear dialtone before it will dial.
  3609.  
  3610. It is becoming increasingly necessary to force a modem to dial even though it
  3611. does not hear a dialtone on the phone line; for example, with PBXs that have
  3612. strange dialtones, or with phone systems in different countries, or with ISDN
  3613. phones, etc.  This is called "blind dialing".
  3614.  
  3615. C-Kermit 7.0 has two new commands to cope with this situation:
  3616.  
  3617. SET DIAL IGNORE-DIALTONE { ON, OFF }
  3618.   OFF (the default) means to tell the modem to wait for dialtone before
  3619.   dialing.  ON means to enable "blind dialing", i.e. tell the modem NOT
  3620.   to wait for dialtone before dialing.  Generally this is accomplished by
  3621.   sending ATX3 to the modem just prior to dialing.  SET MODEM TYPE xxx
  3622.   and then SHOW MODEM displays Kermit's built-in "ignore dialtone" command.
  3623.  
  3624. SET DIAL COMMAND IGNORE-DIALTONE <text>
  3625.   This lets you change the built-in ignore-dialtone command (such as ATX3)
  3626.   to whatever you choose, in case the built-in one does not work, or another
  3627.   command works better.
  3628.  
  3629. Notes:
  3630.  
  3631.  1. The ignore-dialtone command is not sent unless SET DIAL IGNORE-DIALTONE
  3632.     is ON.
  3633.  
  3634.  2. The ATX3 command generally disables not only NO DIALTONE, but also BUSY.
  3635.     So this will prevent Kermit from detecting when the line is busy.  This
  3636.     is a property of the modem, not of Kermit.
  3637.  
  3638. 2.1.7. Trimming the Dialing Dialog
  3639.  
  3640. The command:
  3641.  
  3642.   SET MODEM COMMAND <action> [ <command> ]
  3643.  
  3644. is used to override Kermit's built-in modem commands for each action, for
  3645. each kind of modem in its internal database.  If you include a <command>,
  3646. this is used instead of the built-in one.  If you omit the <command>, this
  3647. restores the original built-in command.
  3648.  
  3649. If you want to omit the command altogether, so Kermit doesn't send the command
  3650. at all, or wait for a response, use:
  3651.  
  3652.   SET MODEM COMMAND <action> {}
  3653.  
  3654. That is, specify a pair of empty braces as the command, for example:
  3655.  
  3656.   SET MODEM COMMAND ERROR-CORRECTION ON {}
  3657.  
  3658. 2.1.8. Controlling the Dialing Speed
  3659.  
  3660. The rate at which characters are sent to the modem during dialing is normally
  3661. controlled by the built-in modem database.  You might want to override this
  3662. if Kermit seems to be dialing too slowly, or it is sending characters to the
  3663. modem faster than the modem handle them.  A new command was added for this
  3664. in C-Kermit 7.0:
  3665.  
  3666. SET DIAL PACING <number>
  3667.   Specifies the number of milliseconds (thousandths of seconds) to pause
  3668.   between each character when sending commands to the modem during DIAL or
  3669.   ANSWER command execution.  0 means no pause at all, -1 (the default) or any
  3670.   other negative number means to use the value from the database.  Any number
  3671.   greater than 0 is the number of milliseconds to pause.
  3672.  
  3673. HINT: You might also need to control the rate at which the modem generates
  3674. Touch Tones during dialing, for example when sending a numeric page.  There
  3675. are two ways to do this.  One way is to insert pause characters into the
  3676. dialing string.  For modems that use the AT command set, the pause character
  3677. is comma (,) and causes a 2-second pause.  On most modems, you can use the S8
  3678. register to change the pause interval caused by comma in the dialing string.
  3679. The other way is to set your modem's tone generation interval, if it has a
  3680. command for that.  Most AT-command-set modems use S11 for this; the value is
  3681. in milliseconds.  For example on USR modems:
  3682.  
  3683.   ATS11=200
  3684.  
  3685. selects an interval of 200 milliseconds to separate each dialing tone.
  3686.  
  3687. Hint: To add S-Register settings or other commands to your dialing procedure,
  3688. use the new SET MODEM COMMAND PREDIAL-INIT command (Section 2.2.2).
  3689.  
  3690. 2.1.9. Pretesting Phone Number Conversions
  3691.  
  3692. The LOOKUP command now accepts telephone numbers as well as directory-entry
  3693. names, for example:
  3694.  
  3695.   LOOKUP +1 (212) 7654321
  3696.  
  3697. When given a phone number, LOOKUP prints the result of converting the phone
  3698. number for dialing under the current dialing rules.  For example, if my
  3699. country code is 1 and my area code is 212, and I am dialing out from a PBX
  3700. whose outside-line prefix is "93,":
  3701.  
  3702.   C-Kermit> lookup +1 (212) 7654321
  3703.   +1 (212) 7654321 => 93,7654321
  3704.   C-Kermit>
  3705.  
  3706. You can also use the \fdialconvert(phone-number) function (Section 2.1.11)
  3707. to do this programmatically:
  3708.  
  3709.   C-Kermit> echo "\fdialconvert(+1 (212) 7654321)"
  3710.   "93,7654321"
  3711.   C-Kermit>
  3712.  
  3713. So the new LOOKUP behaves as follows:
  3714.  
  3715. LOOKUP <portable-format-phone-number>
  3716.   Displays how the number would actually be dialed
  3717.   Sets FAILURE if there was a conversion error, otherwise SUCCESS.
  3718.  
  3719. LOOKUP <literal-format-phone-number>
  3720.   Displays the same <literal-format-phone-number>
  3721.   Always sets SUCCESS.
  3722.  
  3723. LOOKUP <dialing-directory-name>
  3724.   Displays all matching entries and converts portable phone numbers.
  3725.   Sets SUCCESS if at least one entry was found, otherwise FAILURE.
  3726.  
  3727. LOOKUP =anything
  3728.   Displays "=anything" and sets SUCCESS.
  3729.  
  3730. There is, at present, no programmatic way to fetch numbers from the dialing
  3731. directory.  This will be considered for a future release.
  3732.  
  3733. 2.1.10. Greater Control over Partial Dialing
  3734.  
  3735. The following rules now apply to partial dialing:
  3736.  
  3737.  . Phone number transformations based on country and area code,
  3738.    application of prefixes, etc, are performed only on the first PDIAL.
  3739.  
  3740.  . Each PDIAL argument is looked up in the dialing directory, so it is
  3741.    possible have directory entries for pieces of phone numbers or other
  3742.    information.
  3743.  
  3744.  . Suffixes are not applied automatically, since there is no way for C-Kermit
  3745.    to know in which PDIAL segment you want them to be applied.
  3746.  
  3747. However, the suffix that *would* have been applied, based on the dialing rules
  3748. that were invoked when processing the first PDIAL command, is stored in the
  3749. variable:
  3750.  
  3751.   \v(dialsuffix)
  3752.  
  3753. which you can include in any subsequent PDIAL or DIAL commands.
  3754.  
  3755. Example:
  3756.  
  3757.   pdial {\m(my_long_distance_pager_number_part_1)}
  3758.   pdial {\m(my_long_distance_pager_number_part_2)}
  3759.   pdial {\v(dialsuffix)}
  3760.   pdial {\m(my_long_distance_pager_number_part_3)}
  3761.   pdial {@\m(numeric_pager_code)#}
  3762.  
  3763. 2.1.11. New DIAL-related Variables and Functions
  3764.  
  3765. \fdialconvert(s)
  3766.   s is a phone number in either literal or portable format (not a dialing
  3767.   directory entry name).  The function returns the dial string that would
  3768.   actually be used by the DIAL command when dialing from the current location,
  3769.   after processing country code, area code, and other SET DIAL values, and
  3770.   should be the same as the result of LOOKUP when given a telephone number.
  3771.  
  3772. \v(dialsuffix)
  3773.   Contains the suffix, if any, that was applied in the most recent DIAL
  3774.   command, or the suffix that would have been applied in the most recent PDIAL
  3775.   command.  Use this variable to send the dial suffix at any desired point in
  3776.   a PDIAL sequence.
  3777.  
  3778. \v(dialtype)
  3779.   A number indicating the type of call that was most recently placed.  Can
  3780.   be used after a normal DIAL command, or after the first PDIAL command in
  3781.   a PDIAL sequence.  Values are:
  3782.  
  3783.     -2: Unknown because TAPI handled the phone number translation.
  3784.     -1: Unknown because some kind of error occured.
  3785.      0: Internal within PBX.
  3786.      1: Toll-free.
  3787.      2: Local within calling area.
  3788.      3: Unknown (e.g. because a literal-format phone number was given).
  3789.      4: Long distance within country.
  3790.      5: International
  3791.  
  3792. \v(dialcount)
  3793.   The current value of the DIAL retry counter, for use in a DIAL macro
  3794.   (Section 2.1.13).
  3795.  
  3796. \v(d$px)
  3797.   PBX Exchange (see Section 2.1.12).
  3798.  
  3799. Other dial-related variables, already documented in "Using C-Kermit" (or
  3800. other sections of this document, e.g. 2.1.1), include \v(dialnumber),
  3801. \v(dialstatus), etc.  A convenient way to display all of them is:
  3802.  
  3803.   show variable dial  ; hint: abbreviate "sho var dial"
  3804.  
  3805. This shows the values of all the variables whose names start with "dial".
  3806. Also "show variable d$" (to show the \v(d$...) variables).
  3807.  
  3808. 2.1.12. Increased Flexibility of PBX Dialing
  3809.  
  3810. Refer to "Using C-Kermit", 2nd Edition, pages 107-108.  Recall that three
  3811. commands are needed to configure C-Kermit for dialing from a PBX:
  3812.  
  3813.   SET DIAL PBX-EXCHANGE <number>
  3814.   SET DIAL PBX-INSIDE-PREFIX <number>
  3815.   SET DIAL PBX-OUTSIDE-PREFIX <number>
  3816.  
  3817. Unfortunately, this model does not accommodate PBXs that have more than one
  3818. exchange.  For example our PBX at Columbia University (which must handle more
  3819. than 10,000 phones) has 853-xxxx and 854-xxxx exchanges.
  3820.  
  3821. Beginning in C-Kermit 7.0, the SET DIAL PBX-EXCHANGE command accepts a list of
  3822. exchanges, e.g.:
  3823.  
  3824.   SET DIAL PBX-EXCHANGE 853 854
  3825.  
  3826. (multiple exchanges are separated by spaces, not commas).
  3827.  
  3828. So now when dialing a portable-format number that has the same country and
  3829. area codes as those of your dialing location, C-Kermit compares the exchange
  3830. of the dialed number with each number in the PBX Exchange list (rather than
  3831. with a single PBX Exchange number, as it did formerly) to determine whether
  3832. this is an internal PBX number or an external call.  If it is an external
  3833. call, then the PBX Outside Prefix is applied, and then the normal dialing
  3834. rules for local or long-distance calls.
  3835.  
  3836. If it is an inside call, the exchange is replaced by the PBX Inside Prefix.
  3837. But if the PBX has more than one exchange, a single fixed PBX Inside Prefix is
  3838. probably not sufficient.  For example, at Columbia University, we must dial
  3839. 3-xxxx for an internal call to 853-xxxx, but 4-xxxx for a call to 854-xxxx.
  3840. That is, the inside prefix is the final digit of the exchange we are dialing.
  3841. For this reason, C-Kermit 7.0 provides a method to determine the inside prefix
  3842. dynamically at dialing time, consisting of a new variable and new syntax for
  3843. the SET DIAL PBX-INSIDE-PREFIX command:
  3844.  
  3845. \v(d$px)
  3846.   This variable contains the exchange that was matched when a PBX internal
  3847.   call was detected.  For example, if the PBX exchange list is "853 854"
  3848.   and a call is placed to +1 (212) 854-9999, \v(d$px) is set to 854.
  3849.  
  3850. SET DIAL PBX-INSIDE-PREFIX \fxxx(...)
  3851.   If the PBX Inside Prefix is defined to be a function, its evaluation is
  3852.   deferred until dialing time.  Normally, this would be a string function
  3853.   having \v(d$px) as an operand.  Of course, you can still specify a constant
  3854.   string, as before.
  3855.  
  3856. So given the following setup:
  3857.  
  3858.   SET DIAL COUNTRY-CODE 1
  3859.   SET DIAL AREA-CODE 212
  3860.   SET DIAL PBX-OUTSIDE-PREFIX 93,
  3861.   SET DIAL PBX-EXCHANGE 853 854
  3862.   SET DIAL PBX-INSIDE-PREFIX \fright(\v(d$px),1)
  3863.  
  3864. The following numbers give the results indicated:
  3865.  
  3866.  Number                   Result
  3867.   +1 (212) 854-9876        4-9876
  3868.   +1 (212) 853-1234        3-1234
  3869.   +1 (212) 765-4321        93,765-4321
  3870.   +1 (333) 765-4321        93,1333765-4321
  3871.  
  3872. Furthermore, the K_PBX_XCH environment variable may now be set to a list of
  3873. exchanges to automatically initialize C-Kermit's PBX exchange list, for
  3874. example (in UNIX ksh or bash):
  3875.  
  3876.   export K_PBX_XCH="853 854"
  3877.  
  3878. (Quotes required because of the space.)  Of course, this variable can also be
  3879. set to a single exchange, as before:
  3880.  
  3881.   export K_PBX_XCH=853
  3882.  
  3883. 2.1.13. The DIAL macro - Last-Minute Phone Number Conversions
  3884.  
  3885. After a DIAL or LOOKUP command is given, a list of phone numbers is assembled
  3886. from the dialing directory (if any), with all location-dependent conversion
  3887. rules applied as described in Chapter 5 of "Using C-Kermit".
  3888.  
  3889. However, additional conversions might still be required at the last minute
  3890. based on local or ephemeral conditions.  So that you can have the final word
  3891. on the exact format of the dial string, C-Kermit 7.0 lets you pass the
  3892. converted string through a macro of your own design for final processing
  3893. before dialing.  The relevant command is:
  3894.  
  3895. SET DIAL MACRO [ name ]
  3896.   Specifies the name of a macro to be run on each phone number after all
  3897.   built-in conversions have been applied, just before the number is dialed.
  3898.   If no name is given, no macro is run.  The phone number, as it would have
  3899.   been dialed if there were no dial macro, is passed to the macro.
  3900.  
  3901. The dial macro can do anything at all (except start a file transfer).
  3902. However, the normal use for the macro would be to modify the phone number.
  3903. For this reason the phone number is passed to the macro as argument number 1
  3904. (\%1).  To cause a modified number to be dialed, the macro should terminate
  3905. with a RETURN statement specifying a return value.  To leave the number alone,
  3906. the macro should simply end.  Example:
  3907.  
  3908.   define xxx return 10108889999$\%1
  3909.   set dial macro xxx
  3910.   dial xyzcorp
  3911.  
  3912. This defines a DIAL MACRO called xxx, which puts an access code on the
  3913. front of the number.  Another example might be:
  3914.  
  3915.   def xxx if equal "\v(modem)" "hayes-1200" return \freplace(\%1,$,{,,,,,})
  3916.   set dial macro xxx
  3917.   dial xyzcorp
  3918.  
  3919. which replaces any dollar-sign in the dial string by a series of five commas,
  3920. e.g. because this particular modem does not support the "wait for bong"
  3921. feature (remember that commas that are to be included literally in function
  3922. arguments must be enclosed in braces to distinguish them from the commas that
  3923. separate the arguments) and when the IF condition is not satisfied, the macro
  3924. does not return a value, and so the number is not modified.  Then when a DIAL
  3925. command is given referencing a dialing directory entry, "xyzcorp".  The macro
  3926. is automatically applied to each matching number.
  3927.  
  3928. Numerous dial-, modem-, communications-, and time-related variables are
  3929. available for decision making your dial macro.  Type SHOW VARIABLES for a
  3930. list.  Of particular interest is the \v(dialcount) variable, which tells how
  3931. many times the DIAL command gone through its retry loop: 1 on the first try,
  3932. 2 on the second, 3 on the third, and so on, and the \v(dialresult) and
  3933. \v(dialstatus) variables.
  3934.  
  3935. Here are some other applications for the DIAL MACRO (from users):
  3936.  
  3937.  . Phone numbers in the dialing directory are formatted with '-'
  3938.    for readability, but some modems don't like the hyphens, so the DIAL
  3939.    macro is used to remove them before dialing; e.g 0090-123-456-78-99
  3940.    becomes 00901234567899: "def xxx return \freplace(\%1,-)".
  3941.  
  3942.  . To set some specific modem (or other) options depending on the called
  3943.    customer or telephone number.
  3944.  
  3945.  . Choosing the most appropriate provider based on (e.g.) time of day,
  3946.    or cycling through a list of providers in case some providers might
  3947.    be busy.
  3948.  
  3949. To illustrate the final item, suppose you have a choice among many phone
  3950. service providers; the provider is chosen by dialing an access code before the
  3951. number.  Different providers might be better (e.g. cheaper) for certain times
  3952. of day or days of the week, or for dialing certain locations; you can use the
  3953. DIAL macro to add the access for the most desirable provider.
  3954.  
  3955. Similarly, when the same number might be reached through multiple providers,
  3956. it's possible that one provider might not be able to complete the call, but
  3957. another one can.  In that case, you can use the DIAL macro to switch providers
  3958. each time through the DIAL loop -- that's where the \v(dialcount) variable
  3959. comes in handy.
  3960.  
  3961. The following command can be used to debug the DIAL macro:
  3962.  
  3963. SET DIAL TEST { ON, OFF }
  3964.   Normally OFF, so the DIAL command actually dials.  When ON, the DIAL
  3965.   command performs all lookups and number conversions, and then goes through
  3966.   the number list and retry loop, but instead of actually dialing, lists
  3967.   the numbers it would have called if none of the DIAL attempts succeeded
  3968.   (or more precisely, every number was always busy).
  3969.  
  3970. 2.1.14. Automatic Tone/Pulse Dialing Selection
  3971.  
  3972. SET DIAL METHOD { AUTO, DEFAULT, PULSE, TONE }
  3973.   Chooses the dialing method for subsequent calls.
  3974.  
  3975. Prior to version 7.0, C-Kermit's DIAL METHOD was DEFAULT by default, meaning
  3976. it does not specify a dialing method to the modem, but relies on the modem
  3977. to have an appropriate default dialing method set.  So, for example, when
  3978. using Hayes compatible modems, the dial string would be something like
  3979. ATD7654321, rather than ATDT7654321 or ATDP7654321.
  3980.  
  3981. In C-Kermit 7.0 and K95 1.1.18, the dial method can be set from the
  3982. environment variable:
  3983.  
  3984.   K_DIAL_METHOD
  3985.  
  3986. when Kermit starts.  The values can be TONE, PULSE, or DEFAULT, e.g. (UNIX):
  3987.  
  3988.   set K_DIAL_METHOD=TONE; export K_DIAL_METHOD
  3989.  
  3990. In the absence of a K_DIAL_METHOD definition, the new default SET DIAL METHOD
  3991. is AUTO rather than DEFAULT.  When DIAL METHOD is AUTO and the local country
  3992. code is known, then if tone dialing is universally available in the
  3993. corresponding area, tone dialing is used; if dialing from a location where
  3994. pulse dialing is mandatory, pulse dialing is used.
  3995.  
  3996. The "tone country" and "pulse country" lists are preloaded according to our
  3997. knowledge at the time of release.  You can see their contents in the SHOW
  3998. DIAL listing.  You can change the lists with:
  3999.  
  4000. SET DIAL TONE-COUNTRIES [ cc [ cc [ ... ] ] ]
  4001.   Replaces the current TONE-COUNTRIES list with the one given.  Each cc is
  4002.   a country code; separate them with spaces (not commas).  Example:
  4003.  
  4004.     set dial tone-countries 1 358 44 46 49
  4005.  
  4006.   If no country codes are given, the current list, if any, is removed, in
  4007.   which case SET DIAL METHOD AUTO is equivalent to SET DIAL METHOD DEFAULT.
  4008.  
  4009. SET DIAL PULSE-COUNTRIES [ cc [ cc [ ... ] ] ]
  4010.   Replaces the current PULSE-COUNTRIES list with the one give.  Syntax and
  4011.   operation is like SET DIAL TONE-COUNTRIES.
  4012.  
  4013. If the same country code appears in both lists, Pulse takes precedence.
  4014.  
  4015. The SET DIAL TONE- and PULSE-COUNTRIES commands perform no verification
  4016. whatsoever on the cc's, since almost any syntax might be legal in some
  4017. settings.  Furthermore, there is no facility to edit the lists; you can only
  4018. replace the whole list.  However, since the only purpose of these lists is to
  4019. establish a basis for picking tone or pulse dialing automatically, all you
  4020. need to override the effect of the list is to set a specific dialing method
  4021. with SET DIAL METHOD TONE or SET DIAL METHOD PULSE.
  4022.  
  4023. 2.1.15. Dial-Modifier Variables
  4024.  
  4025. As of C-Kermit 7.0, dial modifiers are available in the following variables:
  4026.  
  4027.  \v(dm_lp) Long pause
  4028.  \v(dm_sp) Short pause
  4029.  \v(dm_pd) Pulse dial
  4030.  \v(dm_td) Tone dial
  4031.  \v(dm_wa) Wait for answer
  4032.  \v(dm_wd) Wait for dialtone
  4033.  \v(dm_rc) Return to command mode
  4034.  
  4035. You can use these in your dial strings in place of hardwired modifiers like
  4036. "@", ",", etc, for increased portability of scripts.  Example:
  4037.  
  4038.   C-Kermit>set modem type usrobotics
  4039.   C-Kermit>sho variables dm
  4040.    \v(dm_lp) = ,
  4041.    \v(dm_sp) = /
  4042.    \v(dm_pd) = P
  4043.    \v(dm_td) = T
  4044.    \v(dm_wa) = @
  4045.    \v(dm_wd) = W
  4046.    \v(dm_rc) = ;
  4047.   C-Kermit>exit
  4048.  
  4049. 2.1.16. Giving Multiple Numbers to the DIAL Command
  4050.  
  4051. Prior to C-Kermit 7.0, the only way to give a DIAL command a list of phone
  4052. numbers to try until one answers was to create a dialing directory that had
  4053. multiple entries under the same name, and then use that entry name in the DIAL
  4054. command.  Now a list of numbers can be given to the DIAL command directly in
  4055. the following format:
  4056.  
  4057.   dial {{number1}{number2}{number3}...}
  4058.  
  4059. This is the same list format used by SEND /EXCEPT: and other commands that
  4060. allow a list where normally a single item is given.  Restrictions on this
  4061. form of the DIAL command are:
  4062.  
  4063.  . The first two braces must be adjacent; spacing is optional thereafter.
  4064.  . Each number must be an actual number to dial, not a dialing directory entry.
  4065.  . Dialing directory entries may not contain number lists in this format.
  4066.  
  4067. In all other respects, the numbers are treated as if they had been fetched
  4068. from the dialing directory; they can be in literal or portable format, etc.
  4069. Example:
  4070.  
  4071.   dial {{7654321} {+1 (212) 5551212} { 1-212-5556789 }}
  4072.  
  4073. The list can be any length at all, within reason.
  4074.  
  4075. This feature is especially handy for use with the K95 Dialer, allowing a list
  4076. of phone numbers to be specified in the Telephone Number box without having
  4077. to set up or reference a separate dialing directory.
  4078.  
  4079. You can also use it to add commonly-dialed sequences as variables in your
  4080. C-Kermit customization file, e.g.:
  4081.  
  4082.   define work {{7654321}{7654322}{7654323}}
  4083.  
  4084. and then:
  4085.  
  4086.   dial {\m(work)}
  4087.  
  4088. (the variable name must be enclosed in braces).
  4089.  
  4090. Or more simply:
  4091.  
  4092.   define work dial {{7654321}{7654322}{7654323}}
  4093.  
  4094. and then:
  4095.  
  4096.   work
  4097.  
  4098. 2.2. Modems
  4099.  
  4100. 2.2.1. New Modem Types
  4101.  
  4102. Since C-Kermit 6.0:
  4103.  
  4104.   atlas-newcom-33600ifxC Atlas/Newcom 33600
  4105.   att-keepintouch        AT&T KeepinTouch PCMCIA V.32bis Card Modem
  4106.   att-1900-stu-iii       AT&T Secure Data STU-III Model 1900
  4107.   att-1910-stu-iii       AT&T Secure Data STU-III Model 1910
  4108.   bestdata               Best Data
  4109.   cardinal               Cardinal V.34 MVP288X series.
  4110.   compaq                 Compaq Data+Fax (e.g. in Presario)
  4111.   fujitsu                Fujitsu Fax/Modem Adapter
  4112.   generic-high-speed     Any modern error-correcting data-compressing modem
  4113.   itu-t-v25ter/v250      ITU-T (CCITT) V.25ter (V.250) standard command set
  4114.   megahertz-att-v34      Megahertz AT&T V.34
  4115.   megahertz-xjack        Megahertz X-Jack
  4116.   motorola-codex         Motorola Codex 326X Series
  4117.   motorola-montana       Motorola Montana
  4118.   mt5634zpx              Multitech MT5634ZPX
  4119.   rockwell-v90           Rockwell V.90 56K
  4120.   rolm-244pc             Siemens/Rolm 244PC (AT command set)
  4121.   rolm-600-series        Siemens/Rolm 600 Series (AT command set)
  4122.   spirit-ii              QuickComm Spirit II
  4123.   suprasonic             SupraSonic V288+
  4124.   supra-express-v90      Supra Express V.90
  4125.  
  4126. One of the new types, "generic-high-speed" needs a bit of explanation.  This
  4127. type was added to easily handle other types that are not explicitly covered,
  4128. without going through the bother of adding a complete user-defined modem type.
  4129. This one works for modern modems that use the AT command set, on the
  4130. assumption that all the default ("factory") settings of the modem (a) are
  4131. appropriate for Kermit, (b) include error correction, data compression,
  4132. and speed buffering; and (c) are recallable with the command AT&F.
  4133.  
  4134. If the command to recall your modem's profile is not AT&F, use the SET MODEM
  4135. COMMAND INIT-STRING command to specify the appropriate modem command.  The
  4136. default init-string is AT&F\13 (that is, AT, ampersand, F, and then carriage
  4137. return); a survey of about 20 modern modem types shows they all support this,
  4138. but they might mean different things by it.  For example, the USR Sportster or
  4139. Courier needs AT&F1 (not AT&F, which is equivalent to AT&F0, which recalls an
  4140. inappropriate profile), so for USR modems:
  4141.  
  4142.   set modem type generic-high-speed
  4143.   set modem command init AT&F1\13
  4144.  
  4145. Of course, USR modems already have their own built-in modem type.  But if you
  4146. use this one instead, it will dial faster because it has fewer commands to
  4147. give to the modem; in that sense "&F1" is like a macro that bundles numerous
  4148. commands into a single one.  See your modem manual for details about factory
  4149. profiles and commands to recall them.
  4150.  
  4151. WARNING: Do not use the generic-high-speed modem type in operating systems
  4152. like VMS where hardware flow control is not available, at least not unless you
  4153. change the init string from AT&F\13 to something else that enables local
  4154. Xon/Xoff or other appropriate type of flow control.
  4155.  
  4156. Also see Section 2.1.7 for additional hints about making dialing go faster.
  4157.  
  4158. 2.2.2. New Modem Controls
  4159.  
  4160. SET MODEM CAPABILITIES <list>
  4161.   In C-Kermit 7.0, this command automatically turns MODEM SPEED-MATCHING OFF
  4162.   if SB (Speed Buffering) is in the <list>, and turns it ON if SB is absent.
  4163.  
  4164. SET MODEM COMMAND PREDIAL-INIT [ <text> ]
  4165.   Commands to be sent to the modem just prior to dialing.  Normally none.
  4166.  
  4167. SET MODEM SPEAKER { ON, OFF }
  4168.   Determines whether modem speaker is on or off while call is being placed.
  4169.   ON by default.  Note: This command does not provide fine-grained control
  4170.   over when the speaker is on or off.  Normally, ON means while the call is
  4171.   being placed, until the point at which carrier is successfully established.
  4172.   If your modem has a different speaker option that you want to choose, then
  4173.   use the SET MODEM COMMAND SPEAKER ON <text> command to specify this option.
  4174.  
  4175. SET MODEM COMMAND SPEAKER { ON, OFF } [ <text> ]
  4176.   Specify or override the commands to turn your modem's speaker on and off.
  4177.  
  4178. SET MODEM VOLUME { LOW, MEDIUM, HIGH }
  4179.   When MODEM SPEAKER is on, select volume.  Note: In some modems, especially
  4180.   internal ones, these commands have no effect; this is a limitation of the
  4181.   particular modem, not of Kermit.
  4182.  
  4183. SET MODEM COMMAND VOLUME { LOW, MEDIUM, HIGH } [ <text> ]
  4184.   Specify or override the commands to set your modem's speaker volume.
  4185.  
  4186. SET MODEM COMMAND IGNORE-DIALTONE [ <text> ]
  4187.   The command to enable blind dialing (section 2.1.6).
  4188.  
  4189. SET MODEM ESCAPE-CHARACTER <code>
  4190.   Has been augmented to allow codes of 0 or less:
  4191.     < 0 means the escape mechanism is disabled.
  4192.     = 0 means to use (restore) the default value from the modem database.
  4193.     > 0 and < 128 is a literal value to be used instead of the default one.
  4194.     > 127 means the escape mechanism is disabled.
  4195.   This affects "modem hangup".  When the escape mechanism is disabled, but
  4196.   SET MODEM HANGUP-METHOD is MODEM-COMMAND, it sends the hangup command
  4197.   immediately, without the <pause>+++<pause> business first.  This is useful
  4198.   (for example) when sending lots of numeric pages, a process in which we
  4199.   never go online, and so never need to escape back.  Eliminating the
  4200.   unnecessary pauses and escape sequence allows a lot more pages to be sent
  4201.   per unit time.
  4202.  
  4203. Recall that C-Kermit can dial modems to which it is connected via TCP/IP
  4204. (Telnet or Rlogin) as described on page 126 of "Using C-Kermit", 2nd Ed.
  4205. In this case the MODEM HANGUP-METHOD should be MODEM-COMMAND, since RS-232
  4206. signals don't work over TCP/IP connections.  As noted in the manual, such
  4207. connections are set up by the following sequence:
  4208.  
  4209.   set host <host> [ <port> ]
  4210.   set modem type <name>
  4211.   dial <number>
  4212.  
  4213. But this can cause complications when you use Kermit to switch between serial
  4214. and TCP/IP connections.  In the following sequence:
  4215.  
  4216.   set host <name>
  4217.   set modem type <name>
  4218.   set port <name>
  4219.  
  4220. the first two commands obey the rules for dialing out over Telnet.  However,
  4221. the SET PORT command requires that Kermit close its current (Telnet)
  4222. connection before it can open the serial port (since Kermit can only have one
  4223. connection open at a time).  But since a modem type was set after the "set
  4224. host" command was given, Kermit assumes it is a Telnet dialout connection and
  4225. so sends the modem's hangup sequence is sent to the Telnet host.  To avoid
  4226. this, close the network connection explicitly before opening the serial one:
  4227.  
  4228.   set host <name>
  4229.   close
  4230.   set modem type <name>
  4231.   set port <name>
  4232.  
  4233. 2.3. TELNET and RLOGIN
  4234.  
  4235. For additional background, please also read the TELNET.TXT file.
  4236.  
  4237. Cautions:
  4238.  
  4239. If making a Telnet connection with C-Kermit takes a very long time, like
  4240. over a minute, whereas the system Telnet program makes the same connection
  4241. immediately, try including the /NOWAIT switch:
  4242.  
  4243.   C-Kermit> telnet /nowait hostname
  4244.  
  4245. See TELNET.TXT for details.  If it also takes a very long time to make a
  4246. Telnet connection with system Telnet, then the delay is most likely caused
  4247. by reverse DNS lookups when your host is not properly registered in DNS.
  4248.  
  4249. When supplying numeric IP addresses to C-Kermit or to any other application
  4250. (regular Telnet, Rlogin, etc), do not include leading 0's in any fields unless
  4251. you intend for those fields to be interpreted as octal (or hex) numbers.  The
  4252. description of the Internet address interpreter (the sockets library
  4253. inet_addr() routine) includes these words:
  4254.  
  4255.   All numbers supplied as "parts" in a "." notation may be decimal, octal,
  4256.   or hexadecimal, as specified in the C language (that is, a leading 0x or
  4257.   0X implies hexadecimal; otherwise, a leading 0 implies octal; otherwise,
  4258.   the number is interpreted as decimal).
  4259.  
  4260. To illustrate, 128.59.39.2 and 128.059.039.002 are NOT the same host!  Even
  4261. though most of the fields contain non-octal digits.  Using system Telnet (not
  4262. Kermit):
  4263.  
  4264.   $ telnet 128.059.039.002
  4265.   Trying 128.49.33.2 ...
  4266.  
  4267. Of course the same thing happens with Kermit because it uses (as it must) the
  4268. same system service for resolving network addresses that Telnet, FTP, and all
  4269. other TCP/IP applications use.
  4270.  
  4271. The RLOGIN section on page 123 does not make it clear that you can use the
  4272. SET TELNET TERMINAL-TYPE command to govern the terminal type that is reported
  4273. by C-Kermit to the RLOGIN server.
  4274.  
  4275. Note that the SET TCP commands described on pages 122-123 might be absent;
  4276. some platforms that support TCP/IP do not support these particular controls.
  4277.  
  4278. New commands:
  4279.  
  4280. TELOPT { AO, AYT, BREAK, CANCEL, EC, EL, EOF, EOR, GA, IP, DMARK, DO, DONT,
  4281.  NOP, SB, SE, SUSP, WILL, WONT }
  4282.   This command was available previously, but supported only DO, DONT, WILL,
  4283.   and WONT.  Now it lets you send all the Telnet protocol commands.  Note
  4284.   that certain commands do not require a response, and therefore can be used
  4285.   as nondestructive "probes" to see if the Telnet session is still open; e.g.:
  4286.  
  4287.     set host xyzcorp.com
  4288.     ...
  4289.     telopt nop
  4290.     if fail stop 1 Connection lost
  4291.  
  4292. SET TCP ADDRESS [ <ip-address> ]
  4293.   Specifies the IP address of the computer that C-Kermit is running on.
  4294.   Normally this is not necessary.  The exception would be if your
  4295.   machine has multiple network adapters (physical or virtual) with a
  4296.   different address for each adapter AND you want C-Kermit to use a
  4297.   specific address when making outgoing connections or accepting
  4298.   incoming connections.
  4299.  
  4300. SET TCP DNS-SERVICE-RECORDS {ON, OFF}
  4301.   Tells C-Kermit whether to try to use DNS SRV records to determine the
  4302.   host and port number upon which to find an advertised service.  For
  4303.   example, if a host wants regular Telnet connections redirected to some
  4304.   port other than 23, this feature allows C-Kermit to ask the host which
  4305.   port it should use.  Since not all domain servers are set up to answer
  4306.   such requests, this feature is OFF by default.
  4307.  
  4308. SET TCP REVERSE-DNS-LOOKUP { ON, OFF, AUTO }
  4309.   Tells Kermit whether to perform a reverse DNS lookup on TCP/IP connections.
  4310.   This allows Kermit to determine the actual hostname of the host it is
  4311.   connected to, which is useful for connections to host pools, and is required
  4312.   for Kerberos connections to host pools and for incoming connections.  If the
  4313.   other host does not have a DNS entry, the reverse lookup could take a long
  4314.   time (minutes) to fail, but the connection will still be made.  Turn this
  4315.   option OFF for speedier connections if you do not need to know exactly which
  4316.   host you are connected to and you are not using Kerberos.  AUTO, the
  4317.   default, means the lookup is done on hostnames, but not on numeric IP
  4318.   addresses.
  4319.  
  4320. SET TELNET WAIT-FOR-NEGOTIATIONS { ON, OFF }
  4321.   Each Telnet option must be fully negotiated either On or Off before the
  4322.   session can continue.  This is especially true with options that require
  4323.   sub-negotiations such as Authentication, Encryption, and Kermit; for
  4324.   proper support of these options Kermit must wait for the negotiations to
  4325.   complete.  Of course, Kermit has no way of knowing whether a reply is
  4326.   delayed or not coming at all, and so will wait a minute or more for
  4327.   required replies before continuing the session.  If you know that Kermit's
  4328.   Telnet partner will not be sending the required replies, you can set this
  4329.   option of OFF to avoid the long timeouts.  Or you can instruct Kermit to
  4330.   REFUSE specific options with the SET TELOPT command.
  4331.  
  4332. SET TELOPT [ { /CLIENT, /SERVER } ] <option> -
  4333.     { ACCEPTED, REFUSED, REQUESTED, REQUIRED } -
  4334.     [ { ACCEPTED, REFUSED, REQUESTED, REQUIRED } ]
  4335.   SET TELOPT lets you specify policy requirements for Kermit's handling of
  4336.   Telnet option negotiations.  Setting an option is REQUIRED causes Kermit
  4337.   to offer the option to the peer and disconnect if the option is refused.
  4338.   REQUESTED causes Kermit to offer an option to the peer.  ACCEPTED results
  4339.   in no offer but Kermit will attempt to negotiate the option if it is
  4340.   requested.  REFUSED instructs Kermit to refuse the option if it is
  4341.   requested by the peer.
  4342.  
  4343.   Some options are negotiated in two directions and accept separate policies
  4344.   for each direction; the first keyword applies to Kermit itself, the second
  4345.   applies to Kermit's Telnet partner; if the second keyword is omitted, an
  4346.   appropriate (option-specific) default is applied.  You can also include a
  4347.   /CLIENT or /SERVER switch to indicate whether the given policies apply
  4348.   when Kermit is the Telnet client or the Telnet server; if no switch is
  4349.   given, the command applies to the client.
  4350.  
  4351.   Note that some of Kermit's Telnet partners fail to refuse options that
  4352.   they do not recognize and instead do not respond at all.  In this case it
  4353.   is possible to use SET TELOPT to instruct Kermit to REFUSE the option
  4354.   before connecting to the problem host, thus skipping the problematic
  4355.   negotiation.
  4356.  
  4357.   Use SHOW TELOPT to view current Telnet Option negotiation settings.
  4358.   SHOW TELNET displays current Telnet settings.
  4359.  
  4360. 2.3.0. Bug Fixes
  4361.  
  4362. If "set host nonexistent-host" was given (and it properly failed), followed by
  4363. certain commands like SEND, the original line and modem type were not restored
  4364. and C-Kermit thought that it still had a network hostname; fixed in 7.0.
  4365.  
  4366. 2.3.1. Telnet Binary Mode Bug Adjustments
  4367.  
  4368. SET TELNET BUG BINARY-ME-MEANS-U-TOO { ON, OFF } was added to edit 192
  4369. after the book was printed.  Also SET TELNET BUG BINARY-U-MEANS-ME-TOO.
  4370. The default for both is OFF.  ON should be used when communicating with a
  4371. Telnet partner (client or server) that mistakenly believes that telling
  4372. C-Kermit to enter Telnet binary mode also means that it, too, is in binary
  4373. mode, contrary to the Telnet specification, which says that binary mode must
  4374. be negotiated in each direction separately.
  4375.  
  4376. 2.3.2. VMS UCX Telnet Port Bug Adjustment
  4377.  
  4378. A new command, SET TCP UCX-PORT-BUG, was added for VMS versions with UCX (DEC
  4379. TCP/IP), applying only to early versions of UCX, like 2.2 or earlier.  If you
  4380. try to use VMS C-Kermit to make a Telnet connection using a port name (like
  4381. "telnet", which is used by default), the underlying UCX getservbyname()
  4382. function might return the service number with its bytes swapped and the
  4383. connection will fail.  If "telnet hostname 23" works, then your version of UCX
  4384. has this bug and you can put "set tcp ucx-port-bug on" in your CKERMIT.INI
  4385. file to get around it.
  4386.  
  4387. 2.3.3. Telnet New Environment Option
  4388.  
  4389. The TELNET NEW-ENVIRONMENT option (RFC1572) is supported as 7.0.  This option
  4390. allows the C-Kermit Telnet client to send certain well-known variables to the
  4391. Telnet server, including USER, PRINTER, DISPLAY, and several others.  This
  4392. feature is enabled by default in Windows and OS/2, disabled by default
  4393. elsewhere.  The command to enable and disable it is:
  4394.  
  4395.   SET TELNET ENVIRONMENT { ON, OFF }
  4396.  
  4397. When ON, and you Telnet to another computer, you might (or might not) notice
  4398. that the "login:" or "Username:" prompt does not appear -- that's because your
  4399. username was sent ahead, in which case the remote system might prompt you only
  4400. for your password (similar to Rlogin).  Use "set telnet environment off" to
  4401. defeat this feature, particularly in scripts where the dialog must be
  4402. predictable.  You can also use this command to specify or override specific
  4403. well-known environment variable values:
  4404.  
  4405.  SET TELNET ENVIRONMENT { ACCT,DISPLAY,JOB,PRINTER,SYSTEMTYPE,USER } [ <text> ]
  4406.  
  4407. 2.3.4. Telnet Location Option
  4408.  
  4409. The TELNET LOCATION option (RFC779) is supported in 7.0.  This option allows
  4410. the C-Kermit Telnet client to send a location string to the server if the
  4411. server indicates its willingness to accept one.  If an environment variable
  4412. named LOCATION exists at the time C-Kermit starts, its value is used as the
  4413. location string.  If you want to change it, use:
  4414.  
  4415.   SET TELNET LOCATION <text>
  4416.  
  4417. If you omit the <text> from this command, the Telnet location feature is
  4418. disabled.
  4419.  
  4420. SET TELNET ENVIRONMENT DISPLAY is used to set the DISPLAY variable that is
  4421. sent to the host, as well as the the XDISPLAY location.
  4422.  
  4423. 2.3.5. Connecting to Raw TCP Sockets
  4424.  
  4425. The SET HOST and TELNET commands now accept an optional switch, /RAW-SOCKET,
  4426. at the end, only if you first give a host and a port.  Example:
  4427.  
  4428.   set host xyzcorp.com 23 /raw-socket
  4429.   set host 128.49.39.2:2000 /raw-socket
  4430.   telnet xyzcorp.com 3000 /raw
  4431.  
  4432. Without this switch, C-Kermit behaves as a Telnet client when (a) the port is
  4433. 23 or 1649, or (b) the port is not 513 and the server sent what appeared to be
  4434. Telnet negotiations -- that is, messages starting with 0xFF (IAC).  With this
  4435. switch, Kermit should treat all incoming bytes as raw data, and will not
  4436. engage in any Telnet negotiations or NVT CRLF manipulations.  This allows
  4437. transparent operation through (e.g.) raw TCP ports on Cisco terminal servers,
  4438. through the 'modemd' modem server, etc.
  4439.  
  4440. 2.3.6. Incoming TCP Connections
  4441.  
  4442. Accomplished via SET HOST * <port>, were introduced in C-Kermit 6.0, but for
  4443. UNIX only.  In Version 7.0, they are also available for VMS.
  4444.  
  4445. 2.4. The EIGHTBIT Command
  4446.  
  4447. EIGHTBIT is simply a shorthand for: SET PARITY NONE, SET TERMINAL BYTESIZE 8,
  4448. SET COMMAND BYTESIZE 8; that is, a way to set up an 8-bit clean connection
  4449. in a single command.
  4450.  
  4451. 2.5. The Services Directory
  4452.  
  4453. Chapter 7 of "Using C-Kermit" does not mention the ULOGIN macro, which is
  4454. used by our sample services directory, CKERMIT.KND.  Unlike UNIXLOGIN,
  4455. VMSLOGIN, etc, this one is for use with systems that require a user ID but
  4456. no password.  Therefore it doesn't prompt for a password or wait for a
  4457. password prompt from the remote service.
  4458.  
  4459. In version 7.0, the CALL macro was changed to not execute a SET MODEM TYPE
  4460. command if the given modem type was the same as the current one; otherwise the
  4461. new SET MODEM TYPE command would overwrite any customizations that the user
  4462. had made to the modem settings.  Ditto for SET LINE / SET PORT and SET SPEED.
  4463.  
  4464. 2.6. Closing Connections
  4465.  
  4466. Until version 7.0, there was never an obvious and general way to close a
  4467. connection.  If a serial connection was open, it could be closed by "set
  4468. line" or "set port" (giving no device name); if a network connection was
  4469. open, it could be closed by "set host" (no host name).
  4470.  
  4471. In version 7.0, a new command closes the connection in an obvious and
  4472. straightforward way, no matter what the connection type:
  4473.  
  4474.   CLOSE [ CONNECTION ]
  4475.  
  4476. The CLOSE command was already present, and required an operand such as
  4477. DEBUG-LOG, WRITE-FILE, etc, and so could never be given by itself.  The new
  4478. CONNECTION operand is now the default operand for CLOSE, so CLOSE by itself
  4479. closes the connection, if one is open, just as you would expect, especially
  4480. if you are a Telnet or Ftp user.
  4481.  
  4482. Also see the description of the new SET CLOSE-ON-DISCONNECT command in
  4483. Section 2.10.
  4484.  
  4485. 2.7. Using C-Kermit with External Communication Programs
  4486.  
  4487. C-Kermit 7.0 includes a new ability to create and conduct sessions through
  4488. other communications programs.  Two methods are available:
  4489.  
  4490.  a. Pty (pseudoterminal): The external program is run on a "pseudoterminal",
  4491.     which is controlled by Kermit.  This method works with practically any
  4492.     external program, but it is not portable.  At this writing, it works only
  4493.     on some (not all) UNIX versions, and not on any non-UNIX platforms.
  4494.  
  4495.  b. Pipe: The external program's standard input and output are redirected
  4496.     through a "pipe" controlled by Kermit.  This method is relatively
  4497.     portable -- it should work across all UNIX versions, and it also works
  4498.     in Windows and OS/2 -- but it is effective only when the external
  4499.     program actually uses standard i/o (and many don't).
  4500.  
  4501. The two methods are started differently but are used the same way thereafter.
  4502.  
  4503. The purpose of this feature is to let you use C-Kermit services like file
  4504. transfer, character-set translation, scripting, automatic dialing, etc, on
  4505. connections that Kermit can't otherwise make itself.
  4506.  
  4507. This feature is the opposite of the REDIRECT feature, in which C-Kermit makes
  4508. the connection, and redirects an external (local) command or program over this
  4509. connection.  In a pty or pipe connection, C-Kermit runs and controls a local
  4510. command or program, which makes the connection.  (The same method can be used
  4511. to simply to control a local program without making a connection; see Section
  4512. 2.8.)
  4513.  
  4514. To find out if your version of Kermit includes PTY support, type "show
  4515. features" and look for NETPTY in the alphabetical list of options.  For pipes,
  4516. look for NETCMD.
  4517.  
  4518. The commands are:
  4519.  
  4520.   SET NETWORK TYPE PTY  or  SET NETWORK TYPE PIPE
  4521.   SET HOST <command>
  4522.  
  4523. where <command> is any interactive command.  If the command does not use
  4524. standard i/o, you must use SET NETWORK TYPE PTY.
  4525.  
  4526. Notes:
  4527.  
  4528.  a. COMMAND is an invisible synonym for PIPE.
  4529.  b. The <command> and its arguments are case-sensitive in UNIX.
  4530.  
  4531. The SET NETWORK TYPE, SET HOST sequence sets the given network type for all
  4532. subsequent SET HOST commands until another SET NETWORK TYPE command is given
  4533. to change it.
  4534.  
  4535. You can also use the new /NETWORK-TYPE:PTY or /NETWORK-TYPE:PIPE (or simply
  4536. /PIPE or /PTY) switches on the SET HOST command itself:
  4537.  
  4538.   SET HOST /NETWORK-TYPE:PIPE <command>  ; These two are the same
  4539.   SET HOST /PIPE <command>
  4540.  
  4541.   SET HOST /NETWORK-TYPE:PTY <command>   ; Ditto
  4542.   SET HOST /PTY <command>
  4543.  
  4544. These are like SET NETWORK TYPE followed by SET HOST, except they apply only
  4545. to the connection being made and do not change the global network type setting
  4546. (see Section 1.5 about the difference between switches and SET commands).
  4547.  
  4548. Include any command-line options with the <command> that might be needed, as
  4549. in this example where C-Kermit uses another copy of itself as the
  4550. communications program:
  4551.  
  4552.   SET HOST /PIPE /CONNECT kermit -YQJ xyzcorp.com
  4553.  
  4554. As usual, if you include the /CONNECT switch, SET HOST enters CONNECT mode
  4555. immediately upon successful execution of the given command.  Therefore a new
  4556. command is available as a shorthand for SET HOST /CONNECT /PTY:
  4557.  
  4558.   PTY [ <command> ]
  4559.  
  4560. And for SET HOST /CONNECT /PIPE:
  4561.  
  4562.   PIPE [ <command> ]
  4563.  
  4564. Thus, the PTY and PIPE commands work like the TELNET and RLOGIN commands: they
  4565. set up the connection (in this case, using the given command) and then enter
  4566. CONNECT mode automatically (if the PIPE or PTY command is given without a
  4567. <command>, it continues the current session if one is active; otherwise it
  4568. gives an error message).
  4569.  
  4570. The PIPE command is named after the mechanism by which C-Kermit communicates
  4571. with the <command>: UNIX pipes.  C-Kermit's i/o is "piped" through the given
  4572. command.  Here is a typical example:
  4573.  
  4574.   PIPE rlogin -8 xyzcorp.com
  4575.  
  4576. This is equivalent to:
  4577.  
  4578.   SET HOST /PIPE rlogin -8 xyzcorp.com
  4579.   CONNECT
  4580.  
  4581. and to:
  4582.  
  4583.   SET HOST /PIPE /CONNECT rlogin -8 xyzcorp.com
  4584.  
  4585. IMPORTANT:
  4586.   If you are writing a script, do not use the PIPE, PTY, TELNET, or RLOGIN
  4587.   command unless you really want C-Kermit to enter CONNECT mode at that
  4588.   point.  Normally SET HOST is used in scripts to allow the login and
  4589.   other dialogs to be controlled by the script itself, rather than by
  4590.   an actively participating human at the keyboard.
  4591.  
  4592. Throughput of pty and pipe connections is limited by the performance of the
  4593. chosen command or program and by the interprocess communication (IPC) method
  4594. used and/or buffering capacity of the pipe or pty, which in turn depends on
  4595. the underlying operating system.
  4596.  
  4597. In one trial (on SunOS 4.1.3), we observed file transfer rates over an rlogin
  4598. connection proceeding at 200Kcps for downloads, but only 10Kcps for uploads on
  4599. the same connection with the same settings (similar disparities were noted in
  4600. HP-UX).  Examination of the logs revealed that a write to the pipe could take
  4601. as long as 5 seconds, whereas reads were practically instantaneous.  On the
  4602. other hand, using Telnet as the external program rather than rlogin, downloads
  4603. and uploads were better matched at about 177K each.
  4604.  
  4605. Most external communication programs, like C-Kermit itself, have escape
  4606. characters or sequences.  Normally these begin with (or consist entirely of) a
  4607. control character.  You must be sure that this control character is not
  4608. "unprefixed" when uploading files, otherwise the external program will "escape
  4609. back" to its prompt, or close the connection, or take some other unwanted
  4610. action.  When in CONNECT mode, observe the program's normal interaction rules.
  4611. Of course C-Kermit's own escape character (normally Ctrl-\) is active too,
  4612. unless you have taken some action to disable it.
  4613.  
  4614. On PTY connections, the underlying PTY driver is not guaranteed to be
  4615. transparent to control characters -- for example, it might expand tabs,
  4616. translate carriage returns, generate signals if it sees an interrupt
  4617. character, and so on.  Similar things might happen on a PIPE connection.  For
  4618. this reason, if you plan to transfer files over a PTY or PIPE connection, tell
  4619. the file sender to:
  4620.  
  4621.   SET PREFIXING ALL
  4622.     This causes all control characters to be prefixed and transmitted
  4623.     as printable ASCII characters.
  4624.  
  4625. If the external connection program is not 8-bit clean, you should also:
  4626.  
  4627.   SET PARITY SPACE
  4628.     This causes 8-bit data to be encoded in 7 bits using single and/or
  4629.     locking shifts.
  4630.  
  4631. And if it does not make a reliable connection (such as those made by Telnet,
  4632. Rlogin, Ssh, etc), you should:
  4633.  
  4634.   SET STREAMING OFF
  4635.     This forces C-Kermit to treat the connection as unreliable and
  4636.     to engage in its normal ACK/NAK protocol for error detection and
  4637.     correction, rather than "streaming" its packets, as it normally
  4638.     does on a network connection (Section 4.20).
  4639.  
  4640. In some cases, buffer sizes might be restricted, so you might also need to
  4641. reduce the Kermit packet length to fit; this is a trial-and-error affair.  For
  4642. example, if transfers always fail with 4000-byte packets, try 2000.  If that
  4643. fails too, try 1000, and so on.  The commands are:
  4644.  
  4645.   SET RECEIVE PACKET-LENGTH <number>
  4646.     This tells the file receiver to tell the file sender the longest
  4647.     packet length it can accept.
  4648.  
  4649.   SET SEND PACKET-LENGTH <number>
  4650.     This tells the file sender not to send packets longer than the given
  4651.     length, even if the receiver says longer ones are OK.  Of course, if
  4652.     the receiver's length is shorter, the shorter length is used.
  4653.  
  4654. If none of this seems to help, try falling back to the bare minimum,
  4655. lowest-common-denominator protocol settings:
  4656.  
  4657.   ROBUST
  4658.     No sliding windows, no streaming, no control-character unprefixing,
  4659.     packet length 90.
  4660.  
  4661. And then work your way back up by trial and error to get greater throughput.
  4662.  
  4663. Note that when starting a PIPE connection, and the connection program (such as
  4664. telnet or rlogin) prints some greeting or information messages before starting
  4665. the connection, these are quite likely to be printed with a stairstep effect
  4666. (linefeed without carriage return).  This is because the program is not
  4667. connected with the UNIX terminal driver; there's not much Kermit can do about
  4668. it.  Once the connection is made, everything should go back to normal.  This
  4669. shouldn't happen on a PTY connection because a PTY is, indeed, a terminal.
  4670.  
  4671. On a similar note, some connection programs (like Solaris 2.5 rlogin) might
  4672. print lots of error messages like "ioctl TIOCGETP: invalid argument" when
  4673. used through a pipe.  They are annoying but usually harmless.  If you want to
  4674. avoid these messages, and your shell allows redirection of stderr, you can
  4675. redirect stderr in your pipe command, as in this example where the user's
  4676. shell is bash:
  4677.  
  4678.   PIPE rlogin xyzcorp.com 2> /dev/null
  4679.  
  4680. Or use PTY rather than PIPE, since PTY is available on Solaris.
  4681.  
  4682. 2.7.0. C-Kermit over tn3270 and tn5250
  4683.  
  4684. Now you can make a connection from C-Kermit "directly" to an IBM mainframe and
  4685. transfer files with it, assuming it has Kermit-370 installed.  Because tn3270
  4686. is neither 8-bit clean nor transparent to control characters, you must give
  4687. these commands:
  4688.  
  4689.   SET PREFIXING ALL   ; Prefix all control characters
  4690.   SET PARITY SPACE    ; Telnet connections are usually not 8-bit clean
  4691.  
  4692. and then:
  4693.  
  4694.   SET HOST /PTY /CONNECT tn3270 abccorp.com
  4695.  
  4696. or simply:
  4697.  
  4698.   pty tn3270 abccorp.com
  4699.  
  4700. SET HOST /PIPE does not work in this case, at least not for file transfer.
  4701. File transfer does work, however, with SET HOST /PTY, provided you use the
  4702. default packet length of 90 bytes; anything longer seems to kill the session.
  4703.  
  4704. You can also make connections to IBM AS/400 computers if you have a tn5250
  4705. program installed:
  4706.  
  4707.   pty tn5250 <hostname>
  4708.  
  4709. In this case, however, file transfer is probably not in the cards since
  4710. nobody has ever succeeded in writing a Kermit program for the AS/400.
  4711.  
  4712. Hint:
  4713.  
  4714.   define tn3270 {
  4715.       check pty
  4716.       if fail end 1 Sorry - no PTY support...
  4717.       pty tn3270 \%*
  4718.  
  4719.   }
  4720.  
  4721. Similarly for tn5250.  Note that CHECK PTY and CHECK PIPE can be used in
  4722. macros and scripts to test whether PTY or PIPE support is available.
  4723.  
  4724. 2.7.1. C-Kermit over Telnet
  4725.  
  4726. Although C-Kermit includes its own Telnet implementation, you might need to
  4727. use an external Telnet program to make certain connections; perhaps because it
  4728. has access or security features not available in C-Kermit itself.  As noted
  4729. above, the only precautions necessary are usually:
  4730.  
  4731.   SET PREFIXING ALL   ; Prefix all control characters
  4732.   SET PARITY SPACE    ; Telnet connections might not be 8-bit clean
  4733.  
  4734. and then:
  4735.  
  4736.   SET HOST /PTY (or /PIPE) /CONNECT telnet abccorp.com
  4737.  
  4738. or, equivalently:
  4739.  
  4740.   PTY (or PIPE) telnet abccorp.com
  4741.  
  4742. 2.7.2. C-Kermit over Rlogin
  4743.  
  4744. C-Kermit includes its own Rlogin client, but this can normally be used only if
  4745. you are root, since the rlogin TCP port is privileged.  But ptys and pipes let
  4746. you make rlogin connections with C-Kermit through your computer's external
  4747. rlogin program, which is normally installed as a privileged program:
  4748.  
  4749.   SET PREFIXING ALL
  4750.  
  4751. and then:
  4752.  
  4753.   SET HOST /PTY (or /PIPE) /CONNECT rlogin -8 abccorp.com
  4754.  
  4755. or, equivalently:
  4756.  
  4757.   PTY (or PIPE) rlogin -8 abccorp.com
  4758.  
  4759. The "-8" option to rlogin enables transmission of 8-bit data.  If this is
  4760. not available, then include SET PARITY SPACE if you intend to transfer files.
  4761.  
  4762. Note that the normal escape sequence for rlogin is Carriage Return followed by
  4763. Tilde (~), but only when the tilde is followed by certain other characters;
  4764. the exact behavior depends on your rlogin client, so read its documentation.
  4765.  
  4766. 2.7.3. C-Kermit over Serial Communication Programs
  4767.  
  4768. Ptys and pipes also let you use programs that make serial connections, such as
  4769. cu or tip.  For example, C-Kermit can be used through cu to make connections
  4770. that otherwise might not be allowed, e.g. because C-Kermit is not installed
  4771. with the required write permissions to the dialout device and the UUCP
  4772. lockfile directory.
  4773.  
  4774. Suppose your UUCP Devices file contains an entry for a serial device tty04 to
  4775. be used for direct connections, but this device is protected against you (and
  4776. Kermit when you run it).  In this case you can:
  4777.  
  4778.   SET CONTROL PREFIX ALL
  4779.   PTY (or PIPE) cu -l tty04
  4780.  
  4781. (Similarly for dialout devices, except then you also need to include the phone
  4782. number in the "cu" command.)
  4783.  
  4784. As with other communication programs, watch out for cu's escape sequence,
  4785. which is the same as the rlogin program's: Carriage Return followed by Tilde
  4786. (followed by another character to specify an action, like "." for closing the
  4787. connection and exiting from cu).
  4788.  
  4789. 2.7.4. C-Kermit over Secure Network Clients
  4790.  
  4791.   DISCLAIMER: There are laws in the USA and other countries regarding
  4792.   use, import, and/or export of encryption and/or decryption or other
  4793.   forms of security software, algorithms, technology, and intellectual
  4794.   property.  The Kermit Project attempts to follow all known statutes,
  4795.   and neither intends nor suggests that Kermit software can or should
  4796.   be used in any way, in any location, that circumvents any regulations,
  4797.   laws, treaties, covenants, or other legitimate canons or instruments
  4798.   of law, international relations, trade, ethics, or propriety.
  4799.  
  4800. For secure connections or connections through firewalls, C-Kermit 7.0 can be a
  4801. Kerberos, SRP, and/or SOCKS client when built with the appropriate options and
  4802. libraries.  But other application-level security acronyms and methods -- SSH,
  4803. SSL, SRP, TLS -- pop up at an alarming rate and are (a) impossible to keep up
  4804. with, (b) usually mutually incompatible, and (c) have restrictions on export
  4805. or redistribution and so cannot be included in C-Kermit itself.
  4806.  
  4807. However, if you have a secure text-based Telnet (or other) client that employs
  4808. one of these security methods, you can use C-Kermit "through" it via a pty
  4809. or pipe.
  4810.  
  4811. 2.7.4.1. SSH
  4812.  
  4813. C-Kermit does not and can not incorporate SSH due to licensing, patent,
  4814. and USA export law restrictions.
  4815.  
  4816. The UNIX SSH client does not use standard input/output, and therefore can be
  4817. used only by Kermit's PTY interface, if one is present.  The cautions about
  4818. file transfer, etc, are the same as for Rlogin.  Example:
  4819.  
  4820.   SET PREFIXING ALL
  4821.   PTY ssh XYZCORP.COM
  4822.  
  4823. Or, for a scripted session:
  4824.  
  4825.   SET PREFIXING ALL
  4826.   SET HOST /PTY ssh XYZCORP.COM
  4827.  
  4828. Hint:
  4829.  
  4830.   define ssh {
  4831.       check pty
  4832.       if fail end 1 Sorry - no PTY support...
  4833.       pty ssh \%*
  4834.   }
  4835.  
  4836. 2.7.4.2. SSL
  4837.  
  4838. Secure Sockets Layer (SSL) is another TCP/IP security overlay, this one
  4839. designed by and for Netscape.  An SSL Telnet client is available for UNIX
  4840. from the University of Queensland.  More info at:
  4841.  
  4842.   http://www.psy.uq.oz.au/~ftp/Crypto/
  4843.  
  4844. Interoperability with C-Kermit is unknown.  C-Kermit also includes its own
  4845. built-in SSL/TLS support, but it is not exportable; see the C-Kermit
  4846. security.txt file for details.
  4847.  
  4848. 2.7.4.3. SRP
  4849.  
  4850. SRP(TM) is Stanford University's Secure Remote Password protocol.  An SRP
  4851. Telnet client is available from Stanford:
  4852.  
  4853.   http://srp.stanford.edu/srp/
  4854.  
  4855. Stanford's SRP Telnet client for UNIX has been tested on SunOS and works fine
  4856. with C-Kermit, as described in Section 2.7.1, e.g.
  4857.  
  4858.   SET PREFIX ALL
  4859.   PTY (or PIPE) srp-telnet xenon.stanford.edu
  4860.  
  4861. C-Kermit itself can be built as an SRP Telnet client on systems that have
  4862. libsrp.a installed; the C-Kermit support code, however, may not be exported
  4863. outside the USA or Canada.
  4864.  
  4865. 2.7.4.4. SOCKS
  4866.  
  4867. C-Kermit can be built as a SOCKS-aware client on systems that have a SOCKS
  4868. library.  See section 8.1.1 of the ckccfg.txt file.
  4869.  
  4870. C-Kermit 7.0 can also be run over SOCKSified Telnet or rlogin clients with SET
  4871. NETWORK TYPE COMMAND.  Suppose the Telnet program on your system is SOCKS
  4872. enabled but C-Kermit is not.  Make Kermit connections like this:
  4873.  
  4874.   SET PREFIX ALL
  4875.   PTY (or PIPE) telnet zzz.com
  4876.  
  4877. 2.7.4.5. Kerberos
  4878.  
  4879. UNIX C-Kermit can be built with MIT Kerberos IV or V authentication and
  4880. encryption.  Instructions are available in a separate document, security.txt.
  4881. Additional modules are required that can not be exported from the USA to any
  4882. country except Canada, by US law.
  4883.  
  4884. If you have Kerberos installed but you don't have a Kerberized version of
  4885. C-Kermit, you can use ktelnet as C-Kermit's external communications program
  4886. to make secure connections without giving up C-Kermit's services:
  4887.  
  4888.   SET PREFIX ALL
  4889.   PTY (or PIPE) ktelnet cia.gov
  4890.  
  4891. 2.8. Scripting Local Programs
  4892.  
  4893. If your version of Kermit has PTY support built in, then any text-based
  4894. program can be invoked with SET HOST /PTY or equivalent command and controlled
  4895. using the normal sequence of OUTPUT, INPUT, IF SUCCESS commands (this is the
  4896. same service that is provided by the 'expect' program, but controlled by the
  4897. Kermit script language rather than Tcl).
  4898.  
  4899. When PTY service is not available, then any program that uses standard input
  4900. and output can be invoked with SET HOST /PIPE.
  4901.  
  4902. Here's an example in which we start an external Kermit program, wait for its
  4903. prompt, give it a VERSION command, and then extract the numeric version number
  4904. from its response:
  4905.  
  4906.   set host /pty kermit -Y
  4907.   if fail stop 1 {Can't start external command}
  4908.   input 10 C-Kermit>
  4909.   if fail stop 1 {No C-Kermit> prompt}
  4910.   output version\13
  4911.   input 10 {Numeric: }
  4912.   if fail stop 1 {No match for "Numeric:"}
  4913.   clear input
  4914.   input 10 \10
  4915.   echo VERSION = "\fsubstr(\v(input),1,6)"
  4916.   output exit\13
  4917.  
  4918. This technique could be used to control any other interactive program, even
  4919. those that do screen formatting (like Emacs or Vi), if you can figure out the
  4920. sequence of events.  If your Kermit program doesn't have PTY support, then the
  4921. commands are restricted to those using standard i/o, including certain shells,
  4922. interactive text-mode "hardcopy" editors like ex, and so on.
  4923.  
  4924. If you are using the PTY interface, you should be aware that it runs the
  4925. given program or command directly on the pty, without any intervening shell
  4926. to interpret metacharacters, redirectors, etc.  If you need this sort of
  4927. thing, include the appropriate shell invocation as part of your command; for
  4928. example:
  4929.  
  4930.   pty echo *
  4931.  
  4932. just echoes "*"; whereas:
  4933.  
  4934.   pty ksh -c "echo *"
  4935.  
  4936. echoes all the filenames that ksh finds matching "*".
  4937.  
  4938. Similarly for redirection:
  4939.  
  4940.   set host /pty ksh -c "cat > foo"  ; Note: use shell quoting rules here
  4941.   set transmit eof \4
  4942.   transmit bar
  4943.  
  4944. And for that matter, for built-in shell commands:
  4945.  
  4946.   set host /pty ksh -c "for i in *; do echo $i; done"
  4947.  
  4948. The PIPE interface, on the other hand, invokes the shell automatically, so:
  4949.  
  4950.   pipe echo *
  4951.  
  4952. prints filenames, not "*".
  4953.  
  4954. 2.9. X.25 Networking
  4955.  
  4956. X.25 networking is documented in "Using C-Kermit", 2nd Edition.  When the book
  4957. was published, X.25 was available only in SunOS, Solaris, and Stratus VOS.
  4958. Unlike TCP/IP, X.25 APIs are not standardized; each vendor's X.25 libraries
  4959. and services (if they have them at all) are unique.
  4960.  
  4961. This section describes new additions.
  4962.  
  4963. 2.9.1. IBM AIXLink/X.25 Network Provider Interface for AIX
  4964.  
  4965. Support for X.25 was added via IBM's Network Provider Interface (NPI),
  4966. AIXLink/X.25 1.1, to the AIX 4.x version of C-Kermit 7.0.  Unfortunately,
  4967. AIXLink/X.25 is a rather bare-bones facility, lacking in particular any form
  4968. of PAD support (X.3, X.28, X.29).  Thus, the AIX version of C-Kermit, when
  4969. built to include X.25 networking, has neither a PAD command, nor a SET PAD
  4970. command.  The same is true for the underlying AIX system: no PAD support.
  4971. Thus it is not possible to have an interactive shell session over an X.25
  4972. connection into an AIX system (as far as we know), even from X.25-capable
  4973. Kermit versions (such as Solaris or VOS) that do include PAD support.
  4974.  
  4975. Thus the X.25 capabilities in AIX C-Kermit are limited to peer-to-peer
  4976. connections, e.g. from a C-Kermit client to a C-Kermit server.  Unlike the
  4977. Solaris, SunOS, and VOS versions, the AIX version can accept incoming X.25
  4978. connections:
  4979.  
  4980.   set network type x.25
  4981.   if fail stop 1 Sorry - no X.25 support
  4982.   ; Put any desired DISABLE or ENABLE or SET commands here.
  4983.   set host /server *
  4984.   if fail stop 1 X.25 "set host *" failed
  4985.  
  4986. And then access it from the client as follows:
  4987.  
  4988.   set network type x.25
  4989.   if fail stop 1 Sorry - no X.25 support
  4990.   set host xxxxxxx ; Specify the X.25/X.121 address
  4991.   if fail stop 1 Can't open connection
  4992.  
  4993. And at this point the client can use the full range of client commands:
  4994. SEND, GET, REMOTE xxx, FINISH, BYE.
  4995.  
  4996. The AIX version also adds two new variables:
  4997.  
  4998.   \v(x25local_nua)   The local X.25 address.
  4999.   \v(x25remote_nua)  The X.25 address of the host on the other end
  5000.                      of the connection.
  5001.  
  5002. C-Kermit's AIX X.25 client has not been tested against anything other than
  5003. a C-Kermit X.25 server on AIX.  It is not known if it will interoperate with
  5004. C-Kermit servers on Solaris, SunOS, or VOS.
  5005.  
  5006. To make an X.25 connection from AIX C-Kermit, you must:
  5007.  
  5008.   set x25 call-user-data xxxx
  5009.  
  5010. where xxxx can be any even-length string of hexadecimal digits, e.g. 123ABC.
  5011.  
  5012. 2.9.2. HP-UX X.25
  5013.  
  5014. Although C-Kermit presently does not include built-in support for HP-UX X.25,
  5015. it can still be used to make X.25 connections as follows: start Kermit and
  5016. tell it to:
  5017.  
  5018.   set prefixing all
  5019.   set parity space
  5020.   pty padem <address>
  5021.  
  5022. This should work in HP-UX 9.00 and later (see Section 2.7).  If you have an
  5023. earlier HP-UX version, or the PTY interface doesn't work or isn't available,
  5024. try:
  5025.  
  5026.   set prefixing all
  5027.   set parity space
  5028.   pipe padem <address>
  5029.  
  5030. Failing that, use Kermit to telnet to localhost and then after logging back
  5031. in, start padem as you would normally do to connect over X.25.
  5032.  
  5033. 2.10. Additional Serial Port Controls
  5034.  
  5035. C-Kermit 7.0 adds the following commands for greater control over serial
  5036. ports.  These commands are available only in C-Kermit versions whose
  5037. underlying operating systems provide the corresponding services (such as
  5038. POSIX and UNIX System V), and even then their successful operation depends
  5039. on the capabilities of the specific device and driver.
  5040.  
  5041. SET DISCONNECT { ON, OFF }
  5042.   On a SET LINE or SET PORT connection with SET CARRIER ON or AUTO, if
  5043.   the carrier signal drops during the connection, indicating that the
  5044.   connection has been lost, and C-Kermit notices it, this setting governs
  5045.   what happens next.  With SET DISCONNECT OFF, which is consistent with
  5046.   previous behavior, and therefore the default, C-Kermit continues to keep the
  5047.   device open and allocated.  With SET DISCONNECT ON, C-Kermit automatically
  5048.   closes and releases the device when it senses a carrier on-to-off
  5049.   transition, thus allowing others to use it.  However, it remains the default
  5050.   device for i/o (DIAL, REDIAL, INPUT, SEND, CONNECT, etc), so if a subsequent
  5051.   i/o command is given, the device is reopened if it is still available.  When
  5052.   it has been automatically closed in this manner, SHOW COMMUNICATIONS puts
  5053.   "(closed)" after its name, and in UNIX, the lockfile disappears -- both from
  5054.   SHOW COMM and from the lockfile directory itself.  Synonym:
  5055.   SET CLOSE-ON-DISCONNECT.
  5056.  
  5057. SET EXIT ON-DISCONNECT { ON, OFF }
  5058.   Like DISCONNECT, but makes the program exit if a connection drops.
  5059.  
  5060. Note that SET CLOSE-ON-DISCONNECT and SET EXIT ON-DISCONNECT apply only to
  5061. connections that drop; they do not apply to connections that can't be made
  5062. in the first place.  For example, they have no effect when a SET LINE,
  5063. SET HOST, TELNET, or DIAL command fails.
  5064.  
  5065. HANGUP
  5066.   If [CLOSE-ON-]DISCONNECT is ON, and the HANGUP command is given on a serial
  5067.   device, and the carrier signal is no longer present after the HANGUP
  5068.   command, the device is closed and released.
  5069.  
  5070. SET PARITY HARDWARE { EVEN, ODD }
  5071.   Unlike SET PARITY { EVEN, ODD, MARK, SPACE }, which selects 7 data bits
  5072.   plus the indicated kind of parity (to be done in software by Kermit itself),
  5073.   SET PARITY HARDWARE selects 8 data bits plus even or odd parity, to be done
  5074.   by the underlying hardware, operating system, or device driver.  This
  5075.   command is effective only with a SET LINE or SET PORT device.  That is, it
  5076.   has no effect in remote mode, nor on network connections.  There is
  5077.   presently no method for selecting 8 data bits plus mark or space parity.
  5078.   If hardware parity is in effect, the variable \v(hwparity) is set to
  5079.   "even" or "odd".  Note: some platforms might also support settings of
  5080.   SPACE, MARK, or NONE.
  5081.  
  5082. SET STOP-BITS { 1, 2 }
  5083.   This tells the number of 1-bits to insert after an outbound character's
  5084.   data and parity bits, to separate it from the next character.  Normally 1.
  5085.   Choosing 2 stop bits should do no harm, but will slow down serial
  5086.   transmission by approximately 10 percent.  Historically, 2 stop bits were
  5087.   used with Teletypes (at 110 bps or below) for print-head recovery time.
  5088.   There is presently no method for choosing any number of stop bits besides
  5089.   1 and 2.
  5090.  
  5091. SET SERIAL [ <dps> ]
  5092.   <dps> stands for Data-bits, Parity, Stop-bits.  This is the notation
  5093.   familiar to many people for serial port configuration: 7E1, 8N1, 7O2, etc.
  5094.   The data bits number also becomes the TERMINAL BYTESIZE setting.  The second
  5095.   character is E for Even, O for Odd, M for Mark, S for Space, or N for None.
  5096.   The list of available options depends on the capabilities of the specific
  5097.   platform.  If <dps> is omitted, 8N1 is used.  Type "set serial ?"  for a
  5098.   list of available choices.  Examples:
  5099.  
  5100.   SET SERIAL 7E1
  5101.     Equivalent to SET PARITY EVEN, SET STOP-BITS 1, SET TERM BYTE 7.
  5102.  
  5103.   SET SERIAL 8N1
  5104.     Equivalent to SET PARITY NONE, SET STOP-BITS 1, SET TERM BYTE 8.
  5105.  
  5106.   SET SERIAL 7E2
  5107.     Equivalent to SET PARITY EVEN and SET STOP-BITS 2, SET TERM BYTE 7.
  5108.  
  5109.   SET SERIAL 8E2
  5110.     Same as SET PARITY HARDWARE EVEN, SET STOP-BITS 2, SET TERM BYTE 8.
  5111.  
  5112.   SET SERIAL
  5113.     Same as SET PARITY NONE and SET STOP-BITS 1, SET TERM BYTE 8.
  5114.  
  5115. Notes:
  5116.  
  5117.  . The SET SERIAL xx2 options are available only in Kermit versions where the
  5118.    SET PARITY HARDWARE command is also available.  (SHOW FEATURES includes
  5119.    "HWPARITY" in its options list.)
  5120.  
  5121.  . The SET SERIAL 7xx and 8N1 options affect the software parity setting, even
  5122.    for network connections.
  5123.  
  5124.  . As noted in the manual, selecting 8 data bits does not give you 8-bit
  5125.    terminal sessions in CONNECT mode unless you also SET TERMINAL BYTESIZE 8.
  5126.    The default terminal bytesize remains 7, to protect against the situation
  5127.    where the remote host is generating parity but you don't know about it.  If
  5128.    the terminal bytesize was 8 by default and you CONNECTed to such a host,
  5129.    you would see only garbage on your screen.
  5130.  
  5131.  . If you do not give a SET STOP-BITS or SET SET SERIAL command, C-Kermit
  5132.    does not attempt to set the device's stop bits; instead, it uses whatever
  5133.    setting the device uses when not given explicit instructions about stop
  5134.    bits.
  5135.  
  5136. SHOW COMMUNICATIONS displays the current settings.  Stop bits and hardware
  5137. parity are shown only for SET PORT / SET LINE (serial) devices, since they
  5138. do not apply to network connections or to remote mode.  STOP-BITS is shown
  5139. as "(default)" if you have not given an explicit SET STOP-BITS or SET SERIAL
  5140. command.
  5141.  
  5142. The \v(serial) variable shows the SET SERIAL setting (8N1, 7E1, etc).
  5143.  
  5144. 2.11. Getting Access to the Dialout Device
  5145.  
  5146.   This section is for UNIX only; note the special words about QNX
  5147.   at the end.  Also see Section 2.0 for SET LINE switches, particularly
  5148.   the /SHARE switch for VMS only.
  5149.  
  5150. C-Kermit does its best to obey the UUCP lockfile conventions of each platform
  5151. (machine, operating system, OS version) where it runs, if that platform uses
  5152. UUCP.
  5153.  
  5154. But simply obeying the conventions is often not good enough, due to the
  5155. increasing likelihood that a particular serial device might have more than one
  5156. name (e.g. /dev/tty00 and /dev/term/00 are the same device in Unixware 7;
  5157. /dev/cua and /dev/cufa are the same device in NeXTSTEP), plus the increasingly
  5158. widespread use of symlinks for device names, such as /dev/modem.
  5159.  
  5160. C-Kermit 7.0 goes to greater lengths than previous versions to successfully
  5161. interlock with other communications program (and other instances of Kermit
  5162. itself); for example, by:
  5163.  
  5164.  . Creation of dual lockfiles whenever a symlink is used; one for the link
  5165.    name and one for the "real" name as revealed by readlink().
  5166.  
  5167.  . Creation of dual lockfiles in HP-UX according to HP rules.
  5168.  
  5169.  . Creation of dual uppercase/lowercase lockfile names in SCO UNIX/ODT/OSR5.
  5170.  
  5171.  . The use of ttylock() in versions of AIX where it works.
  5172.  
  5173.  . The use, wherever possible, of lockfile names based on inode/major/minor
  5174.    device number rather than device name.
  5175.  
  5176. See the ckuins.txt and ckubwr.txt files for details.
  5177.  
  5178. QNX is almost unique among UNIX varieties in having no UUCP programs nor
  5179. UUCP-oriented dialout-device locking conventions.  QNX does, however, allow a
  5180. program to get the device open count.  This can not be a reliable form of
  5181. locking unless all applications do it (and they don't), so by default, Kermit
  5182. uses this information only for printing a warning message such as:
  5183.  
  5184.   C-Kermit>set line /dev/ser1
  5185.   WARNING - "/dev/ser1" looks busy...
  5186.  
  5187. However, if you want to use it as a lock, you can do so with:
  5188.  
  5189.   SET QNX-PORT-LOCK { ON, OFF }
  5190.  
  5191. QNX-PORT-LOCK is OFF by default; if you set in ON, C-Kermit fails to open
  5192. any dialout device when its open count indicates that another process has it
  5193. open.  SHOW COMM (in QNX only) displays the setting, and if you have a port
  5194. open, it also shows the current open count (with C-Kermit's own access
  5195. always counting as 1).
  5196.  
  5197. 2.12. The Connection Log
  5198.  
  5199. C-Kermit 7.0 adds the ability to log connections, so you can see where you've
  5200. been and have a record of calls you've made.  A connection is defined as any
  5201. communications session that is begun by SET LINE, SET PORT, DIAL, SET HOST,
  5202. TELNET, or RLOGIN.  Connections are not logged unless you request it; the
  5203. command is:
  5204.  
  5205. LOG CX [ filename [ { NEW, APPEND } ] ]
  5206.   Enables logging of connections in the given file.  If the trailing
  5207.   { NEW, APPEND } keyword is omitted, the file is opened for appending;
  5208.   i.e. new records are written to the end.  If NEW is specified, a new
  5209.   file is created; if a file of the same name already existed, it is
  5210.   overwritten.  If the filename is omitted, CX.LOG in your home (login)
  5211.   directory is used (note: uppercase).  To accept all defaults, just use
  5212.   "log connections" (or "l c" for short).  Synonym: LOG CONNECTIONS.
  5213.  
  5214. CLOSE CX-LOG
  5215.   This closes the connection log if it was open.  (Note, the CLOSE CONNECTION
  5216.   command closes the connection itself).
  5217.  
  5218. SHOW CX
  5219.   This shows your current connection, if any, including the elapsed time
  5220.   (since you opened it).  Synonym: SHOW CONNECTION.
  5221.  
  5222. \v(cx_time)
  5223.   This variable shows the elapsed time of your current connection, or if
  5224.   there is no current connection, of your most recent connection, of if there
  5225.   have been no connections, 0.
  5226.  
  5227. The connection contains one line per connection, of the form:
  5228.  
  5229.   yyyymmdd hh:mm:ss username pid p=v [ p=v [ ... ] ]
  5230.  
  5231. where the timestamp (in columns 1-18) shows when the connection was made;
  5232. username is the login identity of the person who made the connection; pid is
  5233. Kermit's process ID when it made the connection.  The p's are parameters that
  5234. depend on the type of connection, and the v's are their values:
  5235.  
  5236.   T = Connection Type (TCP, SERIAL, DIAL, DECNET, etc).
  5237.   H = The name of the Host from which the connection was made.
  5238.   N = Destination phone Number or Network host name or address.
  5239.   D = Serial connections only: Device name.
  5240.   O = Dialed calls only: Originating country code & area code if known.
  5241.   E = Elapsed time in hh:mm:ss format (or hhh:mm:ss, etc).
  5242.  
  5243. If you always want to keep a connection log, simply add:
  5244.  
  5245.   log connections
  5246.  
  5247. to your C-Kermit customization file.  Note, however, that if you make a lot of
  5248. connections, your CX.LOG will grow and grow.  You can handle this by adding a
  5249. "logrotate" procedure like the following to your customization file, before
  5250. the "log connections" command:
  5251.  
  5252.   define LOGROTATE {                    ; Define LOGROTATE macro
  5253.       local \%i \%m \%d \%n \%f MAX
  5254.       def MAX 4                         ; How many months to keep
  5255.       if not def \%1 -                  ; No argument given
  5256.     end 1 \%0: No filename given
  5257.       if not = 1 \ffiles(\%1) -         ; Exactly 1 file must match
  5258.     end 1 \%0: \%1 - File not found
  5259.       .\%d := \fsubstr(\fdate(\%1),1,6) ; Arg OK - get file year & month
  5260.       if = \%d -                        ; Compare file year & month
  5261.         \fsubstr(\v(ndate),1,6) -       ; with current year & month
  5262.       end 0                         ; Same year & month - done
  5263.       rename \%1 \%1.\%d                ; Different - rename file
  5264.       .\%n := \ffiles(\%1.*)            ; How many old files
  5265.       if < \%n \m(MAX) end 0            ; Not enough to rotate
  5266.       .\%m := \%1.999999                ; Initial compare string
  5267.       for \%i 1 \%n 1 {                 ; Loop thru old logs
  5268.      .\%f := \fnextfile()           ; Get next file name
  5269.      if llt \%f \%m .\%m := \%f     ; If this one older remember it
  5270.       }
  5271.       delete \%m                        ; Delete the oldest one
  5272.   }
  5273.   log connections                       ; Now open the (possibly new) log
  5274.   logrotate \v(home)CX.LOG              ; Run the LOGROTATE macro
  5275.  
  5276. As you can see, this compares the yyyymm portion of the modification date
  5277. (\fdate()) of the given file (\%1) with the current yyyymm.  If they differ,
  5278. the current file has the yyyymm suffix (from its most recent modification
  5279. date) appended to its name.  Then we search through all other such files, find
  5280. the oldest one, and delete it.  Thus the current log, plus the logs from the
  5281. most recent four months, are kept.  This is all done automatically every time
  5282. you start C-Kermit.
  5283.  
  5284. On multiuser systems, it is possible to keep a single, shared, system-wide
  5285. connection log, but this is not recommended since (a) it requires you keep a
  5286. publicly write-accessible logfile (a glaring target for mischief), and (b) it
  5287. would require each user to log to that file and not disable logging.  A better
  5288. method for logging connections, in UNIX at least, is syslogging (see
  5289. ckuins.txt Section 15 and iksd.txt Section 4.2 for details).
  5290.  
  5291. 2.13. Automatic Connection-Specific Flow Control Selection
  5292.  
  5293. Beginning in C-Kermit 7.0, the appropriate flow-control method for each
  5294. connection type is kept in a table, for example:
  5295.  
  5296.   Remote:           NONE
  5297.   Modem:            RTS/CTS
  5298.   Direct-Serial:    NONE
  5299.   TCPIP:            NONE
  5300.  
  5301. The size of the table and values for each connection type can vary from
  5302. platform to platform.  Type "set flow ?" for a list of available flow-control
  5303. types.
  5304.  
  5305. The table is used to automatically select the appropriate kind of flow
  5306. control whenever you make a connection.  You can display the table with:
  5307.  
  5308.   SHOW FLOW-CONTROL
  5309.  
  5310. The defaults are as follows:
  5311.  
  5312. Remote:
  5313.   NONE or XON/XOFF.  This is because C-Kermit is not allowed to find out what
  5314.   type of connection the incoming user has (*).  No kind of flow control will
  5315.   work on every kind of connection, including (unexpectedly) KEEP, which we
  5316.   would have liked to use, but not turning off flow control at the remote end
  5317.   during file transfer on TCP/IP connections is fatal to the transfer (except
  5318.   in VMS and HP-UX, where it must be set to Xon/Xoff!)  Therefore if you are
  5319.   dialing in to a serial port on a server (UNIX or VMS) where C-Kermit is
  5320.   running, you will need to tell C-Kermit to "set flow keep" before
  5321.   transferring files (assuming the modem and port are configured correctly by
  5322.   the system administrator; otherwise you'll need to give a specific kind of
  5323.   flow control, e.g. "set flow xon/xoff"), so in this case C-Kermit will not
  5324.   disable flow control, as it must do when you are coming via Telnet (directly
  5325.   or through a terminal server, except on VMS and HP-UX).
  5326.  
  5327. Modem:
  5328.   This applies when you dial out with a modem.  In this case, the MODEM
  5329.   FLOW-CONTROL setting takes affect after the SET FLOW setting, so it can pick
  5330.   the most appropriate flow control for the combination of the particular
  5331.   modem and the computer/port/driver that is dialing.
  5332.  
  5333. Direct-Serial:
  5334.   The default here is NONE because C-Kermit has no way of knowing what kind
  5335.   of flow control, if any, is or can be done by the device at the other end
  5336.   of the connection.  RTS/CTS would be a bad choice here, because if the CTS
  5337.   signal is not asserted, the connection will hang.  And since direct
  5338.   connections are often made with 3-wire cables, there is a good chance the
  5339.   CTS signal will not be received.
  5340.  
  5341. TCPIP:
  5342.   NONE, since TCP and IP provide their own flow control transparently to the
  5343.   application, except in VMS, where Xon/Xoff is the default due to the
  5344.   requirements of the VMS TCP/IP products.
  5345.  
  5346. Other networks:
  5347.   NONE, since networks should provide their flow control transparently to the
  5348.   application.
  5349.  
  5350. (*) This is possibly the worst feature of UNIX, VMS, and other platforms
  5351.     where C-Kermit runs.  If C-Kermit was able to ask the operating system
  5352.     what kind of connection it had to the user, it could set up many things
  5353.     for you automatically.
  5354.  
  5355. You can modify the default-flow-control table with:
  5356.  
  5357.   SET FLOW-CONTROL /xxx { NONE, KEEP, RTS/CTS, XON/XOFF, ... }
  5358.  
  5359. where "xxx" is the connection type, e.g.
  5360.  
  5361.   SET FLOW /REMOTE NONE
  5362.   SET FLOW /DIRECT RTS/CTS
  5363.  
  5364. If you leave out the switch, SET FLOW works as before, choosing the flow
  5365. control method to be used on the current connection:
  5366.  
  5367.   SET FLOW XON/XOFF
  5368.  
  5369. Thus, whenever you make a connection with SET PORT, SET LINE, DIAL, SET HOST,
  5370. TELNET, RLOGIN, etc, an appropriate form of flow control is selected
  5371. automatically.  You can override the automatic selection with a subsequent
  5372. SET FLOW command, such as SET FLOW NONE (no switch included).
  5373.  
  5374. The flow control is changed automatically too when you give a SET MODEM TYPE
  5375. command.  For example, suppose your operating system (say Linux) supports
  5376. hardware flow control (RTS/CTS).  Now suppose you give the following
  5377. commands:
  5378.  
  5379.   set line /dev/ttyS2    ; Automatically sets flow to NONE
  5380.   set modem type usr     ; Automatically sets flow to RTS/CTS
  5381.   set modem type rolm    ; Doesn't support RTS/CTS so now flow is XON/XOFF
  5382.  
  5383. IMPORTANT: This new feature tends to make the order of SET LINE/HOST and
  5384. SET FLOW commands matter, where it didn't before.  For example, in VMS:
  5385.  
  5386.   SET FLOW KEEP
  5387.   SET LINE TTA0:
  5388.  
  5389. the SET LINE undoes the SET FLOW KEEP command; the sequence now must be:
  5390.  
  5391.   SET FLOW /DIRECT KEEP
  5392.   SET LINE TTA0:
  5393.  
  5394. or:
  5395.  
  5396.   SET LINE TTA0:
  5397.   SET FLOW KEEP
  5398.  
  5399. 2.14. Trapping Connection Establishment and Loss
  5400.  
  5401. If you define a macro called ON_OPEN, it is executed any time that a SET LINE,
  5402. SET PORT, SET HOST, TELNET, RLOGIN or similar command succeeds in opening a
  5403. connection.  The argument is the host or device name (as shown by SHOW
  5404. COMMUNICATIONS, and the same as \v(line)).  This macro can be used for all
  5405. sorts of things, like automatically setting connection- or host-specific
  5406. parameters when the connection is opened.  Example:
  5407.  
  5408.   def ON_OPEN {
  5409.       switch \%1 {
  5410.         :abccorp.com, set reliable off, break
  5411.         :xyzcorp.com, set receive packet-length 1000, break
  5412.         etc etc...
  5413.       }
  5414.   }
  5415.  
  5416. If you define a macro called ON_CLOSE, it will be executed any time that
  5417. a SET LINE, SET PORT, SET HOST, TELNET, RLOGIN or any other kind of connection
  5418. that C-Kermit has made is closed, either by the remote or by a local CLOSE,
  5419. HANGUP, or EXIT command or other local action, such as when a new connection
  5420. is opened before an old one was explicitly closed.
  5421.  
  5422. As soon as C-Kermit notices the connection has been closed, the ON_CLOSE macro
  5423. is invoked at (a) the top of the command parsing loop, or (b) when a
  5424. connection is closed implicitly by a command such as SET LINE that closes any
  5425. open connection prior to making a new connection, or (c) when C-Kermit closes
  5426. an open connection in the act of exiting.
  5427.  
  5428. The ON_CLOSE macro was inspired by the neverending quest to unite Kermit and
  5429. SSH (*).  In this case using the "tunnel" mechanism:
  5430.  
  5431.   def TUNNEL {                                ; \%1 = host to tunnel to
  5432.       local \%p
  5433.       if not def \%1 stop 1
  5434.       assign tunnelhost \%1                   ; Make global copy
  5435.       undef on_close
  5436.       set macro error off
  5437.       close connection                        ; Ignore any error
  5438.       open !read tunnel start \%1
  5439.       read \%p                                ; Get port number
  5440.       if fail stop 1 Tunnel failure: \%1
  5441.       close read
  5442.       if fail stop 1 Tunnel failure: \%1      ; See Section 4.2.8.1
  5443.       assign on_close {                       ; Set up close handler
  5444.           echo Closing tunnel: \m(tunnelhost)
  5445.           !tunnel stop \m(tunnelhost)
  5446.           undef on_close
  5447.       }
  5448.       set host localhost:\%p /telnet
  5449.       if success end 0
  5450.       undef on_close
  5451.       stop 1 Connection failure: \%1
  5452.   }
  5453.  
  5454. In this case, when the connection stops, we also need to shut down the tunnel,
  5455. even if it is at a later time after TUNNEL has finished executing.  This way
  5456. we can escape back, reconnect, transfer files, and so on until the connection
  5457. is broken by logging out from the remote, or by explicitly closing it, or by
  5458. EXITing from C-Kermit, at which time the tunnel is shut down.
  5459.  
  5460. When the connection is closed, no matter how, the ON_CLOSE macro executes
  5461. and then undefines (destroys) itself, since we don't want to be closing
  5462. tunnels in the future when we close subsequent connections.
  5463.  
  5464. Other such tricks can be imagined, including ending ON_CLOSE with a STOP
  5465. command to force the command stack to be peeled all the way back to the top,
  5466. for example in a deeply nested script that depends on the connection being
  5467. open:
  5468.  
  5469.   def on_close { stop 1 CONNECTION LOST }
  5470.  
  5471. When C-Kermit invokes the ON_CLOSE macro, it supplies one argument (\%1):
  5472. the reason the connection was closed as a number, one of the following:
  5473.  
  5474.   2 - Fatal failure to negotiate a required item on a network connection.
  5475.   1 - Closed by C-Kermit command.
  5476.   0 - All others (normally closed by remote).
  5477.  
  5478. which may be used for any purpose; for example, to add a comment to the
  5479. connection log:
  5480.  
  5481.   def on_close {
  5482.       local \%m
  5483.       if not open cx end 0
  5484.       switch \%1 {
  5485.         :0, .\%m = Closed by remote, break
  5486.         :1, .\%m = Closed by me, break
  5487.         :2, .\%m = Network protocol negotiation failure, break
  5488.       }
  5489.       if def \%m writeln cx {# \%m}
  5490.   }
  5491.  
  5492. (*) SSH can not be included in C-Kermit due to licensing, patent, and
  5493.     USA export law restrictions.  Furthermore, the 'ssh' client that is
  5494.     distributed for UNIX can not be run by C-Kermit's PIPE command because
  5495.     it does not use standard i/o.
  5496.  
  5497. 2.15. Contacting Web Servers with the HTTP Command
  5498.  
  5499. C-Kermit 7.0 (at this writing, the UNIX version only) supports direct contact
  5500. and interaction with Web servers via HTTP 1.0 protocol.  To make a connection,
  5501. use Kermit's normal method for making a TCP/IP connection, but specify the
  5502. HTTP port:
  5503.  
  5504.   SET HOST <host> http [ <switches> ]
  5505.  
  5506. where <host> is the IP hostname or address, and http is the name of the
  5507. TCP port for the Web server.  Relevant switches include:
  5508.  
  5509. /RAW
  5510.   Treat the connection as a transparent binary pipe.  This switch may be
  5511.   required if a port other than 'http' is used.
  5512.  
  5513. /SSL
  5514.   Make an secure private connection with SSL (only if SSL support is included
  5515.   in your version of Kermit).  In this case the port name might need to be
  5516.   https rather than http, e.g. "set host secureserver.xyxcorp.com https /ssl".
  5517.  
  5518. /TLS
  5519.   Make an secure private connection with TLS (only if TLS support is included
  5520.   in your version of Kermit).  In this case the port name would be https
  5521.   rather than http.
  5522.  
  5523. Then you can issue an HTTP command.  In most cases, the server closes the
  5524. connection when the command is complete.  Example:
  5525.  
  5526.   SET HOST www.columbia.edu http
  5527.   IF FAIL EXIT 1 Can't contact server
  5528.   HTTP GET kermit/index.html
  5529.  
  5530. At this point the connection is closed, since that's how HTTP 1.0 works.  If
  5531. you want to perform additional operations, you must establish a new connection
  5532. with another SET HOST command.
  5533.  
  5534. The HTTP command acts as a client to the Web server, except instead of
  5535. displaying the results like a Web browser would, it stores them.  Any HTTP
  5536. command can (but need not) include any or all of the following switches:
  5537.  
  5538. /AGENT:<user-agent>
  5539.   Identifies the client to the server; "C-Kermit" or "Kermit-95"
  5540.   by default.
  5541.  
  5542. /HEADER:<header-line>
  5543.   Used for specifying any optional headers.  A list of headers is provided
  5544.   using braces for grouping:
  5545.  
  5546.     /HEADER:{{<tag>:<value>}{<tag>:<value>}...}
  5547.  
  5548.   For a listing of valid <tag> value and <value> formats see RFC 1945:
  5549.   "Hypertext Transfer Protocol -- HTTP/1.0".  A maximum of eight headers
  5550.   may be specified.
  5551.  
  5552. /USER:<name>
  5553.   In case a page requires a username for access.
  5554.  
  5555. /PASSWORD:<password>
  5556.   In case a page requires a password for access.
  5557.  
  5558. /ARRAY:<arrayname>
  5559.   Tells Kermit to store the response headers in the given array, one line per
  5560.   element.  The array need not be declared in advance.  Example:
  5561.  
  5562.     http /array:c get kermit/index.html
  5563.     show array c
  5564.     Dimension = 9
  5565.     1. Date: Fri, 26 Nov 1999 23:12:22 GMT
  5566.     2. Server: Apache/1.3.4 (Unix)
  5567.     3. Last-Modified: Mon, 06 Sep 1999 22:35:58 GMT
  5568.     4. ETag: "bc049-f72-37d441ce"
  5569.     5. Accept-Ranges: bytes
  5570.     6. Content-Length: 3954
  5571.     7. Connection: close
  5572.     8. Content-Type: text/html
  5573.  
  5574. As you can see, the header lines are like MIME e-mail header lines:
  5575. identifier, colon, value.  The /ARRAY switch is the only method available
  5576. to a script to process the server responses for a POST or PUT command.
  5577.  
  5578. The HTTP commands are:
  5579.  
  5580. HTTP [ <switches> ] GET <remote-filename> [ <local-filename> ]
  5581.   Retrieves the named file.  If a <local-filename> is given, the file is
  5582.   stored locally under that name; otherwise it is stored with its own name.
  5583.  
  5584. HTTP [ <switches> ] HEAD <remote-filename> <local-filename>
  5585.   Like GET except without actually getting the file; instead it gets only
  5586.   the headers, storing them into the given file, whose name must be given,
  5587.   one line per header item, as shown above in the /ARRAY: switch description.
  5588.  
  5589. HTTP [ <switches> ] INDEX <remote-directory> [ <local-filename> ]
  5590.   Retrieves the file listing for the given server directory.
  5591.   NOTE: This command is not supported by most Web servers.
  5592.  
  5593. HTTP [ <switches> ] POST [ /MIME-TYPE:<type> ] <local-file> <remote-file>
  5594.   Used to send a response as if it were sent from a form.  The data to be
  5595.   posted must be read from a file.
  5596.  
  5597. HTTP [ <switches> ] PUT [ /MIME-TYPE:<type> ] <local-file> <remote-file>
  5598.   Uploads a local file to a server file.
  5599.  
  5600. HTTP [ <switches> ] DELETE <remote-filename>
  5601.   Instructs the server to delete the specified filename.
  5602.  
  5603.  
  5604. (3) TERMINAL CONNECTION
  5605.  
  5606. 3.1. CONNECT Command Switches
  5607.  
  5608. The following switches (see section 1.5) were added to the CONNECT command
  5609. in 7.0:
  5610.  
  5611.   /QUIETLY
  5612.     Don't print the "Connecting to..." or "Back at..." messages.
  5613.     CQ is an invisible command synonym for CONNECT /QUIETLY.
  5614.  
  5615.   /TRIGGER:string
  5616.     Specify a trigger or triggers (Section 3.2) effective for this CONNECT
  5617.     command only, temporarily overriding any current SET TERMINAL TRIGGER
  5618.     values (Section 3.2).
  5619.  
  5620. Note: Other switches might also be available; type "connect ?" for a list,
  5621. "help connect" for a description of each.
  5622.  
  5623. 3.2. Triggers
  5624.  
  5625. Triggers were added for UNIX, VMS, AOS/VS, and K95 in C-Kermit 7.0.
  5626.  
  5627. SET TERMINAL TRIGGER string
  5628.   Tells C-Kermit to look for the given string during all subsequent CONNECT
  5629.   sessions, and if seen, to return to command mode automatically, as if you
  5630.   had escaped back manually.  If the string includes any spaces, you must
  5631.   enclose it in braces.  Example:
  5632.  
  5633.     SET TERMINAL TRIGGER {NO CARRIER}
  5634.  
  5635. Comparisons are made after character-set translation.
  5636.  
  5637. If a string is to include a literal brace character, precede it with a
  5638. backslash:
  5639.  
  5640.     ; My modem always makes this noise when the connection is lost:
  5641.     SET TERMINAL TRIGGER |||ppp\{\{\{\{UUUUUUU
  5642.  
  5643. If you want Kermit to look for more than one string simultaneously, use the
  5644. following syntax:
  5645.  
  5646.     SET TERMINAL TRIGGER {{string1}{string2}...{stringn}}
  5647.  
  5648. In this case, C-Kermit will return to command mode automatically if any of
  5649. the given strings is encountered.  Up to 8 strings may be specified.
  5650.  
  5651. If the most recent return to command mode was caused by a trigger, the new
  5652. variable, \v(trigger), shows the trigger value; otherwise \v(trigger) is
  5653. empty.
  5654.  
  5655. The SHOW TRIGGER command displays the SET TERMINAL TRIGGER values as well as
  5656. the \v(trigger) value.
  5657.  
  5658. 3.3. Transparent Printing
  5659.  
  5660. As noted in the manual, C-Kermit's CONNECT command on UNIX is not a terminal
  5661. emulator, but rather a "semitransparent pipe" between the terminal or emulator
  5662. you are using to access C-Kermit, and the remote host to which C-Kermit is
  5663. connected.  The "semitransparent" qualifier is because of character-set
  5664. translation as well as several actions taken by the emulator in response to
  5665. the characters or strings that pass through it, such as APCs, Kermit packets
  5666. (autodownload), triggers, etc.
  5667.  
  5668. The UNIX version of C-Kermit 7.0 adds another such action: Transparent
  5669. printing, also called Controller printing (as distinct from Autoprint or line
  5670. or screen print).  It is intended mainly for use on UNIX workstation consoles
  5671. (as opposed to remote logins), but with some care can also be used when
  5672. accessing C-Kermit remotely.
  5673.  
  5674. Transparent printing is related to APC by sharing C-Kermit's built-in ANSI
  5675. escape-sequence parser to detect "printer on" and "printer off" sequences from
  5676. the host.  When the printer-on sequence is received, all subsequent arriving
  5677. characters -- including NUL, control characters, and escape sequences --
  5678. are sent to the SET PRINTER device instead of to your screen until
  5679. the printer-off sequence is received, or you escape back, whichever happens
  5680. first.  These bytes are not translated or modified or filtered in any way
  5681. by Kermit (except for possibly stripping of the 8th bit, as noted below), but
  5682. if filtering or translation is desired, this can be accomplished by your
  5683. SET PRINTER selection (e.g. by choosing a pipeline of filters).
  5684.  
  5685. By default, your SET PRINTER device is your default UNIX printer, but
  5686. it can also be a file, a command, or the null device (which causes all printer
  5687. material to be discarded).  See "Using C-Kermit", 2nd Ed., p.41 for details.
  5688.  
  5689. Transparent printing is controlled by the command:
  5690.  
  5691. SET TERMINAL PRINT { ON, OFF }
  5692.   When ON, transparent-print sequences are obeyed, and printing occurs on the
  5693.   system where C-Kermit is running.  When OFF, transparent print sequences are
  5694.   ignored and passed through to your actual terminal or emulator, along with
  5695.   the data they enclose.  OFF is the default, for compatibility with earlier
  5696.   C-Kermit releases.  As noted in the manual, when the current SET PRINTER
  5697.   device is a file, transparent-print material is appended to it; the file is
  5698.   not overwritten.
  5699.  
  5700. SET TERMINAL BYTESIZE { 7, 8 }
  5701. SET PARITY { EVEN, ODD, MARK, SPACE, NONE }
  5702.   If the terminal bytesize is 7, or PARITY is not NONE, the 8th bit of each
  5703.   byte is stripped prior to printing.
  5704.  
  5705. The transparent-print escape sequences are:
  5706.  
  5707. <ESC>[5i
  5708.   Printer On.  Send all subsequent incoming bytes to the printer without
  5709.   any kind of filtering, translation, or alteration.  Note: <ESC> stands for
  5710.   ASCII character number 27 (decimal), Escape.
  5711.  
  5712. <ESC>[4i
  5713.   Printer Off.  Resume displaying incoming bytes on the screen.
  5714.  
  5715. These are the same sequences used by DEC VT100 and higher terminals and other
  5716. ANSI X3.64 and ISO 6429 compatible terminals.  There is no provision for
  5717. selecting other printer-control sequences.
  5718.  
  5719. Restrictions:
  5720.  
  5721.  1. You must SET TERM TRANSPARENT-PRINT ON before you can use this feature.
  5722.  
  5723.  2. Only the 7-bit forms of the escape sequences are supported.  The 8-bit
  5724.     CSI C1 control is not recognized.
  5725.  
  5726.  3. Autoprint is not supported, since this requires a full-fledged terminal
  5727.     emulator with direct access to the screen.
  5728.  
  5729.  4. The start-print and stop-print sequences pass through to the screen (there
  5730.     is no way to avoid this without causing unacceptable delays or deadlocks
  5731.     in CONNECT mode).  Thus if your terminal or emulator also supports
  5732.     transparent printing via these same sequences, an empty file will be sent
  5733.     to its printer.  Normally this has no effect.
  5734.  
  5735. Point (4) is similar to the situation with autodownload and APC -- when you
  5736. have several Kermit clients in a chain, you should take care that these
  5737. features are enabled in only one of them.
  5738.  
  5739. Example 1:
  5740.  
  5741.   set printer {|lpr -Plaser}  ; Specify the printer (if not default).
  5742.   set term print on           ; Enable transparent printing.
  5743.   set term byte 8             ; Enable 8-bit characters.
  5744.   connect                     ; Enter CONNECT mode.
  5745.  
  5746. Example 2:
  5747.  
  5748.   set printer /home/users/olga/printer.log  ; Send printer material to a file.
  5749.  
  5750. Example 3:
  5751.  
  5752.   set printer {| grep -v ^Received | lpr}   ; Filter out some lines
  5753.  
  5754. Then use "pcprint" or "vtprint" commands on the host to initiate transparent
  5755. print operations.  See "Using C-Kermit", 2nd Ed., p.406 for details.
  5756.  
  5757. Here is a sample "pcprint" shell script for UNIX:
  5758.  
  5759. #!/bin/sh
  5760. echo -n '<ESC>[5i'
  5761. if [ $# -eq 0 ]; then
  5762.   cat
  5763. else
  5764.   cat $*
  5765. fi
  5766. echo -n '<FF><ESC>[4i'
  5767. # (end)
  5768.  
  5769. (Replace "<ESC>" by the actual ASCII Escape character and "<FF>" by the
  5770. ASCII Formfeed character).
  5771.  
  5772. If you always want transparent printing enabled, put "set term print on"
  5773. in your C-Kermit customization file (~/.mykermrc in UNIX).  The "set term
  5774. bytesize" selection, however, is a property of each separate connection.
  5775.  
  5776. 3.4. Binary and Text Session Logs
  5777.  
  5778. C-Kermit 7.0 corrects an oversight in earlier releases, in which binary
  5779. session logs (SET SESSION-LOG BINARY) translated character sets and performed
  5780. various formatting transformations (e.g. "newline mode") before writing
  5781. characters to the session log.  In C-Kermit 7.0, binary-mode session logging
  5782. writes characters as they come in, before anything (other that parity-bit
  5783. stripping) is done to them.  Text-mode session logging records the characters
  5784. after processing.
  5785.  
  5786. (4) FILE TRANSFER
  5787.  
  5788. Every file is transferred either in text mode (which implies record-format
  5789. and character-set translation) or binary mode (in which each byte is sent
  5790. literally without any kind of conversion).  The mode in which a file is
  5791. transferred is controlled by (a) the default mode, in the absence of any
  5792. other indications; (b) the SET FILE TYPE command; (c) various automatic
  5793. mechanisms based on client/server negotiations, directory information or
  5794. filename patterns, etc.
  5795.  
  5796. The default FILE TYPE was changed from TEXT to BINARY in C-Kermit 7.0
  5797. because:
  5798.  
  5799.  . Transferring a text file in binary mode does less damage than
  5800.    transferring a binary file in text mode.
  5801.  
  5802.  . Only binary-mode transfers can be recovered from the point of failure.
  5803.  
  5804.  . The automatic transfer-mode mechanisms switch to text mode on a per-file
  5805.    basis anyway, so only those files that are not covered by the automatic
  5806.    mechanisms are affected.
  5807.  
  5808.  . All file transfers on the Web are done in binary mode, so people are
  5809.    accustomed to it and expect it.
  5810.  
  5811. 4.0. BUG FIXES, MINOR CHANGES, AND CLARIFICATIONS
  5812.  
  5813. 4.0.0. Filenames with Spaces
  5814.  
  5815. Filenames that contain spaces are a major nuisance to a program like Kermit,
  5816. whose command language is line- and word-oriented, in which words are
  5817. separated by spaces and a filename is assumed to be a "word".  In general
  5818. (unless noted otherwise in the description of a particular command), there is
  5819. only one way to refer to such files in Kermit commands, and that is to enclose
  5820. the name in braces:
  5821.  
  5822.   send {this file}
  5823.  
  5824. Tells Kermit to send the file whose name is "this file" (two words, no
  5825. quotes).  Of course, various circumlocutions are also possible, such as:
  5826.  
  5827.   define \%a this file
  5828.   send \%a
  5829.  
  5830. BUT, perhaps contrary to expectation, you can't use "\32" to represent the
  5831. space:
  5832.  
  5833.   send this\32file
  5834.  
  5835. does not work.  Why?  Because the Kermit parser, which must work on many
  5836. operating systems including Windows, has no way of knowing what you mean by
  5837. "this\32file".  Do you mean a file whose name is "this file" in the current
  5838. directory?  Or do you mean a file whose name is "32file" in the "this"
  5839. subdirectory of the current directory?  Guessing won't do here; Kermit must
  5840. behave consistently and deterministically in all cases on all platforms.
  5841.  
  5842. Note that you can't use Esc or Tab within {...} for filename completion,
  5843. or question mark to get a filename list.  However, you can include wildcards;
  5844. for example:
  5845.  
  5846.   send {* *}
  5847.  
  5848. sends all files whose name contains a space.
  5849.  
  5850. All things considered, it is best to avoid spaces in file and directory names
  5851. if you can.  Also see Section 5.4 on this topic.
  5852.  
  5853. 4.0.1. Packet out of Window
  5854.  
  5855. C-Kermit 6.0 could send packets "out of window" if the window size was
  5856. greater than 1 and ACKs had arrived out of order.  Fixed in 6.1.
  5857.  
  5858. 4.0.2. MOVE after ADD SEND-LIST
  5859.  
  5860. ADD SEND-LIST followed by MOVE did not delete original files; fixed in 6.1.
  5861. Carrier loss was not detected during transfer; in 7.0 C-Kermit checks for
  5862. this (but results can not be guaranteed).  In any case, the protocol will
  5863. eventually time out if the connection is lost.
  5864.  
  5865. 4.0.3. GET and RECEIVE As-Names
  5866.  
  5867. In 5A(190) through 6.0.192, the GET and RECEIVE as-name did not properly
  5868. override the RECEIVE PATHNAMES setting.  In 7.0 it does.
  5869.  
  5870. 4.0.4. New Brief Statistics Listing
  5871.  
  5872. Version 7.0 adds a /BRIEF switch to the STATISTICS command, to display a short
  5873. file-transfer statistics report.  /BRIEF is now the default.  Use /VERBOSE to
  5874. see the full display, which is about 25 lines long.
  5875.  
  5876. 4.0.5. Improved FAST Command
  5877.  
  5878. The preinstalled definition of the FAST macro did not take enough factors into
  5879. account.  Now it sets packet lengths and window sizes appropriate to the
  5880. configuration.  Furthermore, in IRIX only, it might restrict the SEND packet
  5881. length to 4000, to work around a bug in the IRIX Telnet server, depending on
  5882. the IRIX version (see ckubwr.txt, IRIX section).  To see the built-in
  5883. definition of the FAST macro, type "show macro fast".  To change it, simply
  5884. define it to be whatever you want -- it's just a macro, like any other.
  5885.  
  5886. 4.0.6. The SET SEND BACKUP Command
  5887.  
  5888. Version 7.0 adds SET SEND BACKUP { ON, OFF }.  This tells whether backup
  5889. files should be sent.  Backup files are the ones created by Kermit (and EMACS,
  5890. and possibly other applications) to preserve old copies of files when creating
  5891. new ones with the same name.  Kermit does this when receiving a file and its
  5892. FILE COLLISION setting is BACKUP (or RENAME, in which case it the new file
  5893. gets the backup name).  On most platforms, the backup name is formed by adding:
  5894.  
  5895.   .~n~
  5896.  
  5897. to the end of the filename, where "n" is a number.  For example, if the
  5898. original file is oofa.txt, a backup file might be called:
  5899.  
  5900.   oofa.txt.~1~
  5901.  
  5902. (or oofa.txt.~2~, etc).  If you SET SEND BACKUP OFF, this tells Kermit not to
  5903. send files that have backup names.  Normally, SET SEND BACKUP is ON (as shown
  5904. by SHOW PROTOCOL), and backup files are sent if their names match the SEND
  5905. file specification.
  5906.  
  5907. Also see PURGE, SET FILE COLLISION, SEND /NOBACKUP, DIRECTORY /[NO]BACKUP.
  5908.  
  5909. 4.0.7. The SET { SEND, RECEIVE } VERSION-NUMBERS Command
  5910.  
  5911. VMS Only.  Normally when sending files, VMS C-Kermit strips the version
  5912. number.  For example, if the file is FOO.BAR;34, the name is sent as FOO.BAR
  5913. (without the ";34").  If you want to keep version numbers on when sending
  5914. files, use SET SEND VERSION-NUMBERS ON.  The effect depends on the receiver.
  5915.  
  5916. Normally when receiving files, and an incoming filename includes a VMS-style
  5917. version number (such as FOO.BAR;34) VMS C-Kermit strips it before trying to
  5918. create the new file; this way the new file receives the next highest version
  5919. number in the customary manner for VMS.  If you want version numbers on
  5920. incoming filenames to be used in creating the new files, use SET RECEIVE
  5921. VERSION-NUMBERS ON.
  5922.  
  5923. Normally these commands would be effective only when VMS C-Kermit is
  5924. exchanging files with a non-VMS Kermit program, since VMS-to-VMS transfers use
  5925. labeled mode unless you have gone out of your way to defeat it.
  5926.  
  5927. Example: You want to send all versions of all files in the current directory
  5928. from a VMS C-Kermit client to a UNIX C-Kermit server.  Use:
  5929.  
  5930.   set send version-numbers on
  5931.   send *.*;*
  5932.  
  5933. The resulting Unix files will have VMS-style version numbers as part of their
  5934. name, for example "foo.bar;1", "foo.bar;2", etc.
  5935.  
  5936. Now suppose you want to send these files from Unix to another VMS system and
  5937. preserve the version numbers.  Again we have a Unix C-Kermit server and VMS
  5938. C-Kermit client.  Give these commands to the client:
  5939.  
  5940.   set receive version-numbers on
  5941.   get *
  5942.  
  5943. 4.0.8. The SET { SEND, RECEIVE } { MOVE-TO, RENAME-TO } Commands
  5944.  
  5945. These commands are persistent global versions of the /MOVE-TO: and
  5946. /RENAME-TO: switches of the SEND, GET, and RECEIVE commands.  They should
  5947. normally be used only when setting up a dedicated transaction-processing
  5948. application, in which each file is to be moved or renamed immediately after,
  5949. and only if, it is transferred successfully, so that (for example) an
  5950. independent, concurrent process can notice when new files appear and process
  5951. them immediately without having to guess whether they are complete.
  5952.  
  5953. 4.0.9. SET FILE INCOMPLETE AUTO
  5954.  
  5955. SET FILE INCOMPLETE { KEEP, DISCARD }, which tells whether to keep or discard
  5956. incompletely received files, has a new option, AUTO, which is also the
  5957. default.  It means KEEP the incomplete file if the transfer is in binary mode,
  5958. otherwise DISCARD it.  This reduces the chances that a subsequent recovery
  5959. operation (RESEND, REGET, etc) could produce a corrupt file, since recovery
  5960. works only for binary-mode transfers.
  5961.  
  5962. 4.1. FILE-TRANSFER FILENAME TEMPLATES
  5963.  
  5964. File-transfer filename templates allow files to be renamed automatically by
  5965. the file sender, the receiver, or both, during transfer of groups of files.
  5966.  
  5967. 4.1.1. Templates in the As-Name
  5968.  
  5969. Prior to C-Kermit 6.1 and Kermit 95 1.1.12 the only options that could be
  5970. used to affect the names of files being transferred were SET FILENAMES
  5971. { LITERAL, CONVERTED } and SET { SEND, RECEIVE } PATHNAMES { ON, OFF }, plus
  5972. the "as-name" feature of the SEND (MOVE, etc) and RECEIVE commands.
  5973.  
  5974. Previously, the as-name could be used only for a single file.  For example:
  5975.  
  5976.   SEND FOO BAR
  5977.  
  5978. would send the file FOO under the name BAR, but:
  5979.  
  5980.   SEND *.TXT anything
  5981.  
  5982. was not allowed, since it would give the same name to each file that was sent.
  5983. When receiving:
  5984.  
  5985.   RECEIVE FOO
  5986.  
  5987. would rename the first incoming file to FOO before storing it on the disk,
  5988. but subsequent files would not be renamed to FOO, since this would result in
  5989. overwriting the same file repeatedly.  Instead, they were stored under the
  5990. names they arrived with.
  5991.  
  5992. Beginning in C-Kermit 6.1 and Kermit 95 1.1.12, it is possible to
  5993. specify as-names in SEND, RECEIVE, and related commands even for file
  5994. groups.  This is accomplished by using replacement variables in the as-name,
  5995. along with optional material such character-string functions and/or constant
  5996. strings.  An as-name containing replacement variables is called a filename
  5997. template.
  5998.  
  5999. The key to filename templates is the new variable:
  6000.  
  6001.   \v(filename)
  6002.  
  6003. During file transfer it is replaced by the name of each file currently being
  6004. transferred (after transfer, it is the name of the last file transferred).
  6005.  
  6006. So, for example:
  6007.  
  6008.   send *.txt \v(filename).new
  6009.  
  6010. sends each file with its own name, but with ".new" appended to it.  Of course
  6011. if the name already contains periods, this could confuse the file receiver, so
  6012. you can also achieve fancier effects with constructions like:
  6013.  
  6014.   send *.txt \freplace(\v(filename),.,_).new
  6015.  
  6016. which replaces all periods in the original filename by underscores, and then
  6017. appends ".new" to the result.  So, for example, oofa.txt would be sent as
  6018. oofa_txt.new.
  6019.  
  6020. Another new variable that is useful in this regard is \v(filenumber), which
  6021. is the ordinal number of the current file in the file group, so you can also:
  6022.  
  6023.   send *.txt FILE\flpad(\v(filenum),2,0)
  6024.  
  6025. resulting in a series of files called FILE00, FILE01, FILE02, etc.  (At the
  6026. end of the transfer, \v(filenum) tells the number of files that were
  6027. transferred).
  6028.  
  6029. If you specify a constant as-name when sending a file group:
  6030.  
  6031.   send *.txt thisnameonly
  6032.  
  6033. Kermit complains and asks you to include replacement variables in the
  6034. as-name.  You should generally use \v(filename) or \v(filenumber) for this
  6035. purpose, since other variables (with the possible exception of date/time
  6036. related variables) do not change from one file to the next.  But Kermit
  6037. accepts any as-name at all that contains any kind of variables for file
  6038. group, even if the variable will not change.  So:
  6039.  
  6040.   send *.txt \%a
  6041.  
  6042. is accepted, but all files are sent with the same name (the value of \%a, if
  6043. it has one and it is constant).  If the variable has no value at all, the
  6044. files are sent under their own names.
  6045.  
  6046. Of course, the value of \%a in the previous example need not be constant:
  6047.  
  6048.   define \%a FILE\flpad(\v(filenum),2,0)_at_\v(time)
  6049.   send *.txt \%a
  6050.  
  6051. The RECEIVE command, when given without an as-name, behaves as always, storing
  6052. all incoming files under the names they arrive with, subject to SET FILE NAME
  6053. and SET RECEIVE PATHNAMES modifications (Section 4.10).
  6054.  
  6055. However, when an as-name is given in the RECEIVE command, it is applied to
  6056. all incoming files rather than to just the first.  If it does not contain
  6057. replacement variables, then the current FILE COLLISION setting governs the
  6058. result.  For example:
  6059.  
  6060.   receive foo
  6061.  
  6062. will result in incoming files named foo, foo.~1~, foo.~2~, and so on, with the
  6063. default FILE COLLISION setting of BACKUP.  If it does contain replacement
  6064. variables, of course they are used.
  6065.  
  6066. When receiving files, the \v(filename) variable refers to the name that was
  6067. received in the incoming file-header packet, BEFORE any processing by SET
  6068. FILE NAMES or SET RECEIVE PATHNAMES.  Since the filenames in file-header
  6069. packets are usually in uppercase, you would need to convert them explicitly
  6070. if you want them in lowercase, e.g.:
  6071.  
  6072.   receive \flower(\v(filename)).new
  6073.  
  6074. 4.1.2. Templates on the Command Line
  6075.  
  6076. On the command-line, use templates as shown above as the -a option argument,
  6077. bearing in mind the propensity of UNIX and perhaps other shells to treat
  6078. backslash as a shell escape character.  So in UNIX (for example):
  6079.  
  6080.   kermit -s oofa.* -a x.\\v(filenum)
  6081.  
  6082. By the way, this represents a change from 6.0 and earlier releases in
  6083. which the as-name (-a argument or otherwise) was not evaluated by the command
  6084. parser.  Thus, for example, in VMS (where the shell does not care about
  6085. backslashes), it was possible to:
  6086.  
  6087.   kermit -s oofa.txt -a c:\tmp\oofa.txt
  6088.  
  6089. Now backslashes in the as-name must be quoted not only for the shell (if
  6090. necessary) but also for Kermit itself:
  6091.  
  6092.   kermit -s oofa.txt -a c:\\tmp\\oofa.txt      ; Kermit only
  6093.   kermit -s oofa.txt -a c:\\\\tmp\\\\oofa.txt  ; Shell and Kermit
  6094.  
  6095. You can also use the \fliteral() function for this:
  6096.  
  6097.   kermit -s oofa.txt -a \fliteral(c:\tmp\oofa.txt)      ; Kermit only
  6098.   kermit -s oofa.txt -a \\fliteral(c:\\tmp\\oofa.txt)   ; Shell and Kermit
  6099.  
  6100. 4.1.3. Post-Transfer Renaming
  6101.  
  6102. Filename templates are now also useful in SET { SEND, RECEIVE } RENAME-TO and
  6103. in the /RENAME-TO: switch, that can be given to the SEND, GET, or RECEIVE
  6104. commands; this is similar to an as-name, but is effective on a per-file basis
  6105. if and only if the file was transferred successfully.
  6106.  
  6107. MOVE-TO and RENAME-TO address a requirement commonly stated for transaction
  6108. processing and similar systems.  Suppose, for example, a central system "X"
  6109. accepts connections from multiple clients simultaneously; a process on X waits
  6110. for a file to appear and then processes the file.  This process must have a
  6111. way of knowing when the file has been completely and successfully transferred
  6112. before it starts to process it.  This can be accomplished easily using
  6113. C-Kermit's SET { SEND, RECEIVE } { MOVE-TO, RENAME-TO } command or /MOVE-TO:
  6114. or /RENAME-TO: switches, described in Sections 4.7.1-3.
  6115.  
  6116. Here's an example for the client side, in which files to be sent are placed in
  6117. a certain directory (/usr/olga/tosend in this example) by another process when
  6118. they are ready to go.  This might be in a hospital or big doctor's office,
  6119. where medical insurance claims are entered at a number of workstations, and
  6120. then deposited in the "tosend" directory, from which they are sent to a claims
  6121. clearinghouse.  We assume the connection is already made and a Kermit server
  6122. is on the other end.
  6123.  
  6124.   local srcdir findir              ; Declare local (automatic) variables
  6125.   assign srcdir /usr/olga/tosend   ; Local source directory (files to send)
  6126.   assign findir /usr/olga/sent     ; Where to move files after they are sent
  6127.   log transactions                 ; Keep a log of transfers
  6128.   cd \m(srcdir)                    ; Change to the source directory
  6129.   while true {                     ; Loop forever...
  6130.       send /move-to:\m(findir) *   ; Send all files
  6131.       sleep 60                     ; Sleep a minute
  6132.   }                                ; Go back and do it again
  6133.  
  6134. Note how simple this is.  Once each file is sent, it is moved so it won't be
  6135. sent again (you could also use SEND /RENAME-TO: or even SEND /DELETE).  If a
  6136. transfer fails, the file is not moved and so we try again to send it next time
  6137. around.  If there are no files to send, the SEND command does nothing but a
  6138. message is printed; you can avoid the message by checking first to see if any
  6139. files are in the directory:
  6140.  
  6141.   while true {                     ; Loop forever...
  6142.       if > \ffiles(*) 0 -          ; If there are any files
  6143.         send /move-to:\m(findir) * ; send them.
  6144.       sleep 60                     ; Sleep a minute.
  6145.   }                                ; Go back and do it again.
  6146.  
  6147. It's even simpler on the server side (here again we assume the connection
  6148. is already in place):
  6149.  
  6150.   local rcvdir findir              ; Declare local (automatic) variables
  6151.   assign rcvdir /usr/ivan/tmp      ; Temporary receiving directory
  6152.   assign findir /usr/ivan/new      ; Where to move files after reception
  6153.   log transactions                 ; Keep a log of transfers
  6154.   cd \m(rcvdir)                    ; Change to the source directory
  6155.   set receive move-to \m(findir)   ; Declare move-to directory.
  6156.   server                           ; Enter server mode.
  6157.  
  6158. A separate process (e.g. the medical claim-form decoder) can look for files
  6159. appearing in the /usr/ivan/new directory and process them with every
  6160. confidence that they have been completely received.
  6161.  
  6162. Note that the use of MOVE-TO can result in moved files overwriting one another
  6163. (the application would normally avoid this by assigning each transaction a
  6164. unique, e.g. based on customer number and claim number).  But if filename
  6165. collisions are a possibility in your application, RENAME-TO might be a better
  6166. choice; you can use any variables you like in the template to ensure
  6167. uniqueness of the RENAME-TO filename; for example:
  6168.  
  6169.   SET RECEIVE RENAME-TO \v(filename)_\v(ndate)_\v(ntime)_\v(userid)_\v(pid)
  6170.  
  6171. 4.2. FILE-TRANSFER PIPES AND FILTERS
  6172.  
  6173. 4.2.1. INTRODUCTION
  6174.  
  6175. Beginning in C-Kermit 6.1 and Kermit 95 1.1.12, it is possible to send from a
  6176. command, or "pipe", as well as from a file, and to receive to a pipe or
  6177. command.  In a typical example, we might want to transfer an entire directory
  6178. tree from one UNIX system to another (but without using the methods described
  6179. in Sections 4.3, 4.10, 4.11, and 4.15).  We could do this in multiple steps as
  6180. follows:
  6181.  
  6182.   1. Create a tar archive of the desired directory tree
  6183.   2. Compress the tar archive
  6184.   3. Transfer it in binary mode to the other computer
  6185.   4. Decompress it
  6186.   5. Extract the directory tree from the tar archive
  6187.  
  6188. But this is inconvenient and it requires a temporary file, which might be
  6189. larger than we have room for.
  6190.  
  6191. The new pipe-transfer feature lets you do such things in a single step,
  6192. and without intermediate files.
  6193.  
  6194. Additional new features, also discussed here, let you specify pre- and post-
  6195. processing filters for outbound and incoming files, and give you a way to
  6196. insert the output from shell or system commands into C-Kermit commands.
  6197.  
  6198. The file-transfer related features are available only with Kermit protocol,
  6199. not with any external protocols, nor with K95's built-in XYZMODEM protocols
  6200. (because XYZMODEM recovers from transmission errors by rewinding the source
  6201. file, and you can't rewind a pipe).
  6202.  
  6203. This section begins by discussing the simple and straightforward use of these
  6204. features in UNIX, in which pipes and input/output redirection are a
  6205. fundamental component and therefore "just work", and then goes on to discuss
  6206. their operation in Windows and OS/2, where matters are much more complicated.
  6207.  
  6208. 4.2.1.1. TERMINOLOGY
  6209.  
  6210. Standard Input
  6211.   This is a precise technical term denoting the normal source of input for
  6212.   a command or program, which is the keyboard of your terminal by default,
  6213.   but which can be redirected to a file or pipe.
  6214.  
  6215. Stdin
  6216.   Abbreviation for Standard Input.
  6217.  
  6218. Standard Output
  6219.   A precise technical term denoting the normal destination for output from a
  6220.   command or program, which is your terminal screen by default, but which can
  6221.   be redirected to a file.
  6222.  
  6223. Stdout
  6224.   Abbreviation for Standard Output.
  6225.  
  6226. Stdio
  6227.   Abbreviation for Standard Input / Standard Output.
  6228.  
  6229. I/O
  6230.   Abbreviation for Input / Output.
  6231.  
  6232. Shell
  6233.   Text-based system command processor, such as the UNIX shell, DOS
  6234.   COMMAND.COM, etc.
  6235.  
  6236. Pipe
  6237.   A mechanism by which the standard output of one program is sent to
  6238.   the standard input of another.
  6239.  
  6240. Pipeline
  6241.   A series of programs connected by pipes.
  6242.  
  6243. 4.2.1.2. NOTATION
  6244.  
  6245. In command descriptions, "<command>" is replaced by a shell or system command
  6246. or pipeline.  The command names specified in these commands are interpreted by
  6247. your shell, just as if you were typing them at the shell prompt, and so if
  6248. they are in your PATH, they will be found in the expected manner.  Therefore
  6249. you don't have to specify complete pathnames for commands that are programs
  6250. (but it shouldn't hurt if you do).
  6251.  
  6252. The normal notation for I/O redirection is as follows:
  6253.  
  6254.   <  Read Stdin from the given file.
  6255.   >  Send Stdout to the given file.
  6256.   |  Send Stdout from the command on the left to the command on the right.
  6257.  
  6258. Examples:
  6259.  
  6260. sort < foo > bar
  6261.   Sorts the lines in file "foo" and writes the results to file "bar"
  6262.  
  6263. grep -c "some text" *.txt | grep -v ":0" | sort | pr -3 | lpr
  6264.   This is a command pipeline composed of 5 commands:
  6265.  
  6266.   grep -c "some text" *.txt
  6267.     Looks in all files whose names end with ".txt" for the string "some text"
  6268.     and writes to Stdout the names of each file followed by a colon and the
  6269.     number of occurrences in each.
  6270.  
  6271.   grep -v ":0"
  6272.     Prints to Stdout the lines from Stdin that do NOT contain the string ":0",
  6273.     in this case, it removes the names of files that do not contain "some
  6274.     text".
  6275.  
  6276.   sort
  6277.     Sorts the lines from Stdin alphabetically to Stdout.
  6278.  
  6279.   pr -3
  6280.     Arranges the lines from Stdin in three columns.
  6281.  
  6282.   lpr
  6283.     Prints its Stdin on the default printer.
  6284.  
  6285. Note that the Kermit features described here work only with commands that use
  6286. Stdio.  If you attempt to use them with commands whose input and output can
  6287. not be redirected, Kermit will most likely get stuck.  Kermit has no way of
  6288. telling how an external command works, nor what the syntax of the shell is, so
  6289. it's up to you to make sure you use these features only with redirectable
  6290. commands.
  6291.  
  6292. The quoting rules of your shell apply to the <command>.  Thus in UNIX, where
  6293. C-Kermit tries to use your preferred shell for running commands, shell
  6294. "metacharacters" within commands must be escaped if they are to be taken
  6295. literally, using the methods normal for your shell.  For example, the UNIX tr
  6296. (translate) command must have its arguments in quotes:
  6297.  
  6298.   tr "[a-z]" "[A-Z]"
  6299.  
  6300. otherwise the shell is likely to replace them by all filenames that match,
  6301. which is probably not what you want.  This is also true when using your shell
  6302. directly, and has nothing to do with Kermit.
  6303.  
  6304. 4.2.1.3. SECURITY
  6305.  
  6306. Some sites might not wish to allow access to system commands or external
  6307. programs from within Kermit.  Such access, including all the features
  6308. described here, can be disabled in various ways:
  6309.  
  6310.  1. When building from source code, include -DNOPUSH among the CFLAGS.
  6311.  2. At runtime, give the NOPUSH command.
  6312.  3. For server mode, give the DISABLE HOST command.
  6313.  4. Implicit use of pipes can be disabled as described in section 4.2.4.
  6314.  
  6315. Note: 3 and 4 are not necessary if you have done 1 or 2.
  6316.  
  6317. 4.2.2. Commands for Transferring from and to Pipes
  6318.  
  6319. SEND /COMMAND sends data from a command or command pipeline, and RECEIVE
  6320. /COMMENT writes data to a command or pipeline.  The GET /COMMAND command
  6321. asks a server to send material, and then writes the incoming material to a
  6322. command or pipeline.  These features, along with switches (like "/COMMAND",
  6323. described in section 4.7) are new to C-Kermit 6.1.  The following synonyms
  6324. are also provided:
  6325.  
  6326.   CSEND    = SEND /COMMAND
  6327.   CRECEIVE = RECEIVE /COMMAND
  6328.   CGET     = GET /COMMAND
  6329.  
  6330. None of these commands can be used if a SEND or RECEIVE FILTER (respectively,
  6331. Section 4.2.3) is in effect, or if a NOPUSH command (Section 4.2.1.3) has been
  6332. given, or if the current protocol is not Kermit.
  6333.  
  6334. 4.2.2.1. Sending from a Command
  6335.  
  6336. SEND /COMMAND <command> [ <as-name> ]
  6337. SEND /AS-NAME:<as-name> /COMMAND <command>
  6338. CSEND <command> [ <as-name> ]
  6339.   These three forms are the same.  They work like the SEND command, but
  6340.   instead of sending a file, it sends the standard output of the given
  6341.   <command>, either under the command's own name, or else with the given
  6342.   <as-name>.  If the <command> contains spaces, it must be enclosed in braces.
  6343.   Braces should also be used for the <as-name> if it contains spaces.  If
  6344.   braces are included around either the <command> or the <as-name>, they are
  6345.   removed after parsing but before use.  As with SEND, the transfer is in text
  6346.   or binary mode according the current FILE TYPE setting, unless you override
  6347.   the global transfer mode by including a /TEXT or /BINARY switch.  The
  6348.   <command> must require no input.
  6349.  
  6350. When sending from a command or pipeline, C-Kermit has no way of knowing
  6351. in advance how much data will be sent, and so it can not send the size
  6352. to the other Kermit in the Attribute packet, and so the receiving Kermit
  6353. has no way of displaying "percent done" or a progress bar (thermometer).
  6354.  
  6355. Examples that make sense in text mode (illustrated by common UNIX commands):
  6356.  
  6357.   SEND /COMMAND finger
  6358.   CSEND finger
  6359.     sends the current "finger" listing (who's logged in) under the
  6360.     name "finger".  The two forms "send /command" and "csend" are
  6361.     equivalent; we won't bother showing them both in the rest of the
  6362.     examples.
  6363.  
  6364.   SEND /COMMAND:{finger}
  6365.   CSEND {finger}
  6366.     Same as previous example (braces are removed from "{finger}").
  6367.  
  6368.   SEND /COMMAND:{ finger }
  6369.   CSEND { finger }
  6370.     Same as previous example, but note that the spaces are kept.  This
  6371.     does not prevent the shell from running the "finger" program, but
  6372.     its output is sent under the name " finger " (with a leading and
  6373.     trailing space).
  6374.  
  6375.   SEND /COMMAND:finger /AS-NAME:userlist
  6376.   CSEND finger userlist
  6377.     sends the current finger listing under the name "userlist".
  6378.  
  6379.   SEND /COMMAND:{finger | sort -r} /AS-NAME:userlist
  6380.   CSEND {finger | sort -r} userlist
  6381.     sends the current finger listing, sorted in reverse order, under the
  6382.     name "userlist".  The braces are needed to distinguish the <command>
  6383.     from the <as-name>.
  6384.  
  6385.   SEND /COMMAND:{finger | sort -r} /AS-NAME:{userlist}
  6386.   CSEND {finger | sort -r} {userlist}
  6387.     Same as previous example (braces are removed from "{userlist}").
  6388.  
  6389.   SEND /COMMAND:{finger | sort -r} /AS-NAME:{\freplace(\v(filename),\32,_)}
  6390.   CSEND {finger | sort -r} {\freplace(\v(filename),\32,_)}
  6391.     Like the previous example, but sends the output of the <command> under
  6392.     the name of the command, but with all spaces (\32) replaced by underscores,
  6393.     so the as-name is "finger_|_sort_-r".
  6394.  
  6395.   Examples that make sense in binary mode (three equivalent forms are shown):
  6396.  
  6397.   SEND /COMMAND /BINARY {tar cf - . | gzip -c} mydir.tar.gz
  6398.   SEND /COMMAND /BINARY /AS-NAME:mydir.tar.gz {tar cf - . | gzip -c}
  6399.   CSEND /BINARY {tar cf - . | gzip -c} mydir.tar.gz
  6400.     Makes a tar archive of the current directory, compresses it with the GNU
  6401.     gzip program, and sends it as "mydir.tar.gz".  The other Kermit can, of
  6402.     course, just store it as a file, or it can use CRECEIVE to uncompress and
  6403.     dearchive it as part of the transfer process.
  6404.  
  6405. When using a "pipeline" of commands in the <command> field, obviously,
  6406. the first command must not require any input, and the last command should
  6407. produce some output, and all intermediate commands should get some input and
  6408. produce some output.
  6409.  
  6410. 4.2.2.2. Receiving to a Command
  6411.  
  6412. RECEIVE /COMMAND <command>
  6413. CRECEIVE <command>
  6414.   This is like RECEIVE, except incoming material is written to the standard
  6415.   input of the given command, in text or binary mode according to the normal
  6416.   rules for file reception.  Be sure to include a redirector to a file (if the
  6417.   command normally writes to standard output), or the output of the command
  6418.   won't go anywhere.  The <command> may contain spaces; braces are not needed,
  6419.   but they are removed if used.
  6420.  
  6421. WARNING: C-Kermit has no way of knowing anything about the <command>, or even
  6422. whether it is a command.  Thus this command will always cause C-Kermit to
  6423. enter protocol mode, as long as some text is specified in the <command> field.
  6424. However, if the text does not correspond to a command, the transfer will
  6425. eventually fail with a message such as "Error writing data" or "Failure to
  6426. close file".
  6427.  
  6428. Examples for text mode (in UNIX):
  6429.  
  6430.   RECEIVE /COMMAND sort -r > reverse.txt
  6431.   CRECEIVE sort -r > reverse.txt
  6432.     The text that is received is sorted in reverse order and stored in
  6433.     the file "reverse.txt".  The two forms shown are equivalent.
  6434.  
  6435.   RECEIVE /COMMAND {sort -r > reverse.txt}
  6436.   CRECEIVE {sort -r > reverse.txt}
  6437.     The same as the previous example; if braces are included, they are
  6438.     simply removed.
  6439.  
  6440.   RECEIVE /COMMAND {sort -r > \flower(\v(filename)).reverse}
  6441.   CRECEIVE {sort -r > \flower(\v(filename)).reverse}
  6442.     Same but stores result under the incoming filename, lowercased, and
  6443.     with ".reverse" appended to it.
  6444.  
  6445.   RECEIVE /COMMAND sort
  6446.   CRECEIVE sort
  6447.     Does nothing useful, since the output of sort has nowhere to go.
  6448.  
  6449.   RECEIVE /COMMAND sort -r | pr -3 | lpr -Plaserjet
  6450.   CRECEIVE sort -r | pr -3 | lpr -Plaserjet
  6451.     The text that is received is sorted in reverse order, arranged into
  6452.     three columns, and sent to the "laserjet" printer.
  6453.  
  6454.   Examples for binary mode:
  6455.  
  6456.   RECEIVE /COMMAND:{gunzip -c | tar xf -}
  6457.   CRECEIVE {gunzip -c | tar xf -}
  6458.     Assuming the data that is received is a compressed tar archive,
  6459.     uncompresses the archive and passes it to tar for extraction.  In this
  6460.     case the braces are needed because otherwise the final "-" would be
  6461.     taken as a command continuation character (see "Using C-Kermit", 2nd
  6462.     Edition, p.33).
  6463.  
  6464. GET /COMMAND <remote-file> <command>
  6465. GET /COMMAND /AS-NAME:<command> <remote-file>
  6466. CGET <remote-file> <command>
  6467.   This command tells the Kermit client to send a GET request for the given
  6468.   remote file to a Kermit server.  Unlike GET, however, the incoming material
  6469.   is written to a command, rather than to a file.  If the <remote-file> or the
  6470.   <command> contain spaces, they must be enclosed in braces.  The same
  6471.   cautions about the <command> apply as for CRECEIVE.  Examples (for UNIX):
  6472.  
  6473.   GET /COMMAND oofa.txt sort -r > oofa.new
  6474.   GET /COMMAND {oofa.txt} {sort -r > oofa.new}
  6475.   CGET oofa.txt sort -r > oofa.new
  6476.   CGET {oofa.txt} {sort -r > oofa.new}
  6477.     These four are equivalent.  Each of them requests the server to send
  6478.     its "oofa.txt" file, and as it arrives, it is sorted in reverse order
  6479.     and written to "oofa.new".
  6480.  
  6481.   GET /COMMAND {profile exec a} lpr
  6482.   GET /COMMAND {profile exec a} {lpr}
  6483.   GET /COMMAND /AS-NAME:lpr {profile exec a}
  6484.   GET /COMMAND /AS-NAME:{lpr} {profile exec a}
  6485.   GET /COMMAND /AS:lpr {profile exec a}
  6486.   CGET {profile exec a} lpr
  6487.   CGET {profile exec a} {lpr}
  6488.     Here the remote filename contains spaces so it MUST be enclosed in
  6489.     braces.  As it arrives it is sent to the lpr program for printing.
  6490.     Braces are optional around "lpr" since it contains no spaces.
  6491.  
  6492.   GET /COMMAND *.txt {cat >> new.txt}
  6493.   GET /AS-NAME:{cat >> new.txt} /COMMAND *.txt
  6494.   CGET *.txt {cat >> new.txt}
  6495.     This gets all the ".txt" files from the server and concatenates them
  6496.     all into a single "new.txt" file on the client.
  6497.  
  6498.   GET /COMMAND *.txt {echo \v(filename)>>new.txt;cat>>new.txt}
  6499.   CGET *.txt {echo \v(filename)>>new.txt;cat>>new.txt}
  6500.     As above, but inserts each file's name before its contents.
  6501.  
  6502. 4.2.3. Using File-Transfer Filters
  6503.  
  6504. The commands described in section 4.2.2 let you send the output of a command,
  6505. or receive data into a command.  But what if you want to specify preprocessing
  6506. for files that you send, or postprocessing of files that you receive, even
  6507. when multiple files are involved?  For this you need a way to specify send and
  6508. receive filters.  The commands are SET SEND FILTER and SET RECEIVE FILTER;
  6509. SHOW PROTOCOL displays the current settings.
  6510.  
  6511. 4.2.3.1. The SEND Filter
  6512.  
  6513. SET SEND FILTER [ <command> ]
  6514.   This command specifies a <command> to be run on any file that you SEND (or
  6515.   MOVE, MSEND, etc).  It also applies to files sent when in server mode, in
  6516.   response to GET commands, but not to the results of REMOTE commands like
  6517.   REMOTE DIRECTORY, REMOTE TYPE, REMOTE HOST, etc.  The <command> may be, but
  6518.   need not be, enclosed in braces; if it is, the braces are stripped before
  6519.   use.  The output of this command is sent, rather than the file itself.  The
  6520.   current FILE TYPE setting (TEXT or BINARY) applies to the output of the
  6521.   command.  The <command> must contain at least one instance of \v(filename),
  6522.   for which the name of the actual file is substituted.  If the <command> is
  6523.   omitted, the send filter is removed and files are sent in the normal manner.
  6524.  
  6525. The SET SEND FILTER sets up a "global" filter -- that is, one that applies to
  6526. all subsequent file-sending commands until you change or remove it.  You can
  6527. also specify a "local" filter to be used in a specific file-sending command by
  6528. using the /FILTER switch (see section 1.5); for example:
  6529.  
  6530.   SEND /FILTER:<command> [ <other-switches> ] <filename>
  6531.  
  6532. Besides \v(filename), you can include any other script programming notation in
  6533. the send filter: variable names, array references, calls to built-in string or
  6534. other functions, and so on.  These are evaluated during file transfer, NOT
  6535. during parsing, and they are evaluated separately for each file.
  6536.  
  6537. When the SEND or MOVE (SEND /DELETE) command is used with a send filter, the
  6538. output from the filter is sent under the file's original name unless you
  6539. specify an "as-name" or template.  The Attribute packet (if any) contains the
  6540. original file's attributes (size, creation date, etc).  So (for example) if
  6541. the filter changes the file's size, the progress thermometer might be wrong.
  6542. (We can't send the size of the output from the filter, because it is not known
  6543. until the transfer is finished.)  If you prefer that the size not be sent, use
  6544. "set attributes size off".
  6545.  
  6546. You can not use send filters with RESEND (SEND /RECOVER) or PSEND
  6547. (SEND /START).
  6548.  
  6549. Examples for text mode:
  6550.  
  6551.   SET SEND FILTER sort -r \v(filename)     ; Braces may be omitted
  6552.   SET SEND FILTER {sort -r \v(filename)}   ; Braces may be included
  6553.   SEND *.txt
  6554.     This sends every file in the current directory whose name ends with
  6555.     ".txt" under its own name, but with its lines sorted in reverse order.
  6556.  
  6557.   SEND /FILTER:{sort -r \v(filename)} *.txt
  6558.     Same as above, but the filter applies only to this SEND command.
  6559.     Braces are required in this case.
  6560.  
  6561.   SET SEND FILTER {sort -r \v(filename)}
  6562.   SEND oofa.txt reverse.txt
  6563.     Sends the oofa.txt file with its lines sorted in reverse order under
  6564.     the name "reverse.txt".
  6565.  
  6566.   SET SEND FILTER {sort -r \v(filename)}
  6567.   SEND oofa.* \v(filename).reverse
  6568.     Sends all the oofa.* files with their lines sorted in reverse order;
  6569.     each file is sent under its own name but with ".reverse" appended to it.
  6570.  
  6571.   SET SEND FILTER {tr "[a-z]" "[A-Z]" < \v(filename)}
  6572.   SEND *.txt
  6573.     Sends all ".txt" files under their own names, but uppercasing their
  6574.     contents.
  6575.  
  6576. Note that the SEND FILTER applies not only to files that are sent with
  6577. SEND, MOVE, MSEND, etc, but also to files sent by the C-Kermit server in
  6578. response to GET requests.
  6579.  
  6580. Examples for binary mode:
  6581.  
  6582.   SET SEND FILTER {gzip -c \v(filename)}
  6583.   SEND /BINARY oofa.txt oofa.txt.gz
  6584.     Sends the oofa.txt file, compressed by gzip, as oofa.txt.gz.
  6585.  
  6586.   SEND /BINARY /FILTER:{gzip -c \v(filename)} oofa.txt oofa.txt.gz
  6587.     As above, but the filter applies only to this SEND command.
  6588.  
  6589.   SET SEND FILTER {gzip -c \v(filename)}
  6590.   SEND /BINARY oofa.* \fupper(\replace(\v(filename),.,_)).GZ
  6591.     Sends all the oofa.* files, compressed by gzip, each under its own name,
  6592.     but with the name uppercased, all periods within the name converted to
  6593.     underscores, and ".GZ" appended to it.  So, for example, "oofa.txt"
  6594.     is sent as "OOFA_TXT.GZ".
  6595.  
  6596. In the gzip examples, note that the amount of data that is sent is normally
  6597. less than the original file size because gzip compresses the file.  But Kermit
  6598. sends the original file size ahead in the attribute packet anyway (unless you
  6599. tell it not too).  Thus the transfer will probably appear to terminate early,
  6600. e.g. when the receiver's file-transfer display thermometer is only at 40%.
  6601. If this annoys you, tell Kermit to "set attribute length off".  On the other
  6602. hand, you can use the final position of the thermometer as a measure of the
  6603. effectiveness of compression.
  6604.  
  6605. 4.2.3.2. The RECEIVE Filter
  6606.  
  6607. SET RECEIVE FILTER [ <command> ]
  6608.   This command specifies that the given <command> will be run on any file
  6609.   that is received before it is written to disk.  The <command> may be, but
  6610.   need not be, enclosed in braces; if it is the braces are stripped before
  6611.   use.  The following two commands are equivalent:
  6612.  
  6613.     SET RECEIVE FILTER sort -r > \v(filename)
  6614.     SET RECEIVE FILTER {sort -r > \v(filename)}
  6615.  
  6616.   The RECEIVE filter <command> may contain a "\v(filename)" sequence to be
  6617.   replaced by the incoming filename from the file header packet, but it is not
  6618.   required.  However you must use it whenever your filter would normally write
  6619.   to Stdout, otherwise its output will be lost.
  6620.  
  6621.   The RECEIVE filter <command> may contain one or more "\v(filename)"
  6622.   sequence to be replaced by the incoming filename from the file header
  6623.   packet, but it is not required.  However you must use it whenever your
  6624.   filter would normally write to Stdout, otherwise its output will be lost.
  6625.  
  6626. RECEIVE /FILTER:<command> and GET /FILTER:<command> can also be used to
  6627. specify a filter to be used for only one file-transfer operation.
  6628.  
  6629. UNIX examples for text mode:
  6630.  
  6631.   SET RECEIVE FILTER lpr
  6632.   RECEIVE
  6633.     All the files that are received are sent to the default UNIX print
  6634.     spooler.
  6635.  
  6636.   RECEIVE /FILTER:lpr
  6637.     Same as above, except the lpr filter is used only with this
  6638.     RECEIVE command.
  6639.  
  6640.   RECEIVE lpr
  6641.     This is probably not what you want; it creates a file called lpr.
  6642.  
  6643.   SET RECEIVE FILTER {sort -r > \v(filename)}
  6644.   RECEIVE
  6645.     Stores each incoming file with its lines sorted in reverse order,
  6646.     under its own name.
  6647.  
  6648.   RECEIVE /FILTER:{sort -r > \v(filename)}
  6649.     As above, but the filter is used only for this RECEIVE command.
  6650.  
  6651.   SET RECEIVE FILTER sort -r > \v(filename)
  6652.   RECEIVE reverse.txt
  6653.     Stores each incoming file with its lines sorted in reverse order,
  6654.     under the name "reverse.txt".  The actual result depends on the
  6655.     FILE COLLISION setting.  If it is OVERWRITE and multiple files arrive,
  6656.     then each incoming file destroys the previous one.  If it is BACKUP
  6657.     (the default), filename conflicts are resolve by adding "version numbers"
  6658.     to the filenames: reverse.txt, reverse.txt.~1~, reverse.txt.~2~, etc.
  6659.  
  6660.   SET RECEIVE FILTER sort -r > \v(filename)
  6661.   RECEIVE \v(filename).reverse
  6662.     Stores each incoming file with its lines sorted in reverse order,
  6663.     under the name it arrived with, but with ".reverse" appended to it.
  6664.  
  6665.   SET RECEIVE FILTER sort -r > \v(filename)
  6666.   RECEIVE \flower(\v(filename)).reverse
  6667.     Like the previous example, but ensures that the filename is lowercase.
  6668.  
  6669. Examples for binary mode:
  6670.  
  6671.   SET RECEIVE FILTER gunzip -c > \v(filename)
  6672.   RECEIVE
  6673.     This receives one or more presumably compressed file and uncompresses
  6674.     each one into a file having the same name it was sent with.  For example,
  6675.     if the file is sent with the name OOFA.TXT.GZ, it is stored with that
  6676.     name, even after decompression.
  6677.  
  6678.   SET RECEIVE FILTER gunzip -c > \v(filename)
  6679.   RECEIVE \flower(\fsubstring(\v(filename),1,\flength(\v(filename))-3))
  6680.     Like the previous example, but the resulting filename has its rightmost
  6681.     three characters removed from it and the remainder is lowercased.  So if
  6682.     the incoming filename is OOFA.TXT.GZ, it is stored as oofa.txt after
  6683.     decompression.
  6684.  
  6685. Of course you don't want to type such long hideous commands, so we have also
  6686. introduced several new functions:
  6687.  
  6688. \fstripx(string[,character])
  6689.    This function removes the rightmost segment of the string that starts with
  6690.    the given character.  If no character is given, period (.) is used.  Thus
  6691.    it is most conveniently used for stripping the extension from a filename
  6692.    (or the decimal portion from a floating-point number written in US/UK
  6693.    style).  Examples:
  6694.  
  6695.      \fstripx(OOFA.TXT.GZ)             => OOFA.TXT
  6696.      \fstripx(OOFA.TXT.GZ,.)           => OOFA.TXT
  6697.      \fstripx(OOFA.TXT.GZ,X)           => OOFA.T
  6698.      \fstripx(\fstripx(OOFA.TXT.GZ))   => OOFA
  6699.      \fstripx($100.00)                 => $100
  6700.  
  6701. \fstripn(string,number)
  6702.    Removes the rightmost <number> characters from the string.  Examples:
  6703.  
  6704.      \fstripn(OOFA.TXT.GZ)             => OOFA.TXT.GZ
  6705.      \fstripn(OOFA.TXT.GZ,3)           => OOFA.TXT
  6706.      \fstripn(OOFA.TXT.GZ,7)           => OOFA
  6707.  
  6708. \fstripb(string[,c1[,c2]])
  6709.    Strips enclosing matching braces, brackets, parentheses, or quotes from
  6710.    the string.  The second argument, c1, specifies which kind of enclosure
  6711.    to look for; if not specified, any enclosing (), [], <>, {}, "", '', or
  6712.    `' are removed.  If c1 is specified and c2 is not, then if c1 is an
  6713.    opening brace, bracket, or parenthesis, the matching closing one is
  6714.    supplied automatically as c2.  If both c1 and c2 are specified, then to
  6715.    be stripped the string must begin with c1 and end with c2.  If the
  6716.    string is not enclosed in the indicated manner, the result is the
  6717.    original string.  Examples:
  6718.  
  6719.      \fstripb("abc")                   => abc
  6720.      \fstripb([abc])                   => abc
  6721.      \fstripb([abc)                    => [abc
  6722.      \fstripb(<abc>)                   => abc
  6723.      \fstripb(<abc>,[)                 => <abc>
  6724.      \fstripb((abc))                   => abc
  6725.      \fstripb((abc),[)                 => (abc)
  6726.      \fstripb((abc),{(})               => abc
  6727.      \fstripb(+abc+)                   => +abc+
  6728.      \fstripb(+abc+,+)                 => abc
  6729.      \fstripb(+abc+,+,^)               => +abc+
  6730.      \fstripb(+abc^,+,^)               => abc
  6731.      \fstripb('abc')                   => abc
  6732.      \fstripb(`abc')                   => abc
  6733.      \fstripb(``abc'')                 => `abc'
  6734.      \fstripb(\fstripb(``abc''))       => abc
  6735.  
  6736.    Notice the special syntax required for including a literal parenthesis
  6737.    in the argument list.  As the last two examples illustrate, \fstripb()
  6738.    strips only one level at at a time; nesting can be used to strip a small
  6739.    fixed number of levels; loops can be used to strip larger or indeterminate
  6740.    numbers of levels.
  6741.  
  6742. \flop(string[,char])
  6743.    Removes the leftmost segment of the string that ends with the given
  6744.    character.  If no character is given, period (.) is used.  Examples:
  6745.  
  6746.      \flop(OOFA.TXT.GZ)               => TXT.GZ
  6747.      \flop(OOFA.TXT.GZ,.)             => TXT.GZ
  6748.      \flop(OOFA.TXT.GZ,X)             => T.GZ
  6749.  
  6750. To remove the leftmost <number> characters, just use \fsubstring(s,<number>+1).
  6751. To return the rightmost <number> characters, use \fright(s,<number>).
  6752.  
  6753. So the hideous example:
  6754.  
  6755.   receive \flower(\fsubstring(\v(filename),1,\flength(\v(filename))-3))
  6756.  
  6757. can now be written as:
  6758.  
  6759.   receive \flower(\fstripx(\v(filename)))
  6760.  
  6761. That is, the filename stripped of its extension and then lowercased.  This
  6762. is not only shorter and less hideous, but also does not depend on the
  6763. length of the extension being 3.
  6764.  
  6765. Note that when a receive filter is in effect, this overrides your FILE
  6766. COLLISION setting, since Kermit has no way of knowing what the final
  6767. destination filename will be (because it does not know, and can not be
  6768. expected to know, the syntax of every version of every command shell on
  6769. every platform on the planet).
  6770.  
  6771. 4.2.4. Implicit Use of Pipes
  6772.  
  6773. If you wish, C-Kermit can also examine incoming filenames to see if they
  6774. start with "!", and if so, the subsequent text is treated as a command to
  6775. read from or write to.  For example, if a Kermit client is given the following
  6776. command:
  6777.  
  6778.   get {!finger | sort}
  6779.  
  6780. the server on the other end, if it supports this feature, will run the
  6781. "finger" program, pipe its standard output to the "sort" program, and send
  6782. sort's standard output back to you.  Similarly, if you:
  6783.  
  6784.   send oofa.txt !sort -r > oofa.new
  6785.  
  6786. or, equivalently:
  6787.  
  6788.   send oofa.txt {!sort -r > oofa.new}
  6789.  
  6790. or:
  6791.  
  6792.   send /as-name:{!sort -r > oofa.new} oofa.txt
  6793.  
  6794. this has the receiver send the contents of the incoming oofa.txt file to
  6795. the sort program, which sorts the text in reverse order and stores the
  6796. result in oofa.new.
  6797.  
  6798. This use of the exclamation mark should be familiar to UNIX users as the
  6799. "bang" feature that lets you run an external application or command from
  6800. within another application.
  6801.  
  6802. Kermit's "bang" feature is disabled by default, since it is not unheard for
  6803. filenames to actually begin with "!".  So if you want to use this feature,
  6804. you must enable it with the following command:
  6805.  
  6806. SET TRANSFER PIPES { ON, OFF }
  6807.   ON enables the recognition of "!" notation in incoming filenames during
  6808.   file transfer as an indicator that the remaining text is the name of a
  6809.   command.  OFF, the default, disables this feature and uses the text as
  6810.   a filename in the normal fashion.  This command does NOT affect SEND
  6811.   /COMMAND, GET /COMMAND, CSEND, etc.
  6812.  
  6813. So using a combination of CSEND (SEND /COMMAND) and the "bang" feature, you
  6814. can transfer a directory tree all in one command (assuming the remote
  6815. Kermit supports pipe transfers and has them enabled):
  6816.  
  6817.   CSEND {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  6818.  
  6819. or:
  6820.  
  6821.   SEND /COMMAND:{tar cf - . | gzip -c} /as:{!gunzip -c | tar xf -}
  6822.  
  6823. Pay close attention to the syntax.  Braces are needed around the <command>
  6824. because it contains spaces; braces are needed around the <as-name> because
  6825. it ends with "-".  The <as-name> must begin with "!" or receiving Kermit will
  6826. not recognize it as a command.  The CSEND command must NOT begin with "!"
  6827. unless you are running a command whose name really does start that character.
  6828.  
  6829. Similarly, you have a Kermit server send a directory tree to be unpacked
  6830. on the client end:
  6831.  
  6832.   CGET {!tar cf - . | gzip -c} {gunzip -c | tar xf -}
  6833.  
  6834. or:
  6835.  
  6836.   GET /COMMAND {!tar cf - . | gzip -c} /as:{gunzip -c | tar xf -}
  6837.  
  6838. Notice how, in this case, the bang is required in the remote command, to
  6839. distinguish it from a filename, but not in the local command, since by
  6840. definition of CGET (or GET /COMMAND), it is known to be a command.
  6841.  
  6842. SEND and RECEIVE FILTERs supersede the bang feature.  For example, if a
  6843. file arrives under the name "!gunzip -c | tar xf -", but the receiving Kermit
  6844. also has been given a command like:
  6845.  
  6846.   set receive filter sort -r > \v(filename)
  6847.  
  6848. then the incoming data will be sorted rather than gunzipped.
  6849.  
  6850. Finally, if SET TRANSFER PIPES is ON (and in this case, this must be done in
  6851. your C-Kermit initialization file), you can send from a pipe on the C-Kermit
  6852. command line:
  6853.  
  6854.   kermit -s "!finger | sort -r" -a userlist
  6855.  
  6856. In this case the "filename" contains spaces and so must be quoting using
  6857. your shell's quoting rules.
  6858.  
  6859. 4.2.5. Success and Failure of Piped Commands
  6860.  
  6861. Commands or programs started by Kermit as a result of CSEND or CRECEIVE
  6862. commands, CGET, SEND /COMMAND, REDIRECT commands (see section 4.2.8.2),
  6863. implicit use of pipes, RUN commands, and so forth, should return their exit
  6864. status codes to the Kermit command that caused them to be run, and
  6865. therefore IF SUCCESS and IF FAILURE tests after these commands should work
  6866. as expected.  For example:
  6867.  
  6868.   CSEND blah < filename
  6869.  
  6870. should fail if there is no command called "blah" or if there is no file called
  6871. "filename".  However, this is not foolproof and sometimes C-Kermit might think
  6872. a command succeeded when it failed, or vice versa.  This is most likely to
  6873. happen when the highly system-dependent methods that Kermit must use to
  6874. determine a command's exit status code do not supply the right information.
  6875.  
  6876. It can also happen because some commands might define success and failure
  6877. differently from what you expect, or because you are using a pipeline composed
  6878. of many commands, and one of them fails to pass failing exit status codes up
  6879. the chain.  The most likely culprit is the shell itself, which in most cases
  6880. must be interposed between Kermit and any external program to be run.
  6881.  
  6882. In any case, you can examine the following variable to find out the exit
  6883. status code returned to Kermit by the process most recently run by any command
  6884. that runs external commands or programs, including CSEND, CRECEIVE, REDIRECT,
  6885. RUN, etc:
  6886.  
  6887.   \v(pexitstat)
  6888.  
  6889. In UNIX, Windows and OS/2, the value should be -2 if no command has been run
  6890. yet, 0 if the most recent command succeeded, -1, -3, or -4 if there was an
  6891. internal error, and a positive number returned by the command itself if the
  6892. command failed.  If the number is in the range 1-127, this is the program's
  6893. exit status code.  If it is 128 or greater, this is supposed to indicate that
  6894. the command or program was interrupted or terminated from outside itself.
  6895.  
  6896. In Windows 95 and 98, the return values of the default shell are unreliable;
  6897. various third-party shells can be used to work around this deficiency.
  6898.  
  6899. In VMS, it is the actual exit status code of the command that was run.  This
  6900. is an odd number if the command succeeded, and an even number if it failed.
  6901. You can see the associated message as follows:
  6902.  
  6903.   run write sys$output f$message(\v(pexitstat))
  6904.  
  6905. Or, more conveniently, use the new Kermit function:
  6906.  
  6907.   echo \ferrstring(\v(pexitstat))
  6908.  
  6909. which converts a system error code (number) to the corresponding message.
  6910.  
  6911. 4.2.6. Cautions about Using Pipes to Transfer Directory Trees
  6912.  
  6913. Although utilities such as tar and zip/unzip might be available on different
  6914. platforms (such as UNIX and Windows), this does not necessarily mean you can
  6915. use them successfully to transfer directory trees between unlike platforms.
  6916. For example:
  6917.  
  6918.   CSEND {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  6919.  
  6920. when used from UNIX to Windows will have satisfactory results for binary
  6921. files, but not for text files.  UNIX text files have lines ending with
  6922. Linefeed (LF) only, whereas Windows text files have lines ending in Carriage
  6923. Return and Linefeed (CRLF).  Thus any text files that were in the archive
  6924. formed by the first tar command will be unpacked by the second tar command
  6925. in their original form, and will display and print incorrectly in Windows
  6926. (except in applications that have been explicitly coded to handle UNIX-format
  6927. text files).  On the other hand if you told gzip to use "text mode" to do
  6928. record format conversion (assuming there was a way to tell it, as there is
  6929. with most "zip" programs), this would destroy any binary files in the archive.
  6930.  
  6931. Furthermore, if the archive contains text files that are written in languages
  6932. other than English, the "special" (accented and/or non-Roman) characters are
  6933. NOT translated, and are therefore likely show up as gibberish on the target
  6934. system.  For example, West European languages are usually encoded in ISO Latin
  6935. Alphabet 1 in UNIX, but in PC code page 850 on the PC.  Capital A with acute
  6936. accent is code point 193 (decimal) Latin-1, but 181 in CP850.  So A-acute in
  6937. the UNIX file becomes Middle Box Bottom on the PC, and similarly for all the
  6938. other special characters, and for all other languages -- Greek, Russian,
  6939. Hebrew, Japanese, etc.
  6940.  
  6941. So when transferring text files between unlike platforms, you should use
  6942. direct Kermit file transfers so Kermit can apply the needed record-format and
  6943. character-set transformations.  Use pipelines containing archivers like tar or
  6944. zip only if all the files are binary or the two systems use the same record
  6945. format and character set for text files.
  6946.  
  6947. Also see sections 4.3, 4.10, 4.11, and 4.15 for how to transfer directory
  6948. trees between both like and unlike systems directly with Kermit.
  6949.  
  6950. 4.2.7. Pipes and Encryption
  6951.  
  6952. Of course pipelines could be used for encrypted file transfers, assuming
  6953. proper precautions could be taken concerning the transmission of the key.
  6954. But there is rarely a good way to do this.  To illustrate using UNIX crypt:
  6955.  
  6956.   csend {crypt key < filename} {!crypt key > filename}
  6957.  
  6958. Or, more ambitiously:
  6959.  
  6960.   csend {tar cf - . | gzip -c | crypt key} {!crypt key | gunzip -c | tar xf -}
  6961.  
  6962. transmits the key in the file header packet as part of the (clear-text) remote
  6963. command, defeating the entire purpose of encrypting the file data.
  6964.  
  6965. But if you are connected in terminal mode to the remote computer and type:
  6966.  
  6967.   creceive {crypt key > filename}
  6968.  
  6969. at the remote Kermit prompt, you have also transmitted the key in clear text
  6970. over the communications link.
  6971.  
  6972. At present, the only secure way to use CSEND and CRECEIVE with an encryption
  6973. filter is to have a human operator at both ends, so the key does not have to
  6974. be transmitted.
  6975.  
  6976. Theoretically it would be possible to use PGP software (Pretty Good Privacy,
  6977. by Phil Zimmerman, Phil's Pretty Good Software) to avoid key transmission
  6978. (since PGP uses separate public and private key and "lets you communicate
  6979. securely with people you've never met, with no secure channels needed for
  6980. prior exchange of keys"), but the specific method has yet to be worked out.
  6981.  
  6982.   HINT: See the PGP User's Guide, e.g. at:
  6983.   http://www.telstra.com.au/docs/PGP/
  6984.   Especially the topic "Using PGP as a UNIX-Style Filter":
  6985.   http://www.telstra.com.au/docs/PGP/pgpdoc2/pgpdoc2_17.html
  6986.  
  6987. In any case, better and more convenient security options are now available:
  6988. Kerberos authentication and encryption (described in the kerberos.txt file)
  6989. and the new ability to run C-Kermit "though" other communication programs,
  6990. described in Section 2.7.
  6991.  
  6992. 4.2.8. Commands and Functions Related to Pipes
  6993.  
  6994. 4.2.8.1. The OPEN !READ and OPEN !WRITE Commands
  6995.  
  6996. These are described in "Using C-Kermit", and are generally useful with reading
  6997. output from commands that produce more than one line on their standard output,
  6998. or writing multiple lines into commands that accept them on their standard
  6999. input.
  7000.  
  7001. In C-Kermit 7.0 CLOSE !READ is accepted as a synonym for CLOSE READ, and
  7002. CLOSE !WRITE for CLOSE WRITE.
  7003.  
  7004. Testing the success and failure of these commands, however, can be a bit
  7005. tricky.  Consider:
  7006.  
  7007.   open !read lalaskjfsldkfjsldkfj
  7008.  
  7009. (where "lalaskjfsldkfjsldkfj" is neither a valid command nor the name of a
  7010. program or script that can be run).  OPEN !READ, in UNIX at least, translates
  7011. this into execl(shellpath,shellname,"-c",command).  This means it starts your
  7012. preferred shell (e.g. from the SHELL environment variable) and asks it to
  7013. execute the given command.  It must be this way, because your command can be a
  7014. either an internal shell command (which only your shell can execute) or an
  7015. external command, which only your shell knows how to find (it knows your PATH
  7016. and interprets, etc).  Therefore unless OPEN !READ can't start your shell,
  7017. it always succeeds.
  7018.  
  7019. Continuing with the nonexistent-command example:
  7020.  
  7021.   C-Kermit>open !read lalaskjfsldkfjsldkfj
  7022.   C-Kermit>status
  7023.    SUCCESS
  7024.   C-Kermit>read line
  7025.   C-Kermit>status
  7026.    SUCCESS
  7027.   C-Kermit>echo "\m(line)"
  7028.   "bash: lalaskjfsldkfjsldkfj: command not found"
  7029.   C-Kermit>close read
  7030.   C-Kermit>status
  7031.    FAILURE
  7032.   C-Kermit>
  7033.  
  7034. In other words, the failure can not be detected on OPEN, since the OPEN
  7035. command succeeds if it can start your shell.  It can't be detected on READ,
  7036. since all this does is read output from the shell, which in this case happens
  7037. to be an error message.  However, failure IS detected upon close, since this
  7038. is the occasion upon which the shell gives Kermit its exit status code.
  7039.  
  7040. For an illustration of this situation, see Section 2.14.
  7041.  
  7042. 4.2.8.2. The REDIRECT Command
  7043.  
  7044. A second method of I/O redirection is offered by the REDIRECT command.
  7045. This is a rather advanced and tricky feature that is presently supported
  7046. only in UNIX C-Kermit, in OS-9 C-Kermit, and in Kermit 95.  Syntax:
  7047.  
  7048. REDIRECT <command>
  7049.   Runs the given <command>, sending its standard output to the current
  7050.   communications channel (SET LINE, SET PORT, or SET HOST connection),
  7051.   and reading its standard input from the same connection.  Works only in
  7052.   local mode -- i.e. a connection is required -- and then only if the given
  7053.   command uses Standard I/O.
  7054.  
  7055. Example:
  7056.  
  7057.   redirect finger
  7058.  
  7059. runs the local "finger" command and sends its output over the connection as
  7060. plain text, where presumably there is a process set up to read it.  Another
  7061. example:
  7062.  
  7063.   redirect finger | sort -r
  7064.  
  7065. shows the use of a pipeline.
  7066.  
  7067. Note: REDIRECT differs from CSEND/CRECEIVE in two important ways: (1) it does
  7068. not use the Kermit protocol, and (2) it uses a bidirectional pipe rather than
  7069. a one-way pipe.
  7070.  
  7071. The primary use of the REDIRECT command is to run external protocols, such as
  7072. sz/rz in UNIX for ZMODEM, when they work over Standard I/O(*).  Example:
  7073.  
  7074.   set host xyzcorp.com
  7075.   (login, etc)
  7076.   redirect sz oofa.zip
  7077.  
  7078. lets you make a Telnet connection with C-Kermit and then do a ZMODEM transfer
  7079. over it.  ZMODEM protocol messages go both ways over the same connection
  7080. simultaneously.
  7081.  
  7082. It is possible to use C-Kermit on UNIX as your PPP dialer and then to REDIRECT
  7083. the connection to the PPP software, but C-Kermit 7.0 offers a better approach
  7084. to PPP dialing in its new EXEC command (Section 1.23).
  7085.  
  7086. In theory, you can also redirect an interactive process.  For example, suppose
  7087. you tell Kermit 95 to wait for an incoming TCP/IP connection:
  7088.  
  7089.   set host * 3000
  7090.  
  7091. and then tell C-Kermit on UNIX to:
  7092.  
  7093.   set host kermit95hostname 3000
  7094.   redirect ksh
  7095.  
  7096. and then tell Kermit 95 to CONNECT: now you are talking to the UNIX K-shell;
  7097. you can give commands (pwd, ls, etc) and see the results.  In practice, the
  7098. K-shell's terminal modes are messed up because (a) it is not going through the
  7099. Unix terminal driver, and (b) it is "smart" and knows it is being redirected,
  7100. and so acts in a decidedly inhospitable manner (other applications like EMACS,
  7101. vi, etc, simply refuse to run if their standard i/o has been redirected).
  7102.  
  7103. (*) Only pre-1988 versions of the publicly-distributed sz/rz programs use
  7104.     Standard I/O; those released later than that do not use Standard I/O and
  7105.     therefore do not work with REDIRECT.  However, Omen Technology does offer
  7106.     an up-to-date redirectable version called crzsz, which must be licensed
  7107.     for use.
  7108.  
  7109. 4.2.8.3. Receiving Mail and Print Jobs
  7110.  
  7111. As of 7.0, and in UNIX only, files that are sent to C-Kermit as mail (when
  7112. the other Kermit uses a MAIL or SEND /MAIL command) or to be printed (via
  7113. REMOTE PRINT or SEND /PRINT) are now piped directly to the mail or print
  7114. program, rather than written to temporary files and then mailed or printed and
  7115. then deleted.  This has the advantages of (a) not requiring a temporary file,
  7116. and (b) allowing mail to have a proper subject in place of the filename.
  7117. Temporary files were bad not only because they required (a) space, and (b)
  7118. writeability of the current directory, but also because using them could
  7119. result in wiping out an existing file.  See section 4.7 for more about SEND
  7120. /MAIL and SEND /PRINT.
  7121.  
  7122. 4.2.8.4. Pipe-Related Functions
  7123.  
  7124. The \fcommand(<command>) function runs the given shell or system command and
  7125. returns the command's standard output as its value (with any newline
  7126. characters stripped from the end), unless the result is too long, in which
  7127. case it returns the empty string.  The maximum length for the result is at
  7128. least 1022 bytes, and it might be longer on some platforms.  Examples (UNIX):
  7129.  
  7130.   C-Kermit> echo "\fcommand(date)"
  7131.   "Fri Apr 18 13:31:42 1997"
  7132.   C-Kermit> echo "\fcommand(finger | wc -l)" ; how many users logged in?
  7133.   "      83"
  7134.   C-Kermit> evaluate \fcommand(finger | wc -l) * 2
  7135.   166
  7136.   C-Kermit> echo Welcome to \fcommand(tty) on \fcommand(date)
  7137.   Welcome to /dev/ttyre on Fri Apr 18 13:31:42 1997
  7138.   C-Kermit> echo "\fcommand(ls oofa.*)"
  7139.   "oofa.c
  7140.   oofa.h
  7141.   oofa.o"
  7142.   C-Kermit> cd /directory-with-thousands-of-files
  7143.   C-Kermit> echo "\fcommand(ls -l)" ; This would be too long
  7144.   ""
  7145.   C-Kermit>
  7146.  
  7147. If a command's output would be too long, you can use the other, more laborious
  7148. method of reading from a command: OPEN !READ <command>, READ each line,
  7149. CLOSE !READ.
  7150.  
  7151. The \frawcommand(<command>) function is identical to \fcommand(<command>),
  7152. except it does not remove trailing newline characters:
  7153.  
  7154.   C-Kermit> echo "\frawcommand(date)"
  7155.   "Fri Apr 18 13:31:42 1997
  7156.   "
  7157.   C-Kermit> echo "\frawcommand(ls oofa.*)"
  7158.   "oofa.c
  7159.   oofa.h
  7160.   oofa.o
  7161.   "
  7162.   C-Kermit>
  7163.  
  7164. Use \frawcommand() if you want to retain the final line terminators, or if
  7165. the command's output is "binary".  But remember that if the result of this
  7166. (or any other) function contains any NUL (ASCII code 0) characters, the first
  7167. NUL will terminate the result string because this is how C strings work
  7168. (it's "C-Kermit", remember?).
  7169.  
  7170. These functions are useful not only locally, but also in the client/server
  7171. arena.  If you need to get the results from a system command on the server
  7172. end into a variable on the client end, just do:
  7173.  
  7174.   [ remote ] query kermit command(date)
  7175.  
  7176. The result is in the local \v(query) variable; see "Using C-Kermit", 2nd Ed.,
  7177. pp.359-360 for details.
  7178.  
  7179. 4.3. Automatic Per-File Text/Binary Mode Switching
  7180.  
  7181. When transferring files between like systems (e.g. UNIX-to-UNIX), binary mode
  7182. can be used for all files unless character-set translation is needed, and in
  7183. fact Kermit programs of recent vintage recognize each others' platforms and
  7184. switch to binary mode automatically when it is appropriate (e.g. DOS to OS/2,
  7185. or UNIX to UNIX).  (Exception: LABELED mode is chosen for VMS-to-VMS and
  7186. OS/2-to-OS/2 transfers so complex file formats can be preserved.)
  7187.  
  7188. On a client/server connection between like systems, the transfer mode is
  7189. currently determined by the file sender, rather than always by the client.
  7190. If the client is sending, it controls the transfer mode.  If a GET command is
  7191. sent to the server, the server sends all files in binary mode if its TRANSFER
  7192. CHARACTER-SET is TRANSPARENT; otherwise it uses text mode for text files
  7193. (according to its text-pattern list) and binary mode for binary files.  Of
  7194. course, the client can control the server's transfer character-set with the
  7195. REMOTE SET TRANSFER CHARACTER-SET command.
  7196.  
  7197. When transferring files between unlike systems, however, (e.g. UNIX-to-DOS),
  7198. some files (such as executable program images) must be transferred in binary
  7199. mode but others (such as plain-text files) must be transferred in text mode so
  7200. their record format and character sets can be appropriately converted.  If a
  7201. binary file is transferred in text mode, it is ruined.  If a text file is
  7202. transferred in binary mode, then at the very least, its format can be
  7203. incorrect; at worst it is also corrupted because its character set was not
  7204. converted (in extreme cases the corruption is total, e.g. because one system
  7205. is ASCII-based and the other EBCDIC).
  7206.  
  7207. 4.3.1. Exceptions
  7208.  
  7209. VMS C-Kermit, when sending files to a non-VMS system, switches to text or
  7210. binary mode automatically for each file, based on the record format in the
  7211. file's directory entry; thus the mechanisms described in this section do not
  7212. apply to VMS C-Kermit, yet the effect is the same: automatic text/binary mode
  7213. switching when VMS C-Kermit is sending files.  See the VMS Appendix of "Using
  7214. C-Kermit" for details.
  7215.  
  7216. Kermit versions that support LABELED or IMAGE transfer mode are likewise
  7217. not affected by this feature when one of those modes is selected (normally
  7218. used only when transferring between like systems).
  7219.  
  7220. Kermit versions that support file-transfer pipes and filters are not affected
  7221. by this feature when pipes or filters are used, since the output of a pipe or
  7222. filter (such as gzip) is likely to require transfer in a different mode than
  7223. the original file.
  7224.  
  7225. Finally, SEND /TEXT or SEND /BINARY will force files to be sent in the
  7226. indicated mode, overriding all automatic transfer-mode-choosing mechanisms.
  7227.  
  7228. 4.3.2. Overview
  7229.  
  7230. Suppose you give C-Kermit a command like:
  7231.  
  7232.   SEND *.*
  7233.  
  7234. And suppose the pattern *.* matches a mixture of text files (such as program
  7235. source code) and binary files (such os object modules or executable programs).
  7236.  
  7237. C-Kermit 6.0 and earlier (except on VMS) send all files in the same mode:
  7238. whatever you said in your most recent SET FILE TYPE command, or else whatever
  7239. mode was chosen automatically according to the rules on page 236 of "Using
  7240. C-Kermit", 2nd Ed.
  7241.  
  7242. But when text and binary files are mixed in the same group, and the files are
  7243. being transferred to an unlike system (e.g. UNIX to IBM Mainframe), this
  7244. results in corruption of either all the text files or all the binary files.
  7245.  
  7246. Stream-oriented file systems such as in UNIX and DOS do not record any
  7247. information about the file to tell us whether the file should be transferred
  7248. in binary or text mode, making it impossible to select the transfer mode
  7249. for each file in a group automatically with any certainty.
  7250.  
  7251. However, we can use some fairly-well established file naming conventions for
  7252. this purpose.  C-Kermit 7.0 lets you provide lists of filename patterns that
  7253. are used to separately determine the file type for each individual file being
  7254. transfered.  A pattern is a string, possibly containing the special characters
  7255. "*" (asterisk, which matches any string of zero of more characters) and/or "?"
  7256. (question mark, which matches any single character).  For example "a*b"
  7257. matches all files whose names start with "a" and end with "b", such as "ab",
  7258. "arb", "ababababab", etc, but not "abba".  And "a?b" matches any file whose
  7259. name starts with "a", ends with "b", and is exactly 3 characters long.
  7260.  
  7261.   NOTE: When typing commands at the C-Kermit prompt, you must
  7262.   prefix "?" with \ to override its normal function of giving help.
  7263.  
  7264. (Also see section 4.9 for additional pattern-matching notations that might
  7265. be available in your version of C-Kermit.)
  7266.  
  7267. When you have specified filename recognition patterns, C-Kermit can transfer
  7268. the ones whose names match any of the binary-mode patterns in binary mode, and
  7269. those with names that match any of the text-mode patterns in text mode, and
  7270. those whose names match neither in the prevailing mode you have chosen, or
  7271. that was chosen automatically via peer recognition.
  7272.  
  7273. 4.3.3. Commands
  7274.  
  7275. SET FILE PATTERNS { ON, OFF, AUTO }
  7276.   This tells Kermit whether to do per-file filename pattern-matching to
  7277.   determine text or binary mode.  The normal and default setting is AUTO,
  7278.   which means to use pattern lists to switch transfer mode only when it is
  7279.   certain that the other Kermit program supports automatic notification of
  7280.   transfer mode (via Attribute packets) on a per-file basis (this information
  7281.   is obtained automatically during protocol startup negotiation).  ON means to
  7282.   always determine the transfer mode from the filename and pattern list when
  7283.   sending files.  Use OFF to disable this feature (without resetting your
  7284.   pattern lists).  Also note that if you have selected LABELED file transfer
  7285.   (SET FILE TYPE LABELED), this takes precedence over filename-matching
  7286.   patterns and all files are sent in labeled mode.
  7287.  
  7288. SET TRANSFER MODE MANUAL
  7289.   Disables the use of filename patterns, no matter what the FILE PATTERNS
  7290.   setting.
  7291.  
  7292. REMOTE SET TRANSFER MODE MANUAL
  7293.   Client command to disable automatic transfer mode, and therefore also
  7294.   filename patterns, in the server.  Synonym: REMOTE SET XFER MODE MANUAL.
  7295.  
  7296. { GET, SEND, etc } { /BINARY, /TEXT }
  7297.   Including a /BINARY or /TEXT (or, where supported, /IMAGE or /LABELED)
  7298.   switch with a file-transfer command changes the transfer mode to manual
  7299.   for that command only, and therefore disables patterns that that command.
  7300.  
  7301. SET FILE BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7302.   A list of zero or more patterns, separated by spaces (not commas).  Letters
  7303.   in a pattern are case-sensitive if the underlying filenames are case
  7304.   sensitive (as in UNIX), and case-insensitive otherwise (as in Windows).  If
  7305.   a file's name is matched by any pattern in the list and SET FILE PATTERNS is
  7306.   ON, the file is sent in binary mode.  Examples:
  7307.  
  7308.     SET FILE BINARY-PATTERNS *.gz *.Z *.tar *.zip *.o *.so *.a *.out ; UNIX
  7309.     SET FILE BINARY-PATTERNS *.EXE *.ZIP *.OBJ *.COM ; DOS or OS/2 or Windows
  7310.  
  7311.   If a pattern contains spaces, enclose it in braces.
  7312.  
  7313. SET FILE TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7314.   Like SET FILE BINARY-PATTERNS, but the patterns choose text files rather
  7315.   than binary ones.  Examples:
  7316.  
  7317.     SET FILE TEXT-PATTERNS *.TXT *.KSC *.HTM* *.BAT ; DOS, Windows, OS/2
  7318.  
  7319. ADD BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7320.   Adds one or more patterns to the BINARY-PATTERN list.
  7321.  
  7322. ADD TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7323.   Adds one or more patterns to the TEXT-PATTERN list.
  7324.  
  7325. REMOVE BINARY-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7326.   Removes one or more patterns from the BINARY-PATTERN list.  The given
  7327.   patterns are matched with the ones in the BINARY-PATTERNS list with
  7328.   case sensitivity if the underlying file system has case-sensitive names
  7329.   (as do UNIX and OS-9), otherwise with case independence.
  7330.  
  7331. REMOVE TEXT-PATTERNS [ <pattern> [ <pattern> [ <pattern> ... ] ] ]
  7332.   Removes one or more patterns from the TEXT-PATTERN list.
  7333.  
  7334. SHOW PATTERNS
  7335.   Displays the current pattern selections.
  7336.  
  7337. Whenever you give a SET FILE BINARY-PATTERNS or SET FILE TEXT-PATTERNS
  7338. command, the previous list is replaced.  If you give one of these commands
  7339. without a pattern list, the previous list is removed.
  7340.  
  7341. When patterns are active and files are being sent, text patterns (if any) are
  7342. applied first (but only if not RESENDing and not sending in LABELED mode),
  7343. then binary patterns, so if the same pattern appears in both lists, binary
  7344. mode is chosen.
  7345.  
  7346. 4.3.4. Examples
  7347.  
  7348. Here's an example that might be used when sending files from UNIX:
  7349.  
  7350.   set file type binary
  7351.   set file text-patterns *.c *.h *.w *.txt makefile
  7352.   set file binary-patterns *.o
  7353.   msend makefile wermit wart ck*.[cwho] ck*.txt
  7354.  
  7355. Note that "wermit" and "wart" do not match any patterns so they are sent in
  7356. the prevailing mode, which is binary.  Also note the use of "makefile" as a
  7357. pattern that does not contain any wildcard characters (there is no other
  7358. convention to distinguish among "wermit" and "wart", which are binary
  7359. executables, and "makefile", which is a text file, purely by their names).
  7360.  
  7361. Most C-Kermit implementations have a default pattern list built in, which
  7362. includes patterns that are almost certain to succeed in picking the right
  7363. transfer mode.  Others are omitted due to ambiguity.  For example ".hlp", and
  7364. ".ini" are generally binary types in Windows but text types everywhere else.
  7365.  
  7366.   NOTE: ".doc", used for decades to denote plain-text documentation
  7367.   files, now more often than not denotes a Microsoft Word Document, so
  7368.   ".doc" is now considered a binary type since it does less harm to
  7369.   transfer a plain-text document in binary mode than it does to transfer
  7370.   an MS Word file in text mode (except when IBM mainframes are involved!)
  7371.  
  7372.   ANOTHER NOTE: ".com" files are binary in DOS-like operating systems,
  7373.   but they are text (DCL command procedures) in VMS.  VMS C-Kermit sends
  7374.   .COM files in text mode; K95 sends them in binary mode.  If you download
  7375.   a .COM file from VMS to DOS or Windows, and then upload it to another
  7376.   VMS system, be sure to use SEND /TEXT to preserve its textness.
  7377.  
  7378. You can see the default pattern list by starting C-Kermit without its
  7379. initialization file (e.g. "kermit -Y") and using the SHOW PATTERNS command.
  7380. If you will be depending on this feature, be sure to examine the list
  7381. carefully in conjunction with the applications that you use.
  7382.  
  7383. The default pattern list does not take "backup files" into account because
  7384. (a) people usually don't want to transfer them; and (b) it would make the
  7385. pattern lists more than twice as long.  For example, we would need to include
  7386. both *.txt and *.txt.~[0-9]*~ for ".txt" files, and similarly for all the
  7387. others.  Instead, you can use SEND /NOBACKUP (or SET SEND BACKUP OFF) to
  7388. skip over all backup files.
  7389.  
  7390. Put your most commonly-used safe pattern declarations in your C-Kermit
  7391. customization file (ckermod.ini, .mykermrc, k95custom.ini, etc).
  7392.  
  7393. As noted, SET FILE PATTERNS is ON by default.  Sometimes, however, it is
  7394. desirable, or necessary, to force files to be sent in a particular mode, and
  7395. often this must be done from the command line (e.g. when using Kermit as a
  7396. download helper in a Web browser like Lynx).  The -V command-line options is
  7397. equivalent to SET FILE PATTERNS OFF and SET TRANSFER MODE MANUAL.  Example:
  7398.  
  7399.   kermit -Vis oofa.txt
  7400.  
  7401. forces oofa.txt to be sent in binary mode, even though ".txt" might match a
  7402. text pattern.
  7403.  
  7404. 4.4. File Permissions
  7405.  
  7406. "Permissions" refers to a code associated with a file that specifies who is
  7407. allowed to access it, and in what manner.  For example, the owner, the members
  7408. of one or more groups, the system administrator, and everybody else, might be
  7409. allowed various combinations of Read, Write, Append, Execute, or Listing
  7410. access.
  7411.  
  7412. The permission code goes by different names on different platforms.  In UNIX,
  7413. it might be called the filemode.  In VMS, it is called the file protection
  7414. (or protection mask).
  7415.  
  7416. The comments in this section presently apply only to the UNIX and VMS versions
  7417. of C-Kermit, to which these features were added in version 7.0; the DOS,
  7418. Windows, and OS/2 file systems embody no notions of protection, and so MS-DOS
  7419. Kermit and Kermit 95 do not send file permissions, and ignore them when
  7420. received.
  7421.  
  7422. The permissions for a received file are determined by a combination of the
  7423. file transfer mode (VMS-to-VMS transfers only), whether a file of the same
  7424. name exists already, whether permissions of the file are received in the file
  7425. attribute packet, and the setting of ATTRIBUTES PROTECTION.
  7426.  
  7427. The default for ATTRIBUTES PROTECTION is ON.  If no attributes are received,
  7428. the effect is the same as if attributes PROTECTION were OFF.
  7429.  
  7430. For VMS-to-VMS transfers, the default LABELED mode simply copies the
  7431. protection code from source to destination.
  7432.  
  7433. 4.4.1. When ATTRIBUTES PROTECTION is OFF
  7434.  
  7435. If no file of the same name exists, system defaults determine the permissions
  7436. of the new file.  Otherwise, the actions taken depend on the current FILE
  7437. COLLISION setting: BACKUP, OVERWRITE, RENAME, etc, as documented in "Using
  7438. C-Kermit".  But now the new file (if it is created at all) automatically
  7439. inherits the permissions (mode bits) of the existing file in a way that is
  7440. appropriate for the platform.
  7441.  
  7442. 4.4.1.1. Unix
  7443.  
  7444. All mode bits are inherited except the directory bit, since the
  7445. incoming file can not possibly be a directory.  (In any case, it is not
  7446. possible to receive a file that has the same name as an existing directory
  7447. unless FILE COLLISION is set to RENAME).
  7448.  
  7449. 4.4.1.2. VMS
  7450.  
  7451. Files with the same name as an existing file, transferred in modes other than
  7452. LABELED between VMS systems, inherit the protection of the prior version.
  7453.  
  7454. 4.4.2 When ATTRIBUTES PROTECTION is ON
  7455.  
  7456. File permissions can be conveyed as part of the file transfer process, in
  7457. accordance with the Kermit protocol definition.  If the file sender puts
  7458. system-dependent and/or system-independent versions of the file protection
  7459. (permissions) into the Attribute (A) packet, the file receiver can set the new
  7460. file's permissions from them.  Otherwise, the permissions are set the same as
  7461. for ATTRIBUTES PROTECTION OFF.
  7462.  
  7463. When the incoming A packet contains system-dependent permissions, the file
  7464. receiver checks to see if the sender has the same system ID (e.g. both the
  7465. sending and receiving systems are UNIX, or both are VMS); if so, it decodes
  7466. and uses the system-dependent permissions; otherwise it uses the generic ones
  7467. (if any) and applies them to the owner field, setting the other fields
  7468. appropriately as described in the following sections.
  7469.  
  7470. Setting the incoming file's protection from the A packet is controlled by SET
  7471. ATTRIBUTES PROTECTION (or PERMISSION), which is ON by default, and its status
  7472. is displayed by SHOW ATTRIBUTES.
  7473.  
  7474. The main benefit of this feature is to not have to "chmod +x" an executable
  7475. file after transfer from UNIX to UNIX.  Its cross-platform benefits are less
  7476. evident, perhaps to retain the status of the Unix 'x' bit on a VMS system,
  7477. for subsequent transfer back to a Unix system.
  7478.  
  7479. 4.4.2.1. System-Specific Permissions
  7480.  
  7481. System-specific file permissions are used when the two Kermit programs
  7482. recognize each other as running on the same type of system.  For example,
  7483. both are running under some form of UNIX (it doesn't matter which UNIX
  7484. variation -- HP-UX, Solaris, AIX, etc -- all use the same scheme for file
  7485. permissions); or both are running under VMS (even if one is on an Alpha and
  7486. the other on a VAX, and/or one is old and the other is new).
  7487.  
  7488. 4.4.2.1.1. UNIX
  7489.  
  7490. UNIX supports three categories of users, File Owner, Group, and World,
  7491. and three types of file access permission: Read, Write, and Execute.  Thus,
  7492. a UNIX file's permissions are expressed in 9 bits.
  7493.  
  7494. The system-dependent permission string for UNIX is a 3-digit octal string, the
  7495. low-order 9 bits of the st_mode member of the stat struct; we deliberately
  7496. chop off the "file format" bits because they are not permissions, nor do we
  7497. convey the setuid/setgid bits, lock bit, sticky bit, etc.
  7498.  
  7499. 4.4.2.1.2. VMS
  7500.  
  7501. VMS supports four categories of users, System, File Owner, Group, and World,
  7502. and four types of file access permission: Read, Write, Execute, and Delete.
  7503. Thus, a VMS file's permissions are expressed in 16 bits.
  7504.  
  7505. The system-dependent protection string for VMS is a 4-digit hexadecimal
  7506. string, corresponding to the internal-format protection word of the file
  7507. (RWED for each of World,Group,Owner,System).  A new file normally gets all 16
  7508. protection bits from the original file of the same name.
  7509.  
  7510. Note: VMS-to-VMS transfers take place in LABELED mode when the two C-Kermits
  7511. recognize each other's platform as VMS (unless you have disabled LABELED-mode
  7512. transfers).  In this case, all of a file's attributes are preserved in the
  7513. transfer and the protection mask (and other information) is taken from the
  7514. file's internal information, and this takes precedence over any information
  7515. in the Attribute packets.  You can defeat the automatic switching into
  7516. LABELED mode (if you want to) with SET TRANSFER MODE MANUAL.
  7517.  
  7518. 4.4.2.2. System-Independent Permissions
  7519.  
  7520. The system-independent ("generic") protection is used when the system IDs of
  7521. the two Kermit programs do not agree (e.g. one is UNIX, the other is VMS).
  7522. The generic protection attribute includes the following permissions (not all
  7523. are applicable to every file system): Read, Write, Append, Execute, Delete,
  7524. Search.  The generic permissions are derived from the owner permissions of
  7525. the source file, thus, a Unix 'w' permission becomes VMS Write,Delete.
  7526.  
  7527. The Owner field of the new file's permissions is set from the incoming
  7528. generic protection attribute.
  7529.  
  7530. In UNIX, the Group and World permissions are set according to your umask,
  7531. except that execute permission is NOT set in these fields if it was not also
  7532. set in the generic protection (and consequently, is set in the Owner field).
  7533.  
  7534. In VMS, the System, Group, and World permissions are set according to the
  7535. process default file permission (as shown in VMS by SHOW PROTECTION), except
  7536. that no permissions are allowed in these fields that are not included in the
  7537. generic permissions.
  7538.  
  7539. Note that the VMS and UNIX interpretations of Execute permission are not
  7540. identical.  In UNIX, a file (binary executable, shell script, etc) may not
  7541. be executed unless it has Execute permission, and normally files that are
  7542. not intended for execution do not have Execute permission.  In VMS, Read
  7543. permission implicitly supplies Execute capability.  Generally files that have
  7544. Read permission also have explicit Execute permission, but files (binary
  7545. executables, DCL command procedures) that have Read permission and not
  7546. Execute permission can still be executed.
  7547.  
  7548. 4.5. File Management Commands
  7549.  
  7550. 4.5.1. The DIRECTORY Command
  7551.  
  7552. Prior to C-Kermit 7.0, the DIRECTORY command always ran an external system
  7553. command (such as "ls" on UNIX) or program to product the directory listing.
  7554. This had certain advantages, mostly that you could include system-dependent
  7555. options for customized listings, e.g. on UNIX:
  7556.  
  7557.   dir -lt c* | more
  7558.  
  7559. or in VMS:
  7560.  
  7561.   directory /size/date/protection/except=*.obj oofa.*;0
  7562.  
  7563. This approach, however, carries some disadvantages: C-Kermit can't return
  7564. SUCCESS or FAILURE status for (e.g.) "dir foo" according to whether the file
  7565. "foo" exists; and it runs an inferior process, which might be a problem in
  7566. some environments for resource and/or security reasons, and won't work at all
  7567. in a "nopush" environment (e.g. one in which C-Kermit is configured to forbid
  7568. access to exterior commands and programs, e.g. in a VMS "captive account").
  7569.  
  7570. In C-Kermit 7.0 on VMS and UNIX, and in K95 1.1.18 and later, the DIRECTORY
  7571. command is internal to Kermit.  It can be run in a "nopush" environment and
  7572. returns SUCCESS or FAILURE status appropriately.  In UNIX it prints all dates
  7573. and times in a consistent way (unlike ls).  In VMS it prints precise file
  7574. sizes, rather than "blocks".  It offers several formatting and other options,
  7575. but it is not necessarily more flexible than the corresponding external
  7576. commands or programs (the UNIX "ls" program, the VMS "directory" command).
  7577. The syntax is:
  7578.  
  7579.   DIRECTORY [ switch [ switch [ ... ] ] ] [ filespec ]
  7580.  
  7581. If no filespec is given, all files in the current directory are listed.
  7582.  
  7583. Optional switches include all the standard file-selection switches presented
  7584. in Section 1.5.4, plus:
  7585.  
  7586. /ALL
  7587.   Show both regular files and directories; this is the default.
  7588.  
  7589. /ARRAY:x
  7590.   Instead of displaying a directory listing, put the files that would have
  7591.   been shown (based on the filespec and other selection switches) in the
  7592.   given array.  The array need not (and should not) be predeclared; if the
  7593.   array already exists, it is destroyed and reused.  The array name can be a
  7594.   single letter, like "a", or any fuller form, such as "&a", "\&a", "\&a[]",
  7595.   etc.  If the /ARRAY switch is included, the following other switches are
  7596.   ignored: /BRIEF, /VERBOSE, /HEADING, /PAGE, /ENGLISHDATE, /ISODATE,
  7597.   /XFERMODE, /MESSAGE, /SORT, /REVERSE, /ASCENDING.  In other words, only
  7598.   file selection switches are meaningful with /ARRAY: /FILES, /DIRECTORIES,
  7599.   /ALL, /DOTFILES, /NOBACKUP, /RECURSIVE, /SMALLER, /LARGER, /AFTER,
  7600.   /BEFORE, /EXCEPT, etc.  The resulting array has the number of files (n) as
  7601.   its 0th element, and the filenames in elements 1 through n.  Example:
  7602.  
  7603.     dir /array:&a /files /nobackup /after:19990101 /larger:10000 [ab]*
  7604.     show array &a
  7605.  
  7606. /FILES
  7607.   Only show regular files.
  7608.  
  7609. /DIRECTORIES
  7610.   Only show directories.
  7611.  
  7612. /BACKUP
  7613.   In UNIX, OS-9, K-95, and other versions that support SET FILE COLLISION
  7614.   BACKUP and create backup files by appending .~n~ to the filename (where
  7615.   "n" is a number), /BACKUP means to include these files in directory
  7616.   listings.  This is the default.
  7617.  
  7618. /NOBACKUP
  7619.   This is the opposite of /BACKUP: that is, do not include backup files in
  7620.   the listing.
  7621.  
  7622. /BRIEF
  7623.   List filenames only; use a compact format, as many filenames as will fit
  7624.   across the screen (based on the longest name).  A brief listing is always
  7625.   sorted alphabetically.
  7626.  
  7627. /VERBOSE
  7628.   List one file per line, and include date, size, and (in UNIX only)
  7629.   permissions of each file.  This is the opposite of /BRIEF, and is the
  7630.   default.
  7631.  
  7632. /PAGE
  7633.   Pause at the end of each screenful and give a "more?" prompt, even if
  7634.   SET COMMAND MORE-PROMPTING is OFF.
  7635.  
  7636. /NOPAGE
  7637.   Don't pause at the end of each screenful and give a "more?" prompt, even if
  7638.   SET COMMAND MORE-PROMPTING is ON.  If neither /PAGE or /NOPAGE is given,
  7639.   paging is according to the prevailing COMMAND MORE-PROMPTING setting (which
  7640.   can be displayed with SHOW COMMAND).
  7641.  
  7642. /ENGLISHDATE
  7643.   Show dates in dd-mmm-yyyy format; mmm is the first three letters of the
  7644.   English month name.
  7645.  
  7646. /ISODATE
  7647.   Show dates in yyyy-mm-dd format; mm is the month number, 1-12.
  7648.   This is the opposite of /ENGLISHDATE, and is the default.
  7649.  
  7650. /HEADINGS
  7651.   Print a heading before the listing and a summary at the end.
  7652.  
  7653. /NOHEADINGS
  7654.   Don't print a heading before the listing or a summary at the end.
  7655.   This is the opposite of /HEADINGS, and is the default.
  7656.  
  7657. /XFERMODE
  7658.   Only in Kermit programs that support SET FILE PATTERNS.  If this switch is
  7659.   included, and the filename matches any FILE BINARY-PATTERN (Section 4.3),
  7660.   "(B)" is printed after the filename; otherwise, if it matches a FILE
  7661.   TEXT-PATTERN, "(T)" is printed.
  7662.  
  7663. /NOXFERMODE
  7664.   Don't display transfer-mode indicators.  This is the opposite of /XFERMODE
  7665.   and is the default.
  7666.  
  7667. /RECURSIVE
  7668.   Show files not only in the given directory, but also in its subdirectories
  7669.   (if any), their subdirectories, etc.
  7670.  
  7671. /NORECURSIVE
  7672.   Don't show files in subdirectories.  This is the opposite of /RECURSIVE,
  7673.   and is the default.
  7674.  
  7675. /MESSAGE:text
  7676.   This lets you specify a short text string to be appended to the end of
  7677.   each directory listing line (a space is supplied automatically).  If the
  7678.   text contains any spaces, enclose it in braces, e.g. /MESSAGE:{two words}.
  7679.  
  7680. /NOMESSAGE
  7681.   Don't append any message to the end of each directory listing line
  7682.   (default).
  7683.  
  7684. /SORT:[{NAME,SIZE,DATE}]
  7685.   Sort the listing by name, size, or date.  If the /SORT switch is given
  7686.   but the "sort-by" keyword is omitted, the listing is sorted by name.
  7687.   /SORT:NAME /ASCENDING (alphabetic sort by name) is the default.
  7688.  
  7689. /NOSORT
  7690.   Don't sort the listing.  Files are listed in whatever order they are
  7691.   supplied by the operating system, e.g. inode order in UNIX.
  7692.  
  7693. /REVERSE
  7694.   If the /SORT switch is given, reverse the order of the sort.
  7695.   Synonym: /DESCENDING.
  7696.  
  7697. /ASCENDING
  7698.   If the /SORT switch is given, sort the listing in normal order.
  7699.   This is the opposite of /REVERSE and is the default.
  7700.  
  7701. Note that most of the DIRECTORY-specific switches come in pairs, in which
  7702. one member of a pair (e.g.  /NOHEADINGS) is the opposite of the other
  7703. (e.g. /HEADINGS).
  7704.  
  7705. If you always want to use certain options, you can set them with the SET
  7706. OPTIONS DIRECTORY command (Section 1.5.5).  Use SHOW OPTIONS to list the
  7707. options currently in effect.  To make the desired options apply every time you
  7708. run C-Kermit, put a SET OPTIONS DIRECTORY command in your C-Kermit
  7709. customization file, specifying the desired options.  Options set in this
  7710. manner apply to every subsequent DIRECTORY command.  Of course, if you include
  7711. switches in a DIRECTORY command, these override any defaults, built-in or
  7712. custom.  Example:
  7713.  
  7714.   DIRECTORY            ; Use "factory defaults"
  7715.   SET OPTIONS DIRECTORY /SORT:SIZE /REVERSE /HEADINGS  ; Customize defaults
  7716.   DIRECTORY            ; Use customized defaults
  7717.   DIR /SORT:NAME       ; Override customized default SORT key
  7718.   SET OPT DIR /RECURS  ; Add /RECURSIVE to customized defaults
  7719.   DIR /ASCEND          ; Override customized default SORT order
  7720.  
  7721. Notes:
  7722.  
  7723.  . Only a single sort key is supported; there is presently no way to
  7724.    have multiple sort keys.
  7725.  
  7726.  . If the /BRIEF switch is given, all other switches (except /[NO]RECURSIVE,
  7727.    /[NO]DOTFILES, /DIRECTORIES, /FILES, and /ALL) are ignored.
  7728.  
  7729.  . /SORT:<anything> gives incorrect results if any files have lengths
  7730.    greater than 10 digits (i.e. that are more than 9999999999 bytes long, i.e.
  7731.    if they are 10GB or more in size) because the overlong length field causes
  7732.    the date and name fields to be misaligned.
  7733.  
  7734.  . /SORT:NAME is redundant in VMS since VMS returns filenames in alphabetic
  7735.    order anyway.
  7736.  
  7737.  . /SORT:NAME ignores alphabetic case on platforms where case does not matter
  7738.    in filenames, but this works only for unaccented Roman letters A-Z.
  7739.  
  7740.  . /SORT:NAME is currently based on code values, and so works fine for ASCII,
  7741.    but will probably produce unexpected results for files with non-ASCII or
  7742.    8-bit characters in their names.  (Locale-based sorting raises rather
  7743.    significant issues of portability, size, performance, etc.)
  7744.  
  7745.  . /SORT:DATE works right only for ISO-format dates, not English ones.
  7746.  
  7747.  . /SORT:SIZE sorts the size field lexically.  On some platforms
  7748.    (e.g. Windows), the size of a directory file is listed as "<DIR>" rather
  7749.    than as a number; in this case, the "<DIR>" files are gathered at the end
  7750.    (or beginning, depending on the sort order) of the listing.
  7751.  
  7752.  . /RECURSIVE is accepted but ignored in AOS/VS.  Use the normal
  7753.    system-specific filespec notation, e.g. "dir #.txt".
  7754.  
  7755.  . /RECURSIVE has no affect when a full, absolute pathname is given; e.g.
  7756.    "dir /recursive /tmp/foo" (where "foo" is a regular file) only shows the
  7757.    "/tmp/foo" file.  If you want to see all "foo" files in the /tmp tree,
  7758.    do "cd /tmp" and then "dir /recursive foo".
  7759.  
  7760.  . If a file size of -1 is shown, or date-time of 0000-00-00 00:00:00, this
  7761.    means the file was located, but access to information about the file was
  7762.    denied to C-Kermit.
  7763.  
  7764.  . In VMS, if FOO.DIR;1 is a directory within your current directory,
  7765.    "directory foo" and "directory [.foo]" list the files in the [.FOO]
  7766.    subdirectory, but "directory foo.dir" lists the directory file itself;
  7767.    similarly for "*.dir" versus "[.*]", etc.
  7768.  
  7769.  . In UNIX, if "foo" is a directory within your current directory,
  7770.    "directory foo" lists the files in the foo directory.  If you want to
  7771.    list the foo directory file itself, put an asterisk at the end:
  7772.    "dir foo*".
  7773.  
  7774. Hint: How to find the biggest files in a directory tree:
  7775.  
  7776.   cd xxx ; (root of tree)
  7777.   directory /sort:size /recursive /reverse /dotfiles /page
  7778.  
  7779. Another hint: If you often use several different directory-listing formats,
  7780. define macro shortcuts for them:
  7781.  
  7782.   DEFINE WD DIRECTORY /SORT:DATE /REVERSE \%*  ; Reverse chronological order
  7783.   DEFINE SD DIRECTORY /SORT:SIZE /REVERSE \%*  ; Reverse order of size
  7784.   DEFINE ND DIRECTORY /SORT:NAME /ASCEND \%*   ; Alphabetical by name
  7785.   DEFINE DL DIR /DIR /SORT:NAME /ASCEND \%*    ; Alphabetical directory list
  7786.  
  7787. Put these definitions in your C-Kermit customization file.  Note that "\%*"
  7788. (Section 7.5) in these definitions lets you include other switches in your
  7789. macro invocations, e.g.:
  7790.  
  7791.   wd /headings *.txt
  7792.  
  7793. Of course you can still access your external directory listing program by
  7794. using RUN or "!", e.g. in VMS:
  7795.  
  7796.   run directory /size/date/protection/except=*.obj oofa.*;0
  7797.  
  7798. or:
  7799.  
  7800.   !dir /size/date/prot/exc=*.obj oofa.*;0
  7801.  
  7802. In UNIX, use "!ls" or just "ls" (which is a special synonym for "!ls").
  7803.  
  7804. 4.5.2. The CD and BACK Commands
  7805.  
  7806. In 7.0, the CD command has a new friend, the BACK command.  BACK
  7807. means "CD to my previous current directory".  A second BACK brings you back
  7808. to where you were before the first one; thus successive BACK commands switch
  7809. back and forth between two directories.
  7810.  
  7811. 4.5.2.1. Parsing Improvements
  7812.  
  7813. The CD command, as well as other commands that parse a directory name, were
  7814. changed in 7.0 to provide all the expected functions: completion on Tab
  7815. or Esc, directory-name lists on ?, etc.  Other affected commands include
  7816. SET SERVER GET-PATH, SET TEMP-DIRECTORY, SET FILE DOWNLOAD-DIRECTORY, and
  7817. SPACE.  CD and REMOTE CD also now work with logical names.
  7818.  
  7819. In VMS, the situation is a bit complicated since a directory name can look
  7820. like "DEV:", "[FOO.BAR]", "DEV:[FOO.BAR]", "[FOO]BAR.DIR;1", etc.  Completion
  7821. and ?-help might not always work, but they do in many cases.  Examples:
  7822.  
  7823.   cd ?           Lists all subdirectories of the current directory
  7824.   cd []?         Ditto
  7825.   cd k?          Ditto, but only those starting with K
  7826.   cd [foo]?      Lists all subdirectories of the [FOO] directory
  7827.   cd [-]?        Lists all subdirectories of the superior directory
  7828.   cd [--]?       Lists all subdirectories of the directory 2 levels up
  7829.   cd [...]?      Lists all directories below the current one
  7830.   cd [foo.?      Does not work.
  7831.  
  7832. C-Kermit allows all of the following in VMS:
  7833.  
  7834.   cd bar         CD to subdirectory BAR of the current directory
  7835.   cd .bar        Ditto
  7836.   cd [.bar]      Ditto
  7837.   cd bar.dir     etc...
  7838.   cd bar.dir;
  7839.   cd bar.dir;1
  7840.   cd [foo.bar]
  7841.   cd bar.baz     This can go more than 1 level deep...
  7842.   cd dir:        (where logical name DIR is defined as [FOO.BAR])
  7843.  
  7844. As well as the following:
  7845.  
  7846.   cd ..          Go up one level as in UNIX
  7847.   cd .           The current directory
  7848.   cd             My login directory
  7849.  
  7850. Note that "cd -" (go up one level) does not work as expected, because "-" is
  7851. Kermit's command continuation character.  However, "cd [-]", and "cd {-}" have
  7852. the desired effect (and so does "cd ..", which is easier to type).
  7853.  
  7854. 4.5.2.2. The CDPATH
  7855.  
  7856. The CD command in the UNIX, Windows, OS/2, and VMS versions of C-Kermit, as of
  7857. version 6.1 / 1.1.12, searches the CDPATH for the given directory, if it is not
  7858. absolute and if a CDPATH environment variable is defined.  Example (in UNIX
  7859. ksh or bash):
  7860.  
  7861.   $ export CDPATH=$HOME:$HOME/kermit:/tmp
  7862.  
  7863. Now if you give a "cd xxx" command, no matter what your current directory is,
  7864. if the "xxx" directory is not a subdirectory of your current directory, then
  7865. the xxx subdirectory of your home directory is used or if that does not exist,
  7866. then the xxx subdirectory of the kermit subdirectory of your home directory is
  7867. used or if that does not exist, then /tmp/xxx is used.  This is how the ksh
  7868. "cd" command works, and now the C-Kermit CD command works the same way.
  7869.  
  7870. In VMS, you can define CDPATH to be a list of directories that contain actual
  7871. directory delimiters, and/or logical names representing directories, using
  7872. commas to separate them, e.g.:
  7873.  
  7874.   $ define cdpath [HOME],[SOMEOTHERDIR],[HOME.MISC]
  7875.  
  7876. or:
  7877.   $ define cdpath SYS$LOGIN:,DISK1:[HOME],DISK2:[SCRATCH.IVAN]
  7878.  
  7879. Example:
  7880.   $ define cdpath SYS$LOGIN:,[IVAN],[OLAF],[OLGA.MISC]
  7881.   $ kermit
  7882.   DISK1:[OLGA] C-Kermit> cd blah
  7883.  
  7884. tries the BLAH subdirectory of the user's login directory, then [OLGA.BLAH],
  7885. [IVAN.BLAH], [OLAF.BLAH], and [OLGA.MISC.BLAH], in that order, using the first
  7886. one it finds, failing if it finds none.
  7887.  
  7888. In C-Kermit 7.0, you may also set the CDPATH from the Kermit prompt:
  7889.  
  7890. SET CD PATH <path>
  7891.   Allows the CD PATH to be set from within C-Kermit.
  7892.  
  7893. SHOW CD shows the CD path and all other information relevant to the CD command.
  7894.  
  7895. 4.5.2.3. CD Messages
  7896.  
  7897. Whenever you change directory, you can have C-Kermit display a "Read Me" file
  7898. from the new directory automatically.  The commands are:
  7899.  
  7900. SET CD MESSAGE { ON, OFF, FILE <list> }
  7901.   ON enables this feature; OFF (the default) disables it.  File lets you
  7902.   specify the name of the "Read Me" file.  A list of names to look for can be
  7903.   given in the following format:
  7904.  
  7905.     {{name1}{name2}{name3}{...}}
  7906.  
  7907.   e.g. SET SERVER CD-MESSAGE FILE {{./.readme}{README.TXT}{READ.ME}}
  7908.   The default list of CD-message files is system dependent.
  7909.  
  7910. SHOW CD shows your current directory, previous directory, CD path, and CD
  7911. message info.
  7912.  
  7913. 4.5.3. Creating and Removing Directories
  7914.  
  7915. The MKDIR command now allows you to create multiple directories at once:
  7916.  
  7917.   C-Kermit> mkdir a/b/c/d
  7918.  
  7919. creates the directory a in the current directory (if it doesn't exist
  7920. already), and then creates a subdirectory b of the a directory (if it didn't
  7921. exist already), and so on.
  7922.  
  7923. If you use MKDIR to try to create a directory that already exists, C-Kermit
  7924. will print a warning ("?Directory already exists"), but the MKDIR command
  7925. will still succeed.  If you want to avoid the warning message, use
  7926. IF DIRECTORY first to check if the directory already exists.
  7927.  
  7928. The RMDIR command, however, will not remove more than one directory, nor
  7929. will it remove a directory that contains any files.  (There is, as yet, no
  7930. RMDIR /RECURSIVE command, although one might be added later.)
  7931.  
  7932. In VMS, these commands (like CD) are more forgiving of your syntax than is the
  7933. DCL command shell; "mkdir oofa" is equivalent to "mkdir [.oofa]" and so on.
  7934. Also in VMS, you'll find that C-Kermit's RMDIR command is easier than deleting
  7935. a directory in DCL, since it automatically first gives it owner delete
  7936. permission if you are the owner.
  7937.  
  7938. 4.5.4. The DELETE and PURGE Commands
  7939.  
  7940. The DELETE command now offers a selection of switches, and has a new
  7941. companion, the PURGE command.  First, DELETE:
  7942.  
  7943. DELETE [ switches... ] filespec
  7944.   Deletes the file or files that match the filespec, which may contain
  7945.   wildcards (Section 4.9).
  7946.  
  7947. Optional switches include the standard file-selection switches presented in
  7948. Section 1.5.4, plus:
  7949.  
  7950. /ASK
  7951.   Before deleting each file, ask permission interactively.  Answers are
  7952.   Yes or OK (delete the file), No (don't delete it), or Quit (stop executing
  7953.   the DELETE command).
  7954.  
  7955. /NOASK
  7956.   Don't ask permission to delete each file.
  7957.  
  7958. /LIST
  7959.   List each file and show whether it was deleted.  Synonyms: /LOG, /VERBOSE.
  7960.  
  7961. /NOLIST
  7962.   Don't list files while deleting them.  Synonyms: /NOLOG, /QUIET.
  7963.  
  7964. /HEADING
  7965.   Print a heading and summary line.
  7966.  
  7967. /NOHEADING
  7968.   Don't print a heading and summary line.
  7969.  
  7970. /PAGE
  7971.   When listing, pause at the end of each screenful and give the "More?"
  7972.   prompt.  If you reply "n" (no), the DELETE command terminates.
  7973.  
  7974. /SIMULATE
  7975.   Do everything implied by the given switches and filespec, except do not
  7976.   actually delete any files.  This lets you preview which files would be
  7977.   deleted; implies /LIST.
  7978.  
  7979. Now the PURGE command:
  7980.  
  7981. PURGE [ switches... ] [ filespec ]
  7982.   (VMS only) Runs the DCL PURGE command.  Switches and filespec, if any,
  7983.   are passed directly to DCL without parsing or verification.  Deletes
  7984.   excess versions of the given (or all) files.  The rest of this section
  7985.   does not apply to VMS.
  7986.  
  7987. PURGE [ switches... ] [ filespec ]
  7988.   (UNIX only) Deletes "backup files" that match the filespec, which may
  7989.   contain wildcards (Section 4.9).  If no filespec is given, all backup
  7990.   files in the current directory are selected (subject to modification by
  7991.   any switches).  Do not include backup notation in the filespec.
  7992.  
  7993. Explanation:
  7994.  
  7995. To avoid destroying preexisting files when a new file arrives that has the
  7996. same name, C-Kermit backs up the old file by appending a "backup number" to
  7997. its name.  In UNIX, the backup suffix consists of a period, a tilde, a number,
  7998. and another tilde.  For example, if a file called oofa.txt exists and a new
  7999. oofa.txt file arrives, the original is renamed to oofa.txt.~1~.  If another
  8000. oofa.txt file arrives, the existing one is renamed to oofa.txt.~2~.  And so
  8001. on.  This system is compatible with the one used by EMACS.  Thus over time, if
  8002. you receive a lot of files with C-Kermit or edit them with EMACS, backup files
  8003. can build up.  The new PURGE command lets you clean out accumulated backup
  8004. files:
  8005.  
  8006. Optional switches include the standard file-selection switches presented in
  8007. Section 1.5.4, plus all the switches listed above for the DELETE command,
  8008. plus:
  8009.  
  8010. /KEEP:n
  8011.   Retains the 'n' most recent (highest-numbered) backup files for each file.
  8012.   For example, if oofa.txt, oofa.txt.~1~, oofa.txt.~2~, oofa.txt.~10~,
  8013.   oofa.txt.~12~, and oofa.txt.~100~ exist, "purge /keep:2 oofa.txt" deletes
  8014.   oofa.txt.~1~, oofa.txt.~2~, and oofa.txt.~10~, and keeps oofa.txt,
  8015.   oofa.txt.~12~, and oofa.txt.~100~.  If /KEEP is given without a number,
  8016.   one (the highest numbered) backup file is kept.
  8017.  
  8018. CAUTION: The PURGE command should be used only when *.~*~ files truly are
  8019. backup files.  This is the case for EMACS, and it is the DEFAULT for C-Kermit.
  8020. However, if C-Kermit's FILE COLLISION has been set to RENAME, newly received
  8021. files will look like backup files.  In that case, don't use the PURGE command
  8022. or you'll be removing new files rather than old ones.  (Use SHOW FILE to find
  8023. the FILE COLLISION setting.)
  8024.  
  8025. The PURGE command is presently available only in UNIX.  The command succeeds
  8026. if it deleted any files, or if it deleted no files but there were no errors.
  8027. It fails if it deleted no files and there were errors (i.e. deletion was
  8028. attempted but failed).  In VMS, backup file versions are handled automatically
  8029. by the OS, and a PURGE command can be used at the VMS prompt to clean them up.
  8030.  
  8031. If you want certain switches to be supplied automatically with each DELETE or
  8032. PURGE command, you can set them with SET OPTIONS (Section 1.5.5) and you can
  8033. display any such settings with SHOW OPTIONS.  Of course you can override them
  8034. on a per-command basis by including switches in your PURGE or DELETE command.
  8035.  
  8036. Also see SET FILE COLLISION, SHOW FILE, SEND /NOBACKUP, SET SEND BACKUP, and
  8037. DIRECTORY /[NO]BACKUP.
  8038.  
  8039. 4.6. Starting the Remote Kermit Server Automatically
  8040.  
  8041. As noted on pages 275-276 of "Using C-Kermit" 2nd edition, you can have Kermit
  8042. send "kermit receive" commands automatically when it is in local mode and you
  8043. give a SEND or similar command, to start the remote Kermit receiver in case it
  8044. is not already started.  The "kermit receive" commands are specified by:
  8045.  
  8046.   SET PROTOCOL KERMIT <binary-receive-command> <text-receive-command>
  8047.  
  8048. As of version 7.0, a Kermit protocol option has been added to send a string
  8049. to the host in advance of any Kermit packets when you give a GET-class or
  8050. REMOTE command.  This will switch the remote C-Kermit into the appropriate
  8051. mode or, if the remote system is at a system command (shell) prompt,
  8052. execute the string on the remote system.  The new syntax of the SET PROTOCOL
  8053. KERMIT command is:
  8054.  
  8055.   SET PROTOCOL KERMIT [ <s1> [ <s2> [ <s3> ] ] ]
  8056.  
  8057. where:
  8058.  
  8059.        Default         Meaning
  8060.   s1  {kermit -ir}     Remote "kermit receive in binary mode" command.
  8061.   s2  {kermit -r}      Remote "kermit receive in text mode" command.
  8062.   s3  {kermit -x}      Remote "start kermit server" command.
  8063.  
  8064. NOTE: If the remote Kermit is 6.0, the following are recommended for fast
  8065. startup and high-performance file transfer (see Appendix I in "Using
  8066. C-Kermit", second Edition, for command-line options):
  8067.  
  8068.   s1   kermit -YQir   (Kermit receive binary, skip init file, fast.)
  8069.   s2   kermit -YQTr   (Kermit receive text, skip init file, fast.)
  8070.   s3   kermit -YQx    (Kermit server, skip init file, fast.)
  8071.  
  8072. If the remote is C-Kermit 7.0 or later, change the -x option (enter server
  8073. mode) to -O (uppercase letter O), which means "enter server mode for One
  8074. transaction only); this way, it is not stuck in server after the transfer.
  8075. Also note that the Q is redundant in version 7.0, since fast Kermit protocol
  8076. settings are now the default.
  8077.  
  8078. Note that in case the C-Kermit executable is called "wermit" or "ckermit"
  8079. you can change "kermit" in the strings above to "wermit" or "ckermit" and
  8080. C-Kermit 7.0 or later will recognize these as synonyms for "kermit", in case
  8081. it is at its command prompt when one of these strings is sent to it.
  8082.  
  8083. 4.7. File-Transfer Command Switches
  8084.  
  8085. Over the years, various new methods of transferring a file have accumulated,
  8086. until we had, in addition to the SEND command, also MOVE (send and then
  8087. delete), MAIL (send as email), REMOTE PRINT (send to be printed), CSEND (send
  8088. the output of a command), PSEND (send a part of a file), BSEND (send in binary
  8089. mode), RESEND (resume an interrupted SEND), etc etc.  Similarly: GET, REGET,
  8090. CGET, RETRIEVE, and so on.
  8091.  
  8092. Not only is it confusing to have different names for these commands, many of
  8093. which are not real words, but this also does not allow all combinations, like
  8094. "send a file as mail, then delete it".
  8095.  
  8096. In C-Kermit 7.0, the SEND, GET, and RECEIVE commands were restructured to
  8097. accept modifier switches (switches are explained in Section 1.5).
  8098.  
  8099. 4.7.1. SEND Command Switches
  8100.  
  8101. Without switches, the SEND command still works exactly as before:
  8102.  
  8103.   send oofa.txt      ; send a single file
  8104.   send oofa.*        ; send multiple files
  8105.   send oofa.txt x.x  ; send oofa.txt as x.x (tell receiver its name is x.x)
  8106.   send               ; send from SEND-LIST
  8107.  
  8108. But now the following modifier switches may be included between "send" and the
  8109. filename.  Zero, one, two, or more switches may be included in any combination
  8110. that makes sense.  Switch names (such as /BINARY) can be abbreviated, just
  8111. like any other keywords.  Most of these switches work only when using Kermit
  8112. protocol (/TEXT and /BINARY are the exceptions).
  8113.  
  8114.   /AFTER:date-time
  8115.     Specifies that only those files modified (or, in VMS, created) after
  8116.     the given date-time (see section 1.6) are to be sent.  Examples:
  8117.  
  8118.       send /text /after:{2-Feb-1997 10:28:30} *.txt
  8119.       send /text /after:\fdate(oofa.txt) *.txt
  8120.  
  8121.     Synonym: /SINCE.
  8122.  
  8123.   /ARRAY:arrayname
  8124.     Specifies that instead of sending a file, C-Kermit is to send the
  8125.     contents of the given array.  Since an array does not have a filename,
  8126.     you should include an /AS-NAME switch to specify the name under which
  8127.     the array is to be sent (if you do not, the name "_array_x_" is used,
  8128.     where 'x' is replaced by the array designator).  See section 7.10 for
  8129.     array-name syntax.  As noted in that section, you can also include a
  8130.     range to have a segment of the array sent, rather than the whole
  8131.     thing; for example: "send /array:&a[100:199]".  It is strongly
  8132.     recommended that you accompany the /ARRAY switch with a /TEXT or
  8133.     /BINARY switch to force the desired transfer mode, since otherwise the
  8134.     various automatic mechanisms might switch to binary mode when you
  8135.     really wanted text, or vice versa.  In text mode a line terminator is
  8136.     added to the end of each array element, but not in binary mode.  For
  8137.     details and examples see Section 7.10.11.
  8138.  
  8139.   /AS-NAME:text
  8140.     Specifies "text" as the name to send the file under.
  8141.     You can also still specify the as-name as the second filename on the
  8142.     SEND command line.  The following two commands are equivalent:
  8143.  
  8144.       send oofa.txt oofa.new
  8145.       send /as:oofa.new oofa.txt
  8146.  
  8147.   /BEFORE:date-time
  8148.     Specifies that only those files modified (or, in VMS, created)
  8149.     before the given date-time (section 1.6) are to be sent.
  8150.  
  8151.   /BINARY
  8152.     Performs this transfer in binary mode without affecting the global
  8153.     transfer mode, overriding not only the FILE TYPE and TRANSFER MODE
  8154.     settings, but also the FILE PATTERN setting, but for this SEND command
  8155.     only.  In other words, SEND /BINARY means what it says: send the file
  8156.     in binary mode, regardless of any other settings.  Example:
  8157.  
  8158.       set file type text      ; Set global transfer mode to text
  8159.       send /binary oofa.zip   ; Send a file in binary
  8160.       send oofa.txt           ; This one is sent in text mode
  8161.  
  8162.   /COMMAND
  8163.     SEND /COMMAND is equivalent to CSEND (section 4.2.2) -- it says to send
  8164.     the output from a command, rather than the contents of a file.
  8165.     The first "filename" on the SEND command line is interpreted as the name
  8166.     of a command; the second (if any) is the as-name.  Examples:
  8167.  
  8168.       send /command {grep Sunday oofa.txt} sunday.txt
  8169.       send /as-name:sunday.txt /command {grep Sunday oofa.txt}
  8170.       send /bin /command {tar cf - . | gzip -c} {!gunzip -c | tar xf -}
  8171.  
  8172.   /DELETE
  8173.     Deletes the file (or each file in the group) after it has been sent
  8174.     successfully (but does not delete it if it was not sent successfully).
  8175.     SEND /DELETE is equivalent to MOVE.  Has no effect when used with
  8176.     /COMMAND.  Example:
  8177.  
  8178.       send /delete *.log
  8179.  
  8180.   /DOTFILES
  8181.     (UNIX and OS-9 only)  Normally files whose names begin with "." are
  8182.     skipped when matching wildcards that do not also beging with ".".
  8183.     Include /DOTFILES to force these files to be included too.
  8184.  
  8185.   /RECURSIVE
  8186.     Descend the through the directory tree when locating files to send.
  8187.     Automatically sets /PATHNAMES:RELATIVE.  Explained in section 4.11.
  8188.  
  8189.   /EXCEPT:<pattern>
  8190.     See Section 1.5.4.
  8191.  
  8192.   /NOBACKUP
  8193.     This means to skip backup files when sending, even if they match the
  8194.     SEND file specification.  This is equivalent to using SEND /EXCEPT and
  8195.     including *.~[0-9]*~ in the exception list (or *.~*~ if Kermit was built
  8196.     without pattern-matching support; see Section 4.9.1).  Including this
  8197.     switch is equivalent to giving SET SEND BACKUP OFF (Section 4.0.6) prior
  8198.     to SEND, except its effect is local to the SEND command with which it was
  8199.     given.
  8200.  
  8201.   /NODOTFILES
  8202.     The opposite of /DOTFILES (q.v.)
  8203.  
  8204.   /FILENAMES:{CONVERTED,LITERAL}
  8205.     Use this switch to override the current global SET FILE NAMES setting
  8206.     for this transfer only.
  8207.  
  8208.   /FILTER:<command>
  8209.     This specifies a filter to pass the file through before sending it.
  8210.     See the section on file-transfer pipes and filters.  The /FILTER switch
  8211.     applies only to the file-transfer command it is given with; it does not
  8212.     affect the global SEND FILTER setting, if any.
  8213.  
  8214.   /IMAGE
  8215.     VMS: Sends in image mode.  Non-VMS: same as /BINARY.
  8216.  
  8217.   /LABELED
  8218.     VMS and OS/2 only: Sends in labeled mode.
  8219.  
  8220.   /LARGER-THAN:number
  8221.     Specifies that only those files that are longer than the given number
  8222.     of bytes are to be sent.
  8223.  
  8224.   /LISTFILE:filename
  8225.     Specifies that the files to be sent are listed in a file with the given
  8226.     filename.  The file contains one filename per line.  These filenames are
  8227.     not checked in any way; each filename is taken and does not use or
  8228.     depend on any Kermit-specific syntax.  In particular, backslashes are
  8229.     not treated specially, leading and trailing spaces are not stripped,
  8230.     etc.  However, if a filename contains wildcards, they are expanded.
  8231.     Example: If a file named files.txt contains the following lines:
  8232.  
  8233.       blah.txt
  8234.       oofa*
  8235.       x.x
  8236.  
  8237.     (but without leading or trailing spaces), then the C-Kermit command
  8238.     "send /listfile:files.txt" will send the files blah.txt, x.x, and all
  8239.     files whose names start with "oofa", assuming the files exist and are
  8240.     readable.  The /LISTFILE switch, can, of course, be used with other
  8241.     switches when it makes sense, for example, /EXCEPT, /BINARY, /AFTER,
  8242.     /SMALLER, /MOVE-TO, /DELETE, /AS-NAME with a template, etc.
  8243.  
  8244.   /MAIL:address
  8245.     Sends the file as e-mail to the given address or addresses.
  8246.     "send /mail:address filename" is equivalent to "mail filename address".
  8247.     You can include multiple addresses separated by commas.  Examples:
  8248.  
  8249.       send /mail:kermit-support@columbia.edu packet.log
  8250.       send /mail:cmg,fdc,jrd oofa.txt
  8251.  
  8252.     As with any switch argument, if the address or address list contains any
  8253.     spaces, you must enclose it in braces.  The format of the addresses must
  8254.     agree with that understood by the mail-sending program on the receiver's
  8255.     computer.
  8256.  
  8257.   /MOVE-TO:directory-name
  8258.     Specifies that after each (or the only) source file is sent successfully,
  8259.     and ONLY if it is sent successfully, it should be moved to the named
  8260.     directory.  If the directory name contains spaces, enclose it in braces.
  8261.     If the directory does not exist, it is created if possible; if it can't be
  8262.     created, the command fails and an error message is printed.  Example:
  8263.       send /text /move-to:/users/olga/backup/ *.txt
  8264.  
  8265.   /NOT-AFTER:date-time
  8266.     Specifies that only those files modified at or before the given date and
  8267.     time are to be sent.
  8268.  
  8269.   /NOT-BEFORE:date-time
  8270.     Specifies that only those files modified at or after the given date and
  8271.     time are to be sent.
  8272.  
  8273.   /PATHNAMES:{OFF,ABSOLUTE,RELATIVE}
  8274.     Use this switch to override the current global SET SEND PATHNAMES setting
  8275.     for this transfer only.  /PATHNAMES:ABSOLUTE or RELATIVE also sets
  8276.     /FILENAMES:LITERAL (also for this transfer only) since pathnames are not
  8277.     sent otherwise.
  8278.  
  8279.   /RENAME-TO:text
  8280.     Specifies that after the (or each) source file is sent successfully, and
  8281.     ONLY if it is sent successfully, it should be renamed to the name given.
  8282.     If the name contains spaces, enclose it in braces.  If a file group is
  8283.     being sent, then the "text" must contain a variable reference such as
  8284.     \v(filename) (see section 4.1).  Example:
  8285.       send /rename-to:ok_\v(filename) *.*
  8286.     This sends each file in the current directory and if it was sent
  8287.     successfully, changes its name to begin with "ok_".
  8288.  
  8289.   /SMALLER-THAN:number
  8290.     Specifies that only those files that are smaller than the given number
  8291.     of bytes are to be sent.
  8292.  
  8293.   /SUBJECT:text
  8294.     Subject for email.  Actually, this is just a synonym for /AS-NAME.  If the
  8295.     text includes spaces, you must enclose it in braces.  If you don't specify
  8296.     a subject (or as-name), the name of the file is used as the subject.
  8297.     Example:
  8298.       send /mail:kermit-support@columbia.edu /subj:{As requested} packet.log
  8299.  
  8300.   /PRINT:options
  8301.     Sends the file to be printed, optionally specifying options for the
  8302.     printer.  Equivalent to REMOTE PRINT filename options.  Examples:
  8303.  
  8304.       send /print oofa.txt              ; No options.
  8305.       send /print:/copies=3 oofa.txt    ; "/copies=3" is a VMS PRINT switch.
  8306.       send /print:-#3 oofa.txt          ; "-#3" is a UNIX lpr switch.
  8307.  
  8308.   /PROTOCOL:name
  8309.     Uses the given protocol to send the file (Kermit, Zmodem, etc) for this
  8310.     transfer without changing global protocol.  Only available in Kermit 95,
  8311.     UNIX, and OS-9.  Example:
  8312.  
  8313.       set protocol kermit               ; Set global protocol
  8314.       send /proto:zmodem /bin oofa.zip  ; Send just this file with Zmodem
  8315.       send oofa.txt                     ; This file is sent with Kermit
  8316.  
  8317.   /QUIET
  8318.     When sending in local mode, this suppresses the file-transfer display.
  8319.  
  8320.   /RECOVER
  8321.     Used to recover from a previously interrupted transfer; SEND /RECOVER is
  8322.     equivalent to RESEND.  Recovery only works in binary mode; SEND /RECOVER
  8323.     and RESEND include an implied /BINARY switch.  Even then, recovery will
  8324.     successful only if (a) the original (interrupted) transfer was also in
  8325.     binary mode, or (b) if it was in text mode, the two Kermit programs run on
  8326.     platforms where text-mode transfers are not length-changing.
  8327.  
  8328.   /STARTING:number
  8329.     Starts sending the file from the given byte position.
  8330.     SEND /STARTING:n filename is equivalent to PSEND filename n.
  8331.  
  8332.   /TEXT
  8333.     Performs this transfer in text mode without affecting the global
  8334.     transfer mode, overriding not only the FILE TYPE and TRANSFER MODE
  8335.     settings, but also the FILE PATTERN setting, for this SEND command
  8336.     only.  In other words, SEND /TEXT really send the file in text mode,
  8337.     regardless of any other settings or negotiations.
  8338.  
  8339. About mail...  Refer to section 4.7.1.  The same rules apply as for file
  8340. transfer.  If you are mailing multiple files, you can't use an as-name (in
  8341. this case, a subject) unless it contains replacement variables like
  8342. \v(filenum).  For example, if you:
  8343.  
  8344.   send /mail:somebody@xyz.com *.txt
  8345.  
  8346. Then each file will arrive as a separate email message with its name as the
  8347. subject.  But if you:
  8348.  
  8349.   send /mail:somebody@xyz.com /subject:{Here is a file} *.txt
  8350.  
  8351. Then each file message will have the same subject, which is probably not what
  8352. you want.  You can get around this with constructions like:
  8353.  
  8354.   send /mail:somebody@xyz.com /subject:{Here is \v(filename)} *.txt
  8355.  
  8356. which embed the filename in the subject.
  8357.  
  8358. The MOVE, CSEND, MAIL, and RESEND commands now also accept the same switches.
  8359. And the switches are also operative when sending from a SEND-LIST (see "Using
  8360. C-Kermit", 2nd Ed, pp.191-192), so, for example, it is now possible to SEND
  8361. /PRINT or SEND /MAIL from a SEND-LIST.
  8362.  
  8363. The MSEND and MMOVE commands also take switches, but not all of them.  With
  8364. these commands, which take an arbitrary list of filespecs, you can use
  8365. /BINARY, /DELETE, /MAIL, /PRINT, /PROTOCOL, /QUIET, /RECOVER, and /TEXT (and
  8366. /IMAGE or /LABELED, depending on the platform).  MMOVE is equivalent to MSEND
  8367. /DELETE.  (If you want to send a group of files, but in mixed transfer modes
  8368. with per-file as-names, use ADD SEND-LIST and then SEND.)
  8369.  
  8370. The MSEND/MMOVE switches come before the filenames, and apply to all of them:
  8371.  
  8372.   msend /print /text *.log oofa.txt /etc/motd
  8373.  
  8374. If you type any of these commands (SEND, CSEND, MSEND, etc) followed by a
  8375. question mark (?), you will see a list of the switches you can use.  If you
  8376. want to see a list of filenames, you'll need to type something like "send ./?"
  8377. (UNIX, OS/2, Windows, etc), or "send []?" (VMS), etc.  Of course, you can also
  8378. type pieces of a filename (anything that does not start with "/") and then "?"
  8379. to get a list of filenames that start that way; e.g. "send x.?"  still works
  8380. as before.
  8381.  
  8382. In UNIX, where "/" is also the directory separator, there is usually no
  8383. ambiguity between a fully-specified pathname and a switch, except when a file
  8384. in the root directory has the same name as a switch (as noted in section 1.5):
  8385.  
  8386.   send /etc/motd                        ; Works as expected
  8387.   send /command                         ; ???
  8388.  
  8389. The second example interprets "/command" as a switch, not a filename.  To
  8390. actually send a file called "command" in the root directory, use:
  8391.  
  8392.   send {/command}
  8393.  
  8394. or other system-dependent forms such as //command, /./command, c:/command,
  8395. etc, or cd to / and then "send command".
  8396.  
  8397. 4.7.2. GET Command Switches
  8398.  
  8399. Without switches, the GET command still works about the same as before:
  8400.  
  8401.   get oofa.txt                          ; GET a single file
  8402.   get oofa.*                            ; GET multiple files
  8403.  
  8404. However, the mechanism for including an "as-name" has changed.  Previously,
  8405. in order to include an as-name, you were required to use the "multiline" form
  8406. of GET:
  8407.  
  8408.   get
  8409.   <remote-filespec>
  8410.   <local-name>
  8411.  
  8412. This was because the remote filespec might contain spaces, and so there would
  8413. be no good way of telling where it ended and where the local name began, e.g:
  8414.  
  8415.   get profile exec a foo
  8416.  
  8417. But now since we can use {braces} for grouping, we don't need the multiline
  8418. GET form any more, and in fact, support for it has been removed.  If you give
  8419. a GET command by itself on a line, it fails and an error message is printed.
  8420. The new form is:
  8421.  
  8422.   GET [ switches... ] remote-name [ local-name ]
  8423.  
  8424. If the remote-name or local-name contains spaces, they must be enclosed in
  8425. braces:
  8426.  
  8427.   get {profile exec a} foo
  8428.   get oofa.txt {~/My Files/Oofa text}
  8429.  
  8430. If you want to give a list of remote file specifications, use the MGET
  8431. command:
  8432.  
  8433.   MGET [ switches... ] remote-name [ remote-name [ remote-name ... ] ]
  8434.  
  8435. Now you can also include modifier switches between "get" or "mget" and the
  8436. remote-name; most of the same switches as SEND:
  8437.  
  8438.   /AS-NAME:text
  8439.     Specifies "text" as the name to store the incoming file under.  (This
  8440.     switch is not available for MGET.)  You can also still specify the
  8441.     as-name as the second filename on the GET command line.  The following
  8442.     two commands are equivalent:
  8443.  
  8444.       get oofa.txt oofa.new
  8445.       get /as:oofa.new oofa.txt
  8446.  
  8447.   /BINARY
  8448.     Tells the server to send the given file(s) in binary mode without
  8449.     affecting the global transfer mode.  Example:
  8450.  
  8451.       set file type text      ; Set global transfer mode to text
  8452.       get /binary oofa.zip    ; get a file in binary mode
  8453.       get oofa.txt            ; This one is transferred in text mode
  8454.  
  8455.     Or, perhaps more to the point:
  8456.  
  8457.       get /binary foo.txt     ; where "*.txt" is a text-pattern
  8458.  
  8459.     This works only if the server is C-Kermit 7.0 or later or K95 1.1.18
  8460.     or later.
  8461.  
  8462.   /COMMAND
  8463.     GET /COMMAND is equivalent to CGET (section 4.2.2) -- it says to receive
  8464.     the file into the standard input of a command, rather than saving it on
  8465.     disk.  The /AS-NAME or the second "filename" on the GET command line is
  8466.     interpreted as the name of a command.  Examples:
  8467.  
  8468.       get /command sunday.txt {grep Sunday oofa.txt}
  8469.       get /command /as-name:{grep Sunday oofa.txt} sunday.txt
  8470.       get /bin /command {!gunzip -c | tar xf -} {tar cf - . | gzip -c}
  8471.  
  8472.   /DELETE
  8473.     Asks the Kermit server to delete the file (or each file in the group)
  8474.     after it has been transferred successfully (but not to delete it if it
  8475.     was not sent successfully).  GET /DELETE is equivalent to RETRIEVE.
  8476.     Example:
  8477.  
  8478.       get /delete *.log
  8479.  
  8480.   /EXCEPT:pattern
  8481.     Specifies that any files whose names match the pattern, which can be a
  8482.     regular filename, or may contain "*" and/or "?" metacharacters,
  8483.     are to be refused upon arrival.  To specify multiple patterns (up to 8),
  8484.     use outer braces around the group, and inner braces around each pattern:
  8485.  
  8486.       /EXCEPT:{{pattern1}{pattern2}...}
  8487.  
  8488.     See the description of SEND /EXCEPT in Section 4.7.1 for examples, etc.
  8489.     Refusal is accomplished using the Attribute Rejection mechanism (reason
  8490.     "name"), which works only when Attribute packets have been successfully
  8491.     negotiated.
  8492.  
  8493.   /FILENAMES:{CONVERTED,LITERAL}
  8494.     Use this switch to override the current global SET FILE NAMES setting
  8495.     for this transfer only.
  8496.  
  8497.   /FILTER:<command>
  8498.     This specifies a filter to pass the incoming file through before writing
  8499.     to disk.  See the section on file-transfer pipes and filters.  The /FILTER
  8500.     switch applies only to the file-transfer command it is given with; it does
  8501.     not affect the global RECEIVE FILTER setting, if any.
  8502.  
  8503.   /IMAGE
  8504.     VMS: Transfer in image mode.  Non-VMS: same as /BINARY.
  8505.  
  8506.   /LABELED
  8507.     VMS and OS/2 only: Specifies labeled transfer mode.
  8508.  
  8509.   /MOVE-TO:<directory>
  8510.     This tells C-Kermit to move each file that is successfully received to
  8511.     the given directory.  Files that are not successfully received are not
  8512.     moved.  By default, files are not moved.
  8513.  
  8514.   /PATHNAMES:{OFF,ABSOLUTE,RELATIVE,AUTO}
  8515.     Use this switch to override the current global SET RECEIVE PATHNAMES
  8516.     setting for this transfer only.  /PATHNAMES:ABSOLUTE or RELATIVE also sets
  8517.     /FILENAMES:LITERAL (also for this transfer only) since incoming pathnames
  8518.     would not be treated as pathnames otherwise.  See Section 4.10.
  8519.  
  8520.   /QUIET
  8521.     When sending in local mode, this suppresses the file-transfer display.
  8522.  
  8523.   /RECOVER
  8524.     Used to recover from a previously interrupted transfer; GET /RECOVER
  8525.     is equivalent to REGET.  Recovery only works in binary mode; SEND /RECOVER
  8526.     and RESEND include an implied /BINARY switch.  Even then, recovery will
  8527.     successful only if (a) the original (interrupted) transfer was also in
  8528.     binary mode, or (b) if it was in text mode, the two Kermit programs run
  8529.     on platforms where text-mode transfers are not length-changing.
  8530.  
  8531.   /RECURSIVE
  8532.     Tells the server that the GET file specification applies recursively.
  8533.     This switch also automatically sets /PATHNAMES:RELATIVE in both the server
  8534.     AND the client.  When used in conjunction with /DELETE, this "moves" a
  8535.     directory tree from the server's computer to the client's computer (except
  8536.     that only regular files are deleted from the server's computer, not
  8537.     directories; thus the original directories will be left, but will contain
  8538.     no files).  Note that all servers that support /RECURSIVE do not
  8539.     necessarily do so in combination with other switches, such as /RECOVER.
  8540.     (Servers that do include C-Kermit 7.0 and later, K95 1.1.18 and later.)
  8541.  
  8542.   /RENAME-TO:<string>
  8543.     This tells C-Kermit to rename each file that is successfully received to
  8544.     the given string.  Files that are not successfully received are not
  8545.     renamed.  By default, files are not renamed.  The <string> can be a
  8546.     literal string, which is appropriate when only one file is being received,
  8547.     or it can contain one or more variables that are to be evaluated at the
  8548.     time each file is received, such as \v(filename), \v(filenumber),
  8549.     \v(ntime), \v(pid), \v(user), etc.  WARNING: if you give a literal string
  8550.     and more than one file arrives, each incoming file will be given the same
  8551.     name (but SET FILE COLLISION BACKUP or RENAME can be used to keep the
  8552.     incoming files from overwriting each other).
  8553.  
  8554.   /TEXT
  8555.     Tells the server to perform this transfer in text mode without affecting
  8556.     its global transfer mode.  See /BINARY for additional info.
  8557.  
  8558. The /MAIL and /PRINT options are not available, but you can use /COMMAND
  8559. to achieve the same effect, as in these UNIX examples:
  8560.  
  8561.   get /command oofa.txt {mail kermit@columbia.edu}
  8562.   get /command oofa.txt lpr
  8563.  
  8564. In OS/2 or Windows, you can GET and print like this:
  8565.  
  8566.   get oofa.txt prn
  8567.  
  8568. The CGET, REGET, RETRIEVE commands also accept the same switches as GET.  CGET
  8569. automatically sets /COMMAND; REGET automatically sets /RECOVER and /BINARY,
  8570. and RETRIEVE automatically sets /DELETE.
  8571.  
  8572. 4.7.3. RECEIVE Command Switches
  8573.  
  8574. Without switches, the RECEIVE command still works as before:
  8575.  
  8576.   receive            ; Receives files under their own names
  8577.   receive /tmp       ; Ditto, but into the /tmp directory
  8578.   r                  ; Same as "receive"
  8579.   receive foo.txt    ; Receives a file and renames to foo.txt
  8580.  
  8581. Now you can also include modifier switches may be included between "receive"
  8582. and the as-name; most of the same switches as GET:
  8583.  
  8584.   /AS-NAME:text
  8585.     Specifies "text" as the name to store the incoming file under.
  8586.     You can also still specify the as-name as a filename on the
  8587.     command line.  The following two commands are equivalent:
  8588.       r oofa.new
  8589.       r /as:oofa.new
  8590.  
  8591.   /BINARY
  8592.     Performs this transfer in binary mode without affecting the global
  8593.     transfer mode.  NOTE: This does not override the incoming filetype (as
  8594.     it does with GET), so this switch is useful only if ATTRIBUTE TYPE is
  8595.     OFF, or if the other Kermit does not send a TYPE (text or binary)
  8596.     attribute.  In any case, it has no affect whatsoever on the file sender.
  8597.  
  8598.   /COMMAND
  8599.     RECEIVE /COMMAND is equivalent to CRECEIVE (section 4.2.2) -- it says to
  8600.     receive the file into the standard input of a command, rather than saving
  8601.     it on disk.  The /AS-NAME or the "filename" on the RECEIVE command line
  8602.     is interpreted as the name of a command.
  8603.  
  8604.       r /command {grep Sunday oofa.txt}
  8605.       r /command /as-name:{grep Sunday oofa.txt}
  8606.       r /bin /command {tar cf - . | gzip -c}
  8607.  
  8608.   /EXCEPT:pattern
  8609.     Specifies that any files whose names match the pattern, which can be a
  8610.     regular filename, or may contain "*" and/or "?" metacharacters,
  8611.     are to be refused upon arrival.  To specify multiple patterns (up to 8),
  8612.     use outer braces around the group, and inner braces around each pattern:
  8613.  
  8614.       /EXCEPT:{{pattern1}{pattern2}...}
  8615.  
  8616.     See the description of SEND /EXCEPT in Section 4.7.1 for examples, etc.
  8617.     Refusal is accomplished using the Attribute Rejection mechanism (reason
  8618.     "name"), which works only when Attribute packets have been successfully
  8619.     negotiated.
  8620.  
  8621.   /FILENAMES:{CONVERTED,LITERAL}
  8622.     Use this switch to override the current global SET FILE NAMES setting
  8623.     for this transfer only.
  8624.  
  8625.   /FILENAMES:{CONVERTED,LITERAL}
  8626.     Use this switch to override the current global SET FILE NAMES setting
  8627.     for this transfer only.
  8628.  
  8629.   /FILTER:<command>
  8630.     This specifies a filter to pass the incoming file through before writing
  8631.     to disk.  See the section on file-transfer pipes and filters.  The /FILTER
  8632.     switch applies only to the file-transfer command it is given with; it does
  8633.     not affect the global RECEIVE FILTER setting, if any.
  8634.  
  8635.   /IMAGE
  8636.     VMS: Transfer in image mode.  Non-VMS: same as /BINARY.
  8637.     See comments under RECEIVE /BINARY.
  8638.  
  8639.   /LABELED
  8640.     VMS and OS/2 only: Specifies labeled transfer mode.
  8641.     See comments under RECEIVE /BINARY.
  8642.  
  8643.   /MOVE-TO:<directory>
  8644.     This tells C-Kermit to move each file that is successfully received to
  8645.     the given directory.  Files that are not successfully received are not
  8646.     moved.  By default, files are not moved.
  8647.  
  8648.   /PATHNAMES:{ABSOLUTE,RELATIVE,OFF,AUTO}
  8649.     Use this switch to override the current global SET RECEIVE PATHNAMES
  8650.     setting for this transfer only.  See Section 4.10.
  8651.  
  8652.   /RECURSIVE
  8653.     When used with the RECEIVE command, /RECURSIVE is simply a synonym
  8654.     for /PATHNAMES:RELATIVE.
  8655.  
  8656.   /RENAME-TO:<string>
  8657.     This tells C-Kermit to rename each file that is successfully received to
  8658.     the given string.  Files that are not successfully received are not
  8659.     renamed.  By default, files are not renamed.  The <string> can be a
  8660.     literal string, which is appropriate when only one file is being received,
  8661.     or it can contain one or more variables that are to be evaluated at the
  8662.     time each file is received, such as \v(filename), \v(filenumber),
  8663.     \v(ntime), \v(pid), \v(user), etc.  WARNING: if you give a literal string
  8664.     and more than one file arrives, each incoming file will be given the same
  8665.     name (but SET FILE COLLISION BACKUP or RENAME can be used to keep the
  8666.     incoming files from overwriting each other).
  8667.  
  8668.   /QUIET
  8669.     When receiving in local mode, this suppresses the file-transfer display.
  8670.  
  8671.   /TEXT
  8672.     Receives in text mode without affecting the global transfer mode.  See
  8673.     comments under RECEIVE /BINARY.
  8674.  
  8675. The /MAIL and /PRINT options are not available, but you can use /COMMAND
  8676. to achieve the same effect, as in these UNIX examples:
  8677.  
  8678.   r /command {mail kermit@columbia.edu}
  8679.   r /command lpr
  8680.  
  8681. In OS/2 or Windows, you can RECEIVE and print like this:
  8682.  
  8683.   receive prn
  8684.  
  8685. The CRECEIVE command now also accepts the same switches.
  8686.  
  8687. 4.8. Kermit Protocol Improvements
  8688.  
  8689. 4.8.1. Multiple Attribute Packets
  8690.  
  8691. C-Kermit 7.0 now sends more than one Attribute packet if a file's attributes
  8692. do not fit into a single packet of the negotiated length.  If a particular
  8693. attribute (such as file creation date-time) does not fit within the negotiated
  8694. length (which will only happen when the negotiated length is around 20 or
  8695. less), that attribute is not sent at all.
  8696.  
  8697. 4.8.2. Very Short Packets
  8698.  
  8699. There are certain situations where extremely short packets must be used;
  8700. 20 or 30 bytes at most.  This can happen when one or more devices along the
  8701. communication path have very small buffers and lack an effective means of
  8702. flow control.  Examples are sometimes cited involving radio modems.
  8703.  
  8704. When the maximum packet length is shorter than certain packets that would be
  8705. sent, those packets are either truncated or else broken up into multiple
  8706. packets.  Specifically:
  8707.  
  8708.  1. Parameter negotiation packets (I, S, and their ACKs) are truncated to
  8709.     the negotiated length.  Any parameters that do not fit are reset to
  8710.     their default values.  There is no provision in the Kermit protocol for
  8711.     fragmentation and reassembly of parameter strings.
  8712.  
  8713.  2. File header packets (containing the filename) are simply truncated.
  8714.     There is no provision in the Kermit protocol for fragmentation and
  8715.     reassembly of filenames.
  8716.  
  8717.  3. Attribute packets are fragmented and reassembled as described in 4.8.1
  8718.     without loss of data, except in case a field will not fit at all in
  8719.     the negotiated length (the longest attribute is usually the date and
  8720.     time of file creation/modification) because of the rule that attributes
  8721.     may not be broken across packets.
  8722.  
  8723.  4. Data packets and other packets are unaffected -- they can be as short
  8724.     as they need to be, within reason.
  8725.  
  8726. 4.9. Wildcard / File Group Expansion
  8727.  
  8728. "Wildcard" refers to the notation used in filenames to specify a group of
  8729. files by pattern matching.
  8730.  
  8731. 4.9.1. In UNIX C-Kermit
  8732.  
  8733. Prior to C-Kermit 7.0, C-Kermit was capable of expanding wildcard strings
  8734. containing only the "metacharacters" '*' and '?':
  8735.  
  8736. * Matches any sequence of zero or more characters.  For example: "ck*.c"
  8737.   matches all files whose names start with "ck" and end with ".c", including
  8738.   "ck.c".
  8739.  
  8740. ? Matches any single character.  For example, "ck?.c" matches all files whose
  8741.   names are exactly 5 characters long and start with "ck" and end with ".c".
  8742.   When typing commands at the prompt, you must precede any question mark to
  8743.   be used for matching by a backslash (\) to override the normal function of
  8744.   question mark, which is providing menus and file lists.
  8745.  
  8746. C-Kermit 7.0 adds the additional features that users of ksh, csh, and bash
  8747. are accustomed to:
  8748.  
  8749. [abc]
  8750.   Square brackets enclosing a list of characters matches any single
  8751.   character in the list.  Example: ckuusr.[ch] matches ckuusr.c and ckuusr.h.
  8752.  
  8753. [a-z]
  8754.   Square brackets enclosing a range of characters; the hyphen separates the
  8755.   low and high elements of the range.  For example, [a-z] matches any
  8756.   character from a to z.
  8757.  
  8758. [acdm-z]
  8759.   Lists and ranges may be combined.  This example matches a, c, d, or m
  8760.   through z.
  8761.  
  8762. {string1,string2,...}
  8763.   Braces enclose a list of strings to be matched.  For example:
  8764.   ck{ufio,vcon,cmai}.c matches ckufio.c, ckvcon.c, or ckcmai.c.  The strings
  8765.   may themselves contain metacharacters, bracket lists, or indeed, other
  8766.   lists of strings, but (when matching filenames) they may not contain
  8767.   directory separators.
  8768.  
  8769. Thus, the metacharacters in filenames (and in any other field that can be a
  8770. pattern, such as the IF MATCH pattern, SEND or GET exception lists, etc) are:
  8771.  
  8772.  * ? [ {
  8773.  
  8774. And within braces only, comma (,) is a metacharacter.
  8775.  
  8776. To include a metacharacter in a pattern literally, precede it with a backslash
  8777. '\' (or two if you are passing the pattern to a macro).  Examples:
  8778.  
  8779.   send a*b      ; Send all files whose names start with 'a' and end with 'b'.
  8780.   send a?b      ; Ditto, but the name must be exactly three characters long.
  8781.   send a[a-z]b  ; Ditto, but the second character must be a lowercase letter.
  8782.   send a[x\-z]b ; Ditto, except the second character must be 'x', '-', or 'y'.
  8783.   send a[ghi]b  ; Ditto, except the second character must be 'g', 'h', or 'i'.
  8784.   send a[?*]b   ; Ditto, except the second character must be '?' or '*'.
  8785.   send a[\?\*]b ; Same as previous.
  8786.   send *?[a-z]* ; All files with names containing at least one character
  8787.                 ; that is followed by a lowercase letter.
  8788.  
  8789. Or, more practically:
  8790.  
  8791.   send ck[cuw]*.[cwh]  ; Send the UNIX C-Kermit source files.
  8792.  
  8793. To refer to the C-Kermit sources files and makefile all in one filespec:
  8794.  
  8795.   {{makefile,ck[cuw]*.[cwh]}}
  8796.  
  8797. (NOTE: if the entire pattern is a {stringlist}, you must enclose it it TWO
  8798. pairs of braces, since the SEND command strips the outer brace pair, because
  8799. of the "enclose in braces if the filename contains spaces" rule).
  8800.  
  8801. If the makefile is called ckuker.mak:
  8802.  
  8803.   ck[cuw]*.{[cwh],mak}
  8804.  
  8805. (NOTE: double braces are not needed here since the pattern does not both
  8806. begin and end with a brace.)
  8807.  
  8808. To add in all the C-Kermit text files:
  8809.  
  8810.   ck[cuw]*.{[cwh],mak,txt}
  8811.  
  8812. All of these features can be used anywhere you would type a filename that
  8813. is allowed to contain wildcards.
  8814.  
  8815. When you are typing at the command prompt, an extra level of quoting is
  8816. required for the '?' character to defeat its regular function of producing a
  8817. list of files that match what you have typed so far, for example:
  8818.  
  8819.   send ck[cu]?
  8820.  
  8821. lists all the files whose names start with ckc and cku.  If you quote the
  8822. question mark, it is used as a pattern-matching character, for example:
  8823.  
  8824.   send ck\?[ft]io.c
  8825.  
  8826. sends all the file and communications i/o modules for all the platforms:
  8827. ckufio.c, ckutio.c, ckvfio.c, ckvtio.c, etc.
  8828.  
  8829. If, however, a filename actually contains a question mark and you need to
  8830. refer to it on the command line, you must use three (3) backslashes.  For
  8831. example, if the file is actually called ck?fio.c, you would use:
  8832.  
  8833.   send ck\\\?fio.c
  8834.  
  8835. Further notes on quoting:
  8836.  
  8837.  . A single backslash is sufficient for quoting a special character at the
  8838.    command prompt or in a command file.  However, when passing patterns to
  8839.    macros you'll need double backslashes, and when referring to these
  8840.    patterns within the macro, you'll need to use \fcontents(\%1) (see
  8841.    Section 1.11.5).  You should enclose macro argument references in
  8842.    braces in case grouped arguments were passed.  Example:
  8843.  
  8844.      define ismatch {
  8845.          xif match {\fcont(\%1)} {\fcont(\%2)} {
  8846.              end 0 MATCH
  8847.          } else {
  8848.              end 1 NO MATCH
  8849.          }
  8850.      }
  8851.      ismatch ab*yz a*\\**z           ; Backslash must be doubled
  8852.      ismatch {abc def xyz} *b*e*y*   ; Braces must be used for grouping
  8853.  
  8854.  . Watch out for possible conflicts between {} in filename patterns and
  8855.    {} used for grouping multiple words into a single field, when the pattern
  8856.    has outer braces.  For example, in:
  8857.  
  8858.      if match {abc xyz} {a* *z} echo THEY MATCH
  8859.  
  8860.    braces must be used to group "abc xyz" into a single string.  Kermit strips
  8861.    off the braces before comparing the string with the pattern.  Therefore:
  8862.  
  8863.      if match makefile {makefile,Makefile} echo THEY MATCH
  8864.  
  8865.    does not work, but:
  8866.  
  8867.      if match makefile {{makefile,Makefile}} echo THEY MATCH
  8868.  
  8869.    does.
  8870.  
  8871.  . If you use a pattern that has outer braces, like {*.txt,*.doc},
  8872.    in a field that accepts a pattern list (like SEND /EXCEPT:xxx), you'll
  8873.    need to add two extra sets of outer braces:
  8874.  
  8875.      send /except:{{{*.txt,*.doc}}} *.*
  8876.  
  8877. C-Kermit's new pattern matching capabilities are also used when C-Kermit is
  8878. in server mode, so now you can send requests such as:
  8879.  
  8880.   get ck[cuw]*.[cwh]
  8881.  
  8882. to a C-Kermit server without having to tell it to SET WILD SHELL first.
  8883. Previously this would have required:
  8884.  
  8885.   mget ckc*.c ckc*.w ckc*.h cku*.c cku*.w cku*.h ckw*.c ckw*.w ckw*.h
  8886.  
  8887. The new pattern matching features make SET WILD SHELL redundant, and barring
  8888. any objections, it will eventually be phased out.  (One possible reason for
  8889. retaining it would be as an escape mechanism when Kermit does not understand
  8890. the underlying file system.)
  8891.  
  8892. By the way, patterns such as these are sometimes referred to as "regular
  8893. expressions", but they are not quite the same.  In a true regular expression
  8894. (for example), "*" means "zero or more repetitions of the previous item", so
  8895. (for example), "([0-9]*)" would match zero or more digits in parentheses.  In
  8896. Kermit (and in most shells), this matches one digit followed by zero or more
  8897. characters, within parentheses.  Here are some hints:
  8898.  
  8899.  . Although you can't match any sequence of digits (or letters, etc), you
  8900.    can match (say) 1, 2, or 3 of them in row.  For example, the following
  8901.    pattern matches Kermit backup files (with backup numbers from 1 to 999):
  8902.  
  8903.      *.~{[1-9],[1-9][0-9],[1-9][0-9][0-9]}~
  8904.  
  8905.  . There is presently no NOT operator, so no way to match any character or
  8906.    string EXCEPT the one(s) shown.
  8907.  
  8908. In other wildcarding news...
  8909.  
  8910.  . You may now "send xxx" where "xxx" is a directory name, and this will send
  8911.    all the files from the directory xxx, as if you had typed "send xxx/*".
  8912.    You can also use the special shorthand "send ." to send all the files from
  8913.    the current directory.
  8914.  
  8915.  . To easily skip over backup files (the ones whose names end like .~22~)
  8916.    when sending, you can use SEND /NOBACKUP (see Section 4.0.6 for details).
  8917.  
  8918.  . When choosing Kermit to expand wildcards, rather than the shell, you can
  8919.    choose whether "dot files" -- files whose names begin with ".", which are
  8920.    normally "invisible" -- should be matched:
  8921.  
  8922.      SET WILD KERMIT /NO-MATCH-DOT-FILES (this is the default)
  8923.      SET WILD KERMIT /MATCH-DOT-FILES    (this allows matching of "." files)
  8924.  
  8925.    or include the /DOTFILES or /NODOTFILES switch on the command you are
  8926.    using, such as SEND or DIRECTORY.
  8927.  
  8928.  . Commands such as DIRECTORY and SEND allow recursive directory traversal.
  8929.    There are also new functions for this to use in scripts.  See Section
  8930.    4.11 for details.
  8931.  
  8932. When building file lists in UNIX, C-Kermit follows symbolic links.  Because of
  8933. this, you might encounter any or all of the following phenomena:
  8934.  
  8935.  . Multiple copies of the same file; e.g. one from its real directory and
  8936.    others from links to its real directory, if both the real directory and
  8937.    the links to it are in the wildcard expansion list.
  8938.  
  8939.  . A command might unexpectedly "hang" for a long time because an NFS link
  8940.    might not be responding, or the directory you are looking at contains
  8941.    a link to a huge directory tree (example: "directory /recursive /etc"
  8942.    when /etc/spool is a symlink to /var/spool, which is a large organization's
  8943.    incoming email directory, containing tens of thousands of subdirectories).
  8944.  
  8945. The size of the file list that Kermit can build is limited in most C-Kermit
  8946. implementations.  The limit, if any, depends on the implementation.  Use the
  8947. SHOW FEATURES command and look in the alphabetized options list for MAXWLD to
  8948. see the value.
  8949.  
  8950. 4.9.2. In Kermit 95
  8951.  
  8952. Kermit 95 1.1.18 and later uses the same pattern matching syntax as in UNIX,
  8953. but (as always) you will encounter numerous difficulties if you use backslash
  8954. (\) as the directory separator.  In any command where K95 parses filenames
  8955. itself (that is, practically any file-oriented command except RUN), you can
  8956. use forward slash (/) as the directory separator to avoid all the nasty
  8957. conflicts.
  8958.  
  8959. 4.9.3. In VMS, AOS/VS, OS-9, VOS, etc.
  8960.  
  8961. Platforms other than UNIX, Windows 95/98/NT, and OS/2 have their own
  8962. filename matching capabilities that are, in general, different from Kermit's
  8963. built-in ones and in any case might conflict with them.  For example, []
  8964. encloses directory names in VMS.
  8965.  
  8966. Nevertheless you can still use all the pattern-matching capabilities described
  8967. in Section 4.9.1 by loading a file list into an array (e.g. with
  8968. \ffiles(*,&a), see Section 4.11.3) and then using IF MATCH on the members.
  8969.  
  8970. 4.10. Additional Pathname Controls
  8971.  
  8972. In version 6.0 and earlier, C-Kermit's SET { SEND, RECEIVE } PATHNAMES command
  8973. had only ON and OFF as options.  In version 7.0, there are more choices:
  8974.  
  8975. SET SEND PATHNAMES OFF
  8976.   When sending a file, strip all disk/directory information from the name.
  8977.   Example: "send /usr/olga/letters/oofa.txt" sends the file as "oofa.txt".
  8978.   This applies to actual filenames, not to any as-name you might specify.
  8979.  
  8980. SET SEND PATHNAMES RELATIVE
  8981.   When sending a file, leave the pathname on as given.  For example, if your
  8982.   current directory is /usr/olga, "send letters/oofa.txt" sends the file as
  8983.   "letters/oofa.txt", not "/usr/olga/letters/oofa.txt" or "letters.txt".
  8984.  
  8985. SET SEND PATHNAMES ABSOLUTE
  8986.   When sending a file, convert its name to the full, absolute local pathname.
  8987.   For example, if your current directory is /usr/olga, "send letters/oofa.txt"
  8988.   sends the file as "/usr/olga/letters/oofa.txt".  NOTE: Even with this
  8989.   setting, device and/or node names are not included.  For example, in VMS,
  8990.   any node or device name is stripped; in Windows or OS/2, any disk letter
  8991.   is stripped.
  8992.  
  8993. SET RECEIVE PATHNAMES OFF
  8994.   When receiving a file, strip all disk/directory information from the name
  8995.   before attempting to store it.  This applies to incoming filename, not to
  8996.   any as-name you might specify.  Example: If a file arrives under the name
  8997.   "/usr/olga/letters/oofa.txt" it is stored simply as "oofa.txt" in your
  8998.   download directory or, if no download directory has been specified, in your
  8999.   current directory.
  9000.  
  9001. SET RECEIVE PATHNAMES RELATIVE
  9002.   When receiving a file, leave the pathname on as it appears in the incoming
  9003.   name, but if the incoming name appears to be absolute, make it relative to
  9004.   your current or download directory.  Examples:
  9005.  
  9006.     "oofa.txt" is stored as "oofa.txt".
  9007.  
  9008.     "letters/oofa.txt" is stored as "letters/oofa.txt"; the "letters"
  9009.     subdirectory is created if it does not already exist.
  9010.  
  9011.     "/usr/olga/letters/oofa.txt" is stored as "usr/olga/letters/oofa.txt"
  9012.     in your current or download directory, and the "usr", "usr/olga", etc,
  9013.     directories are created if they do not exist.
  9014.  
  9015. SET RECEIVE PATHNAMES ABSOLUTE
  9016.   The incoming filename is used as given.  Thus it cannot be stored unless the
  9017.   given path (if any) already exists or can be created.  In this case, node,
  9018.   device, or disk designations are NOT stripped, since they most likely
  9019.   were given explicitly by the user as an as-name, meant to be used as given.
  9020.  
  9021. SET RECEIVE PATHNAMES AUTO
  9022.   This is the default, and means RELATIVE if the sender tells me it is a
  9023.   recursive transfer, OFF otherwise.
  9024.  
  9025. Set FILE NAMES CONVERTED now also affects pathnames too.  When PATHNAMES are
  9026. RELATIVE or ABSOLUTE and FILE NAMES are CONVERTED, the file sender converts
  9027. its native directory-name format to UNIX format, and the file receiver
  9028. converts from UNIX format to its native one; thus UNIX format is the common
  9029. intermediate representation for directory hierarchies, as it is in the
  9030. ZIP/UNZIP programs (which is why ZIP archives are transportable among, UNIX,
  9031. DOS, and VMS).
  9032.  
  9033. Here's an example in which a file is sent from Windows to UNIX with relative
  9034. pathnames and FILE NAMES CONVERTED:
  9035.  
  9036.   Source name                Intermediate name      Destination Name
  9037.   C:\K95\TMP\OOFA.TXT        K95/TMP/OOFA.TXT       k95/tmp/oofa.txt
  9038.  
  9039. In a more complicated example, we send the same file from Windows to VMS:
  9040.  
  9041.   Source name                Intermediate name      Destination Name
  9042.   C:\K95\TMP\OOFA.TXT        K95/TMP/OOFA.TXT       [.K95.TMP]OOFA.TXT
  9043.  
  9044. (Note that disk letters and device designations are always stripped when
  9045. pathnames are relative).
  9046.  
  9047. As you can imagine, as more and more directory formats are considered, this
  9048. approach keeps matters simple: on each platform, Kermit must know only its
  9049. own local format and the common intermediate one.  In most cases, the receiver
  9050. can detect which format is used automatically.
  9051.  
  9052. 4.11. Recursive SEND and GET: Transferring Directory Trees
  9053.  
  9054. C-Kermit 7.0 in selected versions (UNIX, VMS, VOS, AOS/VS, Windows, and OS/2
  9055. at this writing) now permits the SEND command to traverse directories
  9056. "recursively" if you ask it to; that is, to send files from the current or
  9057. specified directory and all of its subdirectories too, and their
  9058. subdirectories, etc.  (Some other commands can do this too, including
  9059. DIRECTORY.)
  9060.  
  9061. This feature is new to UNIX, Windows, VOS, and OS/2.  VMS and AOS/VS have
  9062. always included "wildcard" or "template" characters that allow this, and in
  9063. this case, recursive directory traversal could happen behind Kermit's back,
  9064. i.e. Kermit does not have to do it itself (in VMS, the notation is "[...]"  or
  9065. "[directory...]"; in AOS/VS is "#").  In C-Kermit 7.0, however, SEND
  9066. /RECURSIVE is supported by C-Kermit itself for VMS.
  9067.  
  9068. 4.11.1. Command-Line Options
  9069.  
  9070. To descend a directory tree when sending files, use the -L command-line option
  9071. to indicate that the send operation is to be recursive, and include a name or
  9072. pattern to be sent.  When giving a pattern, you should enclose it in quotes to
  9073. prevent the shell from expanding it.  Examples:
  9074.  
  9075.   $ kermit -Ls "/usr/olga/*" # send all of Olga's files in all her directories
  9076.   $ kermit -Ls foo.txt       # send all foo.txt files in this directory tree
  9077.   $ kermit -Ls "*.txt"       # send all .txt files in this directory tree
  9078.   $ kermit -Ls "letters/*"   # send all files in the letters directory tree
  9079.   $ kermit -Ls letters       # send all files in the letters directory tree
  9080.   $ kermit -Ls "*"           # send all files in this directory tree
  9081.   $ kermit -Ls .             # UNIX only: send all files in this directory tree
  9082.   $ kermit -s .              # UNIX only: a filename of . implies -L
  9083.  
  9084. If you let the shell expand wildcards, Kermit only sends files whose names
  9085. match files in the current or given directory, because the shell replaces an
  9086. unquoted wildcard expression with the list of matching files -- and the shell
  9087. does not build recursive lists.  Note that the "." notation for the tree
  9088. rooted at the current directory is allowed only in UNIX, since in Windows and
  9089. OS/2, it means "*.*" (nonrecursive).
  9090.  
  9091. 4.11.2. The SEND /RECURSIVE Command
  9092.  
  9093. If you include the /RECURSIVE switch in a SEND (or MOVE, or similar) command,
  9094. it means to descend the current or specified directory tree searching for
  9095. files whose names match the given name or pattern.  Since this is not terribly
  9096. useful unless you also include pathnames with the outbound files, the
  9097. /RECURSIVE switch also includes an implicit /PATHNAMES:RELATIVE switch (which
  9098. you can undo by including an explicit /PATHNAMES switch after the /RECURSIVE
  9099. switch).
  9100.  
  9101. Examples:
  9102.  
  9103. SEND /RECURSIVE *
  9104.   Sends all of the files in the current directory and all the files in
  9105.   all of its subdirectories, and all of their subdirectories, etc, including
  9106.   their relative pathnames.  Empty directories are not sent.
  9107.  
  9108. SEND /RECURSIVE /PATHNAMES:ABSOLUTE *
  9109.   Sends all of the files in the current directory and all the files in
  9110.   all of its subdirectories, and all of their subdirectories, etc, including
  9111.   their absolute pathnames.
  9112.  
  9113. SEND /RECURSIVE /PATHNAMES:OFF *
  9114.   Sends all of the files in the current directory and all the files in
  9115.   all of its subdirectories, and all of their subdirectories, etc, without
  9116.   pathnames.
  9117.  
  9118. SEND /RECURSIVE /usr/olga/*
  9119.   Sends all of the files in the /usr/olga directory and all the files in
  9120.   all of its subdirectories, and all of their subdirectories, etc.
  9121.  
  9122. SEND /RECURSIVE /usr/olga  (or /usr/olga/)
  9123.   Same as above.  If the name is a directory name (with or without a
  9124.   trailing slash), its files are sent, and those of its subdirectories,
  9125.   and their subdirectories, etc (see section 4.9).
  9126.  
  9127. SEND /RECURSIVE /TEXT /usr/olga/*.txt
  9128.   As above, but only files whose names end with ".txt" are sent, and they
  9129.   are sent in text mode (as they would be by default anyway if SET FILE
  9130.   PATTERNS is ON or AUTO).
  9131.  
  9132. SEND .
  9133.   UNIX only: Send all the files in the current directory.
  9134.  
  9135. SEND /RECURSIVE .
  9136.   UNIX only: Sends all of the files in the current directory and all of its
  9137.   subdirectories, etc (section 4.9).
  9138.  
  9139. The /RECURSIVE switch is different from most other switches in that its effect
  9140. is immediate (but still local to the command in which it is given), because it
  9141. determines how filenames are to be parsed.  For example, "send *.txt" fails
  9142. with a parse error ("No files match") if there are no *.txt files in the
  9143. current directory, but "send /recursive *.txt" succeeds if there are ".txt"
  9144. files anywhere in the tree rooted at the current directory.
  9145.  
  9146. The /RECURSIVE switch also affects the file lists displayed if you type "?"
  9147. in a filename field.  "send ./?" lists the regular files in the current
  9148. directory, but "send /recursive ./?" lists the entire directory tree rooted
  9149. at the current directory.
  9150.  
  9151. 4.11.3. The GET /RECURSIVE Command
  9152.  
  9153. In a client/server setting, the client can also request a recursive
  9154. transfer with:
  9155.  
  9156.   GET /RECURSIVE [ other switches ] <remote-filespec> [ <local-spec> ]
  9157.  
  9158. In which remote file specification can be a directory name, a filename, a
  9159. wildcard, or any combination.  If the <local-spec> is not given (and PATHNAMES
  9160. are RELATIVE), incoming files and directories go into the current local
  9161. directory.  If <local-spec> is given and is a directory, it becomes the root
  9162. of the tree into which the incoming files and directories are placed.  If
  9163. <local-spec> has the syntax of a directory name (e.g. in UNIX it ends with /),
  9164. C-Kermit creates the directory and then places the incoming files into it.
  9165. If <local-spec> is a filename (not recommended), then all incoming files are
  9166. stored with that name with collisions handled according to the FILE COLLISION
  9167. setting.
  9168.  
  9169. Again, the normal method for transferring directory trees uses relative
  9170. pathnames, and this is the default when the sender has been given the
  9171. /RECURSIVE switch.  The action at the receiver depends on its RECEIVE
  9172. PATHNAMES setting.  The default is AUTO, meaning that if the sender tells
  9173. it to expect a recursive transfer, then it should automatically switch to
  9174. relative pathnames for this transfer only; otherwise it obeys the RECEIVE
  9175. PATHNAMES setting of OFF, ABSOLUTE, or RELATIVE.
  9176.  
  9177. What happens if a file arrives that has an absolute pathname, when the
  9178. receiver has been told to use only relative pathnames?  As a security
  9179. precaution, in this case the receiver treats the name as if it was relative.
  9180. For example, if a file arrives as:
  9181.  
  9182.   /usr/olga/oofa.txt
  9183.  
  9184. The receiver creates a "usr" subdirectory in its current directory, and
  9185. then an "olga" subdirectory under the "usr" subdirectory in which to store
  9186. the incoming file.
  9187.  
  9188. Suppose, however there is a sequence of directories:
  9189.  
  9190.   /usr/olga/a/b/c/d/
  9191.  
  9192. in which "a" contains nothing but a subdirectory "b", which in turn contains
  9193. nothing but a subdirectory "c", which in turn contains nothing but a
  9194. subdirectory "d", which contains nothing at all.  Thus there are no files in
  9195. the "/usr/olga/a/" tree, and so it is not sent, and therefore it is not
  9196. reproduced on the target computer.
  9197.  
  9198. 4.11.4. New and Changed Functions
  9199.  
  9200. C-Kermit 7.0 adds the following functions:
  9201.  
  9202. \ffiles(pattern[,&a])
  9203.   This function has been changed to match only regular files in the current
  9204.   or given directory, and to take an optional array name as a second argument
  9205.   (explained below).
  9206.  
  9207. \fdirectories(pattern[,&a])
  9208.   Returns the number of directories that match the given pattern.
  9209.   If the pattern does not include a directory, then the search is performed
  9210.   in the current directory.
  9211.  
  9212. \frfiles(pattern[,&a])
  9213.   Returns the number of files in the current or given directory and all of
  9214.   its subdirectories, and their subdirectories, etc, that match the given
  9215.   pattern.  Warning -- this one can take quite some time if performed at the
  9216.   root of a large directory tree.
  9217.  
  9218. \frdirectories(pattern[,&a])
  9219.   Returns the number of directories in the current or given directory and all
  9220.   of its subdirectories, and their subdirectories, etc, that match the given
  9221.   pattern.
  9222.  
  9223. Each of these functions builds up a list of files to be returned by the
  9224. \fnextfile() function, just as \ffiles() always has done.  (This can also
  9225. be done with the /ARRAY switch of the DIRECTORY command; see Sections 4.5.1
  9226. and 7.10).
  9227.  
  9228. Each of these functions can be given an array name as an optional second
  9229. argument.  If an array name is supplied, the array will contain the number of
  9230. files as its 0th element, and the filenames in elements 1 through last.  If
  9231. the array already existed, its previous contents are lost.  For example, if
  9232. the current directory contains two files, oofa.txt and foo.bar, then
  9233. "\ffiles(*,&a)" creates an array \&a[] with a dimension of 2, containing the
  9234. following elements:
  9235.  
  9236.  \&a[0] = 2
  9237.  \&a[1] = oofa.txt
  9238.  \&a[2] = foo.bar
  9239.  
  9240. If no files match the specification given in the first argument, the array
  9241. gets a dimension of 0, which is the same as undeclaring the array.
  9242.  
  9243. Note that the order in which the array is filled (and in which \fnextfile()
  9244. returns filenames) is indeterminate (but see Section 7.10.5).
  9245.  
  9246. Here's an example that builds and prints a list of all the file whose names
  9247. end in .txt in the current directory and all its descendents:
  9248.  
  9249.   asg \%n \frfiles(*.txt)
  9250.   declare \&a[\%n]
  9251.   for \%i 1 \%n 1 {
  9252.       asg \&a[\%i] \fnextfile()
  9253.       echo \flpad(\%i,4). "\&a[\%i]"
  9254.   }
  9255.  
  9256. Alternatively, using the array method, and then printing the filenames in
  9257. alphabetic order (see Sections 7.10.3 and 7.10.5):
  9258.  
  9259.   asg \%n \frfiles(*.txt,&a)
  9260.   sort &a
  9261.   for \%i 1 \%n 1 {
  9262.       echo \flpad(\%i,4). "\&a[\%i]"
  9263.   }
  9264.  
  9265. Or even more simply:
  9266.  
  9267.   asg \%n \frfiles(*.txt,&a)
  9268.   sort &a
  9269.   show array &a
  9270.  
  9271. As noted elsewhere, the file lists built by \ffiles(), \frfiles(), etc, are
  9272. now "safe" in the sense that SEND and other file-related commands can
  9273. reference \fnextfile() without resetting the list:
  9274.  
  9275.   set send pathnames relative
  9276.   for \%i 1 \frfiles(*.txt) 1 {
  9277.       asg \%a \fnextfile()
  9278.       echo Sending \%a...
  9279.       send \%a
  9280.       if fail break
  9281.   }
  9282.  
  9283. Copying to an array (as shown on p.398 of "Using C-Kermit" 2nd Ed) is no
  9284. longer necessary.
  9285.  
  9286. 4.11.5. Moving Directory Trees Between Like Systems
  9287.  
  9288. 4.11.5.1. UNIX to UNIX
  9289.  
  9290. Transferring a directory tree from one computer to another replicates the file
  9291. sender's arrangement of files and directories on the file receiver's computer.
  9292. Normally this is done using relative pathnames, since the user IDs might not
  9293. be identical on the two computers.  Let's say both computers are UNIX based,
  9294. running C-Kermit 7.0 or later.  On the sending computer (leaving out the
  9295. connection details, etc):
  9296.  
  9297.   C-Kermit> cd /usr/olga
  9298.   C-Kermit> send /recursive .
  9299.  
  9300. The /RECURSIVE switch tells C-Kermit to descend through the directory tree
  9301. and to include relative pathnames on outbound filenames.
  9302.  
  9303. On the receiving computer:
  9304.  
  9305.   C-Kermit> mkdir olgas-files           ; Make a new directory.
  9306.   C-Kermit> cd olgas-files              ; CD to it.
  9307.   C-Kermit> receive /recursive          ; = /PATHNAMES:RELATIVE
  9308.  
  9309. Each Kermit program recognizes that the other is running under UNIX and
  9310. switches to binary mode and literal filenames automatically.  Directories
  9311. are automatically created on the receiving system as needed.  File dates
  9312. and permissions are automatically reproduced from source to destination.
  9313.  
  9314. 4.11.5.2. VMS to VMS
  9315.  
  9316. To send recursively from VMS, simply include the /RECURSIVE switch, for
  9317. example at the sender:
  9318.  
  9319.   $ kermit
  9320.   C-Kermit> cd [olga]
  9321.   C-Kermit> send /recursive *.*;0
  9322.  
  9323. And at the receiver:
  9324.  
  9325.   C-Kermit> cd [.olga]
  9326.   C-Kermit> receive /recursive
  9327.  
  9328. The notation "..." within directory brackets in VMS means "this directory
  9329. and all directories below it"; the /RECURSIVE switch, when given to the
  9330. sender, implies the use of "..." in the file specification so you don't have
  9331. to include "..."; but it makes no difference if you do:
  9332.  
  9333.   $ kermit
  9334.   C-Kermit> send /recursive [olga...]*.*;0
  9335.  
  9336. And at the receiver:
  9337.  
  9338.   C-Kermit> cd [.olga]
  9339.   C-Kermit> receive /recursive
  9340.  
  9341. In either case, since both systems recognize each other as VMS, they switch
  9342. into LABELED transfer mode automatically.
  9343.  
  9344. 4.11.6. Moving Directory Trees Between Unlike Systems
  9345.  
  9346. There are several difficulties with recursive transfers between unlike
  9347. systems:
  9348.  
  9349.  . File formats can be different, especially text files character sets and
  9350.    record formats.  This can now be handled by using SET FILE PATTERN,
  9351.    SET FILE TEXT-PATTERNS, and SET FILE BINARY-PATTERNS (Section 4.3).
  9352.  
  9353.  . File naming conventions are different.  For example, one system might allow
  9354.    (and use) longer filenames than the other.  You can tell Kermit how to
  9355.    handle file names with the normal "set file names" and "set file
  9356.    collision" mechanisms.  Most modern Kermits are fairly tolerant of illegal
  9357.    filenames and should not fail simply because of an incoming filename;
  9358.    rather, it will do its best to convert it to a recognizable and unique
  9359.    legal filename.
  9360.  
  9361.  . Directory notations can be different, e.g. backslashes instead of slashes,
  9362.    brackets, parentheses, spaces, etc.  But this is now handled by converting
  9363.    pathnames to a standard format during transfer (Section 4.10).
  9364.  
  9365. So now, for the first time, it is possible to send directory trees among
  9366. any combination of UNIX, DOS, Windows, OS/2, VMS, AOS/VS, etc.  Here's an
  9367. example sending files from an HP-UX system (where text files are encoded in
  9368. the HP Roman8 character set) to a PC with K95 (where text files are encoded
  9369. in CP850):
  9370.  
  9371.  Sender:
  9372.   cd xxx                           ; CD to root of source tree
  9373.   set file type binary             ; Default transfer mode
  9374.   set file character-set hp-roman8 ; Local character set for text files
  9375.   set xfer character-set latin1    ; Transfer character set
  9376.   set file patterns on             ; Enable automatic file-type switching...
  9377.   set file binary-patterns *.Z *.gz *.o  ; based on these patterns...
  9378.   set file text-patterns *.txt *.c *.h   ; for binary and text files.
  9379.   send /recursive *                ; Send all the file in this directory tree
  9380.  
  9381.  Receiver:
  9382.   cd yyy                           ; CD to root of destination tree
  9383.   set file character-set cp850     ; Local character set for text files
  9384.   receive /pathnames:relative      ; Receive with pathnames
  9385.  
  9386.  Notes:
  9387.  . Replace "xxx" and "yyy" with the desired directories.
  9388.  . Replace the file character sets appropriately.
  9389.  . Change the patterns as needed (or just use the built-in default lists).
  9390.  . SEND /RECURSIVE also implies /PATHNAMES:RELATIVE.
  9391.  . The file sender tells the file receiver the transfer mode of each file.
  9392.  . The file sender tells the file receiver the transfer character set.
  9393.  . By default, destination file dates will be the same as on the source.
  9394.  . Many of the settings shown might already be set by default.
  9395.  . See sections 4.3, 4.10, and 4.15 for additional explanation.
  9396.  
  9397. If you are refreshing an existing directory on the destination computer,
  9398. use "set file collision update" or other appropriate file collision option
  9399. to handle filename collisions.
  9400.  
  9401. 4.12. Where Did My File Go?
  9402.  
  9403. Now that Kermit can be started by clicking on desktop icons (thus obscuring
  9404. the concept of "current directory"), and can have a download directory, and
  9405. can create directories for incoming files on the fly, etc, sometimes it is
  9406. easy to lose a file after transfer.  Of course, if you keep a transaction log:
  9407.  
  9408.   LOG TRANSACTIONS
  9409.  
  9410. it will record the fate and final resting place of each file.  But in case
  9411. you did not keep a log, the new command:
  9412.  
  9413.   WHERE
  9414.  
  9415. added in C-Kermit 7.0, gives you as much information as it has about the
  9416. location of the last files transferred, including the pathname reported by
  9417. the receiving Kermit, if any, when C-Kermit is the sender.  This information
  9418. was also added to SHOW FILE in somewhat less detail.
  9419.  
  9420. 4.13. File Output Buffer Control
  9421.  
  9422. (UNIX only).  The new command SET FILE OUTPUT lets you control how incoming
  9423. files are written to disk:
  9424.  
  9425. SET FILE OUTPUT BUFFERED [ <size> ]
  9426.   Chooses buffered file output; this is the default.  UNIX does its normal
  9427.   sort of disk buffering.  The optional <size> specifies Kermit's own file
  9428.   output buffer size, and therefore the frequency of disk accesses (write()
  9429.   system calls) -- the bigger the size, the fewer the disk accesses.
  9430.  
  9431. SET FILE OUTPUT UNBUFFERED [ <size> ]
  9432.   This forces each file output write() call to actually commit the data to
  9433.   disk immediately.  Choosing this option will usually slow file reception
  9434.   down.
  9435.  
  9436. SET FILE OUTPUT BLOCKING
  9437.   Write() calls should not return until they are complete.  This is the normal
  9438.   setting, and it lets Kermit detect disk-write errors immediately.
  9439.  
  9440. SET FILE OUTPUT NONBLOCKING
  9441.   Write() calls should return immediately.  This can speed up file reception,
  9442.   but also delay the detection of disk-write errors.
  9443.  
  9444. Experimentation with these parameters should be harmless, and might (or might
  9445. not) have a perceptible, even dramatic, effect on performance.
  9446.  
  9447. 4.14. Improved Responsiveness
  9448.  
  9449. In version 7.0, C-Kermit's file-transfer protocol engine has been tuned
  9450. for additional speed and responsiveness.
  9451.  
  9452.  . Binary-mode transfers over 8-bit connections, a very common case, are
  9453.    now handled in a special way that minimizes overhead.
  9454.  
  9455.  . SET TRANSFER CRC-CALCULATION is now OFF by default, rather than ON.
  9456.    (This affects only the overall per-transfer CRC, \v(crc16), not the
  9457.    per-packet CRCs)
  9458.  
  9459.  . Connection loss during file transfer is now detected immediately in most
  9460.    cases on Internet connections and on serial connections when CARRIER-WATCH
  9461.    is not set to OFF.
  9462.  
  9463. 4.15. DOUBLING AND IGNORING CHARACTERS FOR TRANSPARENCY
  9464.  
  9465. The following commands were added in 7.0, primarily to allow successful
  9466. file transfer through ARPAnet TACs and with Honeywell DPS6 systems, but can
  9467. be used in any setting where they might be needed:
  9468.  
  9469. SET SEND DOUBLE-CHAR { [ <char> [ <char> [ ... ] ] ], NONE }
  9470.   Tells C-Kermit to double the specified characters (use decimal notation)
  9471.   in packets that it sends.  For example, if you are sending files through
  9472.   a device that uses @ as an escape character, but allows you to send a
  9473.   single copy of @ through by doubling it, use "set send double 64".
  9474.  
  9475. SET RECEIVE IGNORE-CHAR [ <char> [ <char> [ ... ] ] ]
  9476.   Tells C-Kermit to ignore the specified character(s) in incoming packets.
  9477.   Use this, for example, when something between the sender and receiver is
  9478.   inserting linefeeds for wrapping, NULs for padding, etc.
  9479.  
  9480. 4.16. New File-Transfer Display Formats
  9481.  
  9482. SET TRANSFER DISPLAY { BRIEF, CRT, FULLSCREEN, NONE, SERIAL }
  9483.  
  9484. BRIEF is the new one.  This writes one line to the screen per file, showing
  9485. the file's name, transfer mode, size, the status of the transfer, and when the
  9486. transfer is successful, the effective data rate in characters per second (CPS).
  9487. Example:
  9488.  
  9489.  SEND ckcfn3.o (binary) (59216 bytes): OK (0.104 sec, 570206 cps)
  9490.  SEND ckcfns.o (binary) (114436 bytes): OK (0.148 sec, 772006 cps)
  9491.  SEND ckcmai.c (text) (79147 bytes): OK (0.180 sec, 438543 cps)
  9492.  SEND ckcmai.o (binary) (35396 bytes): OK (0.060 sec, 587494 cps)
  9493.  SEND ckcnet.o (binary) (62772 bytes): REFUSED
  9494.  SEND ckcpro.o (binary) (121448 bytes): OK (0.173 sec, 703928 cps)
  9495.  SEND ckcpro.w (text) (63687 bytes): OK (0.141 sec, 453059 cps)
  9496.  SEND makefile (text) (186636 bytes): OK (0.444 sec, 420471 cps)
  9497.  SEND wermit (binary) (1064960 bytes): OK (2.207 sec, 482477 cps)
  9498.  
  9499. Note that transfer times are now obtained in fractional seconds, rather than
  9500. whole seconds, so the CPS figures are more accurate (the display shows 3
  9501. decimal places, but internally the figure is generally precise to the
  9502. microsecond).
  9503.  
  9504. 4.17. New Transaction Log Formats
  9505.  
  9506. The new command:
  9507.  
  9508.   SET TRANSACTION-LOG { VERBOSE, FTP, BRIEF [ <separator> ] }
  9509.  
  9510. lets you choose the format of the transaction log.  VERBOSE (the default)
  9511. indicates the traditional format described in the book.  BRIEF and FTP are
  9512. new.  This command must be given prior to the LOG TRANSACTION command if a
  9513. non-VERBOSE type is desired.
  9514.  
  9515. 4.17.1. The BRIEF Format
  9516.  
  9517. BRIEF chooses a one-line per file format suitable for direct importation into
  9518. databases like Informix, Oracle, or Sybase, in which:
  9519.  
  9520.  . Each record has 8 fields.
  9521.  . Fields are separated by a non-alphanumeric separator character.
  9522.  . The default separator character is comma (,).
  9523.  . Any field containing the separator character is enclosed in doublequotes.
  9524.  . The final field is enclosed in doublequotes.
  9525.  
  9526. The fields are:
  9527.  
  9528.   1. Date in yyyymmdd format
  9529.   2. Time in hh:mm:ss format
  9530.   3. Action: SEND or RECV
  9531.   4. The local filename
  9532.   5. The size of the file
  9533.   6. The transfer mode (text, binary, image, labeled)
  9534.   7. The status of the transfer: OK or FAILED
  9535.   8. Additional status-dependent info, in doublequotes.
  9536.  
  9537. Examples:
  9538.  
  9539.   20000208,12:08:52,RECV,/u/olga/oofa.txt,5246,text,OK,"0.284sec 18443cps"
  9540.   20000208,12:09:31,SEND,/u/olga/oofa.exe,32768,binary,OK,"1.243sec 26362cps"
  9541.   20000208,12:10:02,SEND,"/u/olga/a,b",10130,text,FAILED,"Refused: date"
  9542.  
  9543. Note how the filename is enclosed in doublequotes in the final example,
  9544. because it contains a comma.
  9545.  
  9546. To obtain BRIEF format, you must give the SET TRANSACTION-LOG BRIEF command
  9547. before the LOG TRANSACTIONS command.  (If you give them in the opposite order,
  9548. a heading is written to the log by the LOG command.)
  9549.  
  9550. 4.17.2. The FTP Format
  9551.  
  9552. SET TRANSACTION-LOG FTP (available only in UNIX) chooses a format that is
  9553. compatible with the WU-FTPD (Washington University FTP daemon) log, and so can
  9554. be processed by any software that processes the WU-FTPD log.  It logs only
  9555. transfers in and out, both successful and failed (but success or failure is
  9556. not indicated, due to lack of a field in the WU-FTPD log format for this
  9557. purpose).  Non-transfer events are not recorded.
  9558.  
  9559. Unlike other logs, the FTP-format transaction log is opened in append mode
  9560. by default.  This allows you to easily keep a record of all your kermit
  9561. transfers, and it also allows the same log to be shared by multiple
  9562. simultaneous Kermit processes or (permissions permitting) users.  You can, of
  9563. course, force creation of a new logfile by specifying the NEW keyword after
  9564. the filename, e.g.
  9565.  
  9566.   log transactions oofa.log new
  9567.  
  9568. All records in the FTP-style log are in a consistent format.  The first field
  9569. is fixed-length and contains spaces; subsequent fields are variable length,
  9570. contain no spaces, and are separated by one or more spaces.  The fields are:
  9571.  
  9572. Timestamp
  9573.   This is an asctime-style timestamp, example: "Wed Sep 16 20:19:05 1999"
  9574.   It is always exactly 24 characters long, and the subfields are always in
  9575.   fixed positions.
  9576.  
  9577. Elapsed time
  9578.   The whole number of seconds required to transfer the file, as a string
  9579.   of decimal digits, e.g. "24".
  9580.  
  9581. Connection
  9582.   The name of the network host to which C-Kermit is connected, or the name
  9583.   of the serial device through which it has dialed (or has a direct
  9584.   connection), or "/dev/tty" for transfers in remote mode.
  9585.  
  9586. Bytes transferred
  9587.   The number of bytes transferred, decimal digits, e.g. "1537904".
  9588.  
  9589. Filename
  9590.   The name of the file that was transferred, e.g.
  9591.   "/pub/ftp/kermit/a/README.TXT".  If the filename contains any spaces or
  9592.   control characters, each such character is replaced by an underscore ('_')
  9593.   character.
  9594.  
  9595. Mode
  9596.   The letter 'b' if the file was transferred in binary mode, or 'a'
  9597.   if it was transferred in text (ASCII) mode.
  9598.  
  9599. Options
  9600.   This field always contains an underscore ('_') character.
  9601.  
  9602. Direction
  9603.   The letter 'o' if the file was transferred Out, and 'i' if the file was
  9604.   transferred In.
  9605.  
  9606. User class
  9607.   The letter 'r' indicates the file was transferred by a Real user.
  9608.  
  9609. User identification
  9610.   The ID of the user who transferred the file.
  9611.  
  9612. Server identification
  9613.   The string "kermit".  This distinguishes a Kermit transfer log
  9614.   record from a WU-FTPD record, which contains "ftp" in this field.
  9615.  
  9616. Authentication class
  9617.   The digit '1' if we know the user's ID on the client system,
  9618.   otherwise '0'.  Currently, always '0'.
  9619.  
  9620. Authenticated user
  9621.   If the authentication class is '1', this is the user's ID on the client
  9622.   system.  Otherwise it is an asterisk ('*').  Currently it is always an
  9623.   asterisk.
  9624.  
  9625. Examples:
  9626.  
  9627.   Thu Oct 22 17:42:48 1998 0 * 94 /usr/olga/new.x a _ i r olga kermit 0 *
  9628.   Thu Oct 22 17:51:29 1998 1 * 147899 /usr/olga/test.c a _ o r olga kermit 0 *
  9629.   Thu Oct 22 17:51:44 1998 1 * 235 /usr/olga/test.o b _ i r olga kermit 0 *
  9630.   Fri Oct 23 12:10:25 1998 0 * 235 /usr/olga/x.ksc a _ o r olga kermit 0 *
  9631.  
  9632. Note that an ftp-format transaction log can also be selected on the Kermit
  9633. command line as follows:
  9634.  
  9635.   kermit --xferfile:<filespec>
  9636.  
  9637. This is equivalent to:
  9638.  
  9639.   SET TRANSACTION-LOG FTP
  9640.   LOG TRANSACTIONS <filespec> APPEND
  9641.  
  9642. Conceivably it could be possible to have a system-wide shared Kermit log,
  9643. except that UNIX lacks any notion of an append-only file; thus any user who
  9644. could append to the log could also delete it (or alter it).  This problem
  9645. could be worked around using setuid/setgid tricks, but these would most likely
  9646. interfere with the other setuid/setgid tricks C-Kermit must use for getting
  9647. at dialout devices and UUCP logfiles.
  9648.  
  9649. 4.18. Unprefixing NUL
  9650.  
  9651. As of 6.1.193 Alpha.10, C-Kermit can finally send and receive file-transfer
  9652. packets in which NUL (ASCII 0) is unprefixed (no more NUL-terminated
  9653. packets!).  NUL is, of course, extremely prevalent in binary files such as
  9654. executables, and this has been a significant source of packet overhead.  For
  9655. example, when transferring itself (the SunOS C-Kermit executable) with minimal
  9656. prefixing and 9000-byte packets, we see:
  9657.  
  9658.   File size:                       1064960
  9659.   Packet chars with 0 prefixed:    1199629  overhead = 12.65%
  9660.   Packet chars with 0 unprefixed:  1062393  overhead = -0.03%
  9661.  
  9662. Transfer rates go up accordingly, not only because of the reduced amount of
  9663. i/o, but also because less computation is required on each end.
  9664.  
  9665. 4.19. Clear-Channel Protocol
  9666.  
  9667. Now that C-Kermit itself is capable of sending and receiving any byte at all
  9668. on a clear channel (section 4.18), it is, for the first time, in a position to
  9669. negotiate a clear channel with the other Kermit, giving it permission (but not
  9670. requiring it) to unprefix any and all characters that it knows are safe.  In
  9671. general this means all but the Kermit start-of-packet character (normally
  9672. Ctrl-A), Carriage Return (not only Kermit's end-of-packet character, but also
  9673. treated specially on Telnet NVT links), and IAC (255, also special to Telnet).
  9674.  
  9675. By default, C-Kermit will say it has a clear channel only if it has opened a
  9676. TCP socket.  Since the Kermit program on the far end of a TCP/IP connection
  9677. generally does not know it has a TCP/IP connection, it will not announce a
  9678. clear channel unless it has been told to do so.  The command is:
  9679.  
  9680.   SET CLEAR-CHANNEL { ON, OFF, AUTO }
  9681.  
  9682. AUTO is the default, meaning that the clear-channel status is determined
  9683. automatically from the type of connection.  ON means to announce a clear
  9684. channel, OFF means not to announce it.  Use SHOW STREAMING (Section 4.20)
  9685. to see the current CLEAR-CHANNEL status.  Synonym: SET CLEARCHANNEL.
  9686.  
  9687. CLEAR-CHANNEL is also set if you start C-Kermit with the -I switch (see
  9688. Section 4.20).
  9689.  
  9690. Whenever a clear channel is negotiated, the resulting control-character
  9691. unprefixing is "sticky"; that is, it remains in effect after the transfer so
  9692. you can use SHOW CONTROL to see what was negotiated.
  9693.  
  9694. You can also see whether a clear channel was negotiated in the STATISTICS
  9695. /VERBOSE Display.
  9696.  
  9697. The advantage of the clear channel feature is that it can make file transfers
  9698. go faster automatically.  The disadvantage would be file-transfer failures if
  9699. the channel is not truly clear, for example if C-Kermit made a Telnet
  9700. connection to a terminal server, and then dialed out from there; or if
  9701. C-Kermit made an Rlogin connection to host and then made a Telnet connection
  9702. from there to another host.  If a file transfer fails on a TCP/IP connection,
  9703. use SHOW CONTROL to check whether control characters became unprefixed as a
  9704. result of protocol negotiations, and/or SHOW STREAMING (Section 4.20) to see
  9705. if "clear-channel" was negotiated.  If this happened, use SET CLEAR-CHANNEL
  9706. OFF and SET PREFIXING CAUTIOUS (or whatever) to prevent it from happening
  9707. again.
  9708.  
  9709. 4.20. Streaming Protocol
  9710.  
  9711. A new Kermit protocol option called "streaming" was added in C-Kermit 7.0.
  9712. The idea is that if the two Kermit partners have a reliable transport (such as
  9713. TCP/IP or X.25) between them, then there is no need to send ACKs for Data
  9714. packets, or NAKs, since a reliable transport will, by definition, deliver all
  9715. packets in order and undamaged.  On such a connection, streaming cuts down not
  9716. only on Kermit program overhead (switching back and forth between reading and
  9717. sending packets), but also tends to make the underlying transport use itself
  9718. more efficiently (e.g. by defeating the Nagle algorithm and/or Delayed ACK
  9719. stratagem of the TCP layer).  Furthermore, it allows transfers to work
  9720. smoothly on extremely slow network congestions that would otherwise cause
  9721. timeouts and retransmissions, and even failure when the retry limit was
  9722. exceeded.
  9723.  
  9724. The trick is knowing when we can stream:
  9725.  
  9726.  a. If C-Kermit has opened a TCP socket or X.25 connection, it offers stream.
  9727.  
  9728.  b. If C-Kermit has been started with the -I (uppercase) option, or if it
  9729.     has been told to SET RELIABLE ON, it offers to stream.
  9730.  
  9731.  c. If C-Kermit is in remote mode, and has been told to SET RELIABLE AUTO
  9732.     (or ON), it always offers to stream, and also always agrees to stream,
  9733.     if the other Kermit offers.  Unless you take explicit actions to override
  9734.     the defaults, this allows the local Kermit (the one that made the
  9735.     connection, and so knows whether it's reliable) to control streaming.
  9736.  
  9737. (Note that an offer to stream also results in a Clear-Channel announcement if
  9738. CLEAR-CHANNEL is set to AUTO; see Section 4.19.)
  9739.  
  9740. When BOTH Kermits offer to stream, then they stream; otherwise they don't.
  9741. Thus streaming-capable Kermit programs interoperate automatically and
  9742. transparently with nonstreaming ones.  If the two Kermits do agree to stream,
  9743. you'll see the word "STREAMING" on the fullscreen file-transfer display in the
  9744. Window Slots field.  You can also find out afterwards with the STATISTICS or
  9745. SHOW STREAMING commands.
  9746.  
  9747.   WARNING: Automatic choice of streaming is based on the assumption of a
  9748.   "direct" end-to-end network connection; for example, a Telnet or Rlogin
  9749.   connection from host A to host B, and transferring files between A and
  9750.   B.  However, if your connection has additional components -- something
  9751.   "in the middle" (B) that you have made a network connection to, which
  9752.   makes a separate connection to the destination host (C), then you don't
  9753.   really have a reliable connection, but C-Kermit has no way of knowing
  9754.   this; transferring files between A and C will probably fail.  In such
  9755.   cases, you'll need to tell the *local* C-Kermit to "set reliable off"
  9756.   before transferring files (it does no good to give this command to the
  9757.   remote Kermit since the local one controls the RELIABLE setting).
  9758.  
  9759. Streaming is like using an infinite window size, with no timeouts and no
  9760. tolerance for transmission errors (since there shouldn't be any).  It relies
  9761. on the underlying transport for flow control, error correction, timeouts, and
  9762. retransmission.  Thus it is very suitable for use on TCP/IP connections,
  9763. especially slow or bursty ones, since Kermit's packet timeouts won't interfere
  9764. with the transfer -- each packet takes as long to reach its destination as it
  9765. takes TCP to deliver it.  If TCP can't deliver the packet within its own
  9766. timeout period (over which Kermit has no control), it signals a fatal error.
  9767. Just like FTP.
  9768.  
  9769. Streaming goes much faster than non-streaming when a relatively small packet
  9770. length is used, and it tends to go faster than non-streaming with even the
  9771. longest packet lengths.  The Kermit window size is irrelevant to streaming
  9772. protocol, but still might affect performance in small ways since it can result
  9773. in different paths through the code.
  9774.  
  9775. The definition of "reliable transport" does not necessarily demand 8-bit and
  9776. control-character transparency.  Streaming can work with parity and/or
  9777. control-character prefixing just as well (but not as fast) as without them;
  9778. in such cases you can leave RELIABLE set to ON, but set CLEARCHANNEL and/or
  9779. PARITY appropriately.
  9780.  
  9781. Maximum performance -- comparable to and often exceeding FTP -- is achieved on
  9782. socket-to-socket connections (in which the considerable overhead of the
  9783. terminal driver and Telnet or Rlogin server is eliminated) with long packets
  9784. and the new "brief" file-transfer display (Section 4.16).
  9785.  
  9786. 4.20.1. Commands for Streaming
  9787.  
  9788. SET RELIABLE { ON, OFF, AUTO }
  9789.   SET RELIABLE ON tells Kermit that it has a reliable transport.
  9790.   SET RELIABLE OFF tells Kermit the transport is not reliable.
  9791.   SET RELIABLE AUTO tells Kermit that it should SET RELIABLE ON whenever
  9792.   it makes a reliable connection (e.g. TELNET or SET HOST on a TCP/IP or
  9793.   X.25 network), and when in remote mode it should believe the transport is
  9794.   reliable if the other Kermit says it is during Kermit protocol negotiation.
  9795.  
  9796. AUTO is the default; the Kermit program that makes the connection knows
  9797. whether it is reliable, and tells the remote Kermit.
  9798.  
  9799. The RELIABLE setting has several effects, including:
  9800.  
  9801.  . It can affect the timeouts used during normal ACK/NAK protocol.
  9802.  . It can affect the clear-channel announcement.
  9803.  . It can affect streaming.
  9804.  
  9805. If you TELNET or SET HOST somewhere, this includes an implicit SET RELIABLE ON
  9806. command.  The -I command-line option is equivalent to SET RELIABLE ON.
  9807.  
  9808. Since SET RELIABLE ON (and -I) also implies SET CLEAR CHANNEL ON, you might
  9809. find that in certain cases you need to tell Kermit that even though the
  9810. connection is reliable, it doesn't have a clear channel after all:
  9811.  
  9812.   SET CLEAR-CHANNEL OFF
  9813.   SET PREFIXING CAUTIOUS ; or whatever...
  9814.  
  9815. You can control streaming without affecting the other items with:
  9816.  
  9817.   SET STREAMING { ON, OFF, AUTO }
  9818.  
  9819. AUTO is the default, meaning streaming will occur if Kermit has made a TCP/IP
  9820. connection or if RELIABLE is ON (or it was started with the -I command line
  9821. option).  OFF means don't stream; ON means offer to stream no matter what.
  9822.  
  9823. 4.20.2. Examples of Streaming
  9824.  
  9825. Here we look at the use and behavior of streaming on several different kinds
  9826. of connections, and compare its performance with non-streaming transfers.
  9827.  
  9828. 4.20.2.1. Streaming on Socket-to-Socket Connections
  9829.  
  9830. Here we get streaming automatically when both Kermit programs are capable of
  9831. it, since they both make socket connections.  For example, on the far end:
  9832.  
  9833.   C-Kermit> set host * 3000
  9834.   C-Kermit> server
  9835.  
  9836. and on the near end:
  9837.  
  9838.   C-Kermit> set host foo.bar.xyz.com 3000
  9839.   (now give SEND and GET command)
  9840.  
  9841. All subsequent file transfers use streaming automatically.
  9842.  
  9843. Here are the results from 84 trials, run on a production network,
  9844. disk-to-disk, in which a 1-MB binary file (the SunOS C-Kermit Sparc
  9845. executable) was sent from a Sun Sparc-10 with SunOS 4.1.3 to an IBM Power
  9846. Server 850 with AIX 4.1, socket-to-socket, over a 10Mbps 10BaseT Ethernet,
  9847. using minimal control-character unprefixing, window sizes from 10 to 32, and
  9848. packet sizes from 1450 to 9010:
  9849.  
  9850.                 Streaming    Nonstreaming
  9851.   Max CPS         748955        683354
  9852.   Min CPS         221522        172491
  9853.   Mean CPS        646134        558680
  9854.   Median CPS      678043        595874
  9855.   Std Dev         101424        111493
  9856.  
  9857. Correlations:
  9858.  
  9859.   CPS and window size:   -0.036
  9860.   CPS and packet length:  0.254
  9861.   CPS and streaming:      0.382
  9862.  
  9863. Note that the relationship between streaming and throughput is significantly
  9864. stronger than that between CPS and window size or packet length.
  9865.  
  9866. Also note that this and all other performance measurements in this section
  9867. are snapshots in time; the results could be much different at other times when
  9868. the load on the systems and/or the network is higher or lower.
  9869.  
  9870. In a similar socket-to-socket trial, but this time over a wide-area TCP/IP
  9871. connection (from New York City to Logan, Utah, about 2000 miles), the
  9872. following results were obtained:
  9873.  
  9874.                 Streaming    Nonstreaming
  9875.   Max CPS         338226        318203
  9876.   Min CPS         191659        132314
  9877.   Mean CPS        293744        259240
  9878.   Median CPS      300845        273271
  9879.   Std Dev          41914         52351
  9880.  
  9881. Correlations:
  9882.  
  9883.   CPS and window size:    0.164
  9884.   CPS and packet length:  0.123
  9885.   CPS and streaming:      0.346
  9886.  
  9887. 4.20.2.2. Streaming on Telnet Connections
  9888.  
  9889. In this case the local copy of Kermit is told to TELNET or SET HOST, and so it
  9890. knows it has a reliable connection and -- unless it has been told not to --
  9891. will offer to stream, and the other Kermit program, since it has STREAMING set
  9892. to AUTO, agrees.
  9893.  
  9894. Since we have a reliable connection, we'll also get control-character
  9895. unprefixing automatically because of the new clear-channel protocol (Section
  9896. 4.19).
  9897.  
  9898. Any errors that occur during streaming are fatal to the transfer.  The
  9899. message is "Transmission error on reliable link".  Should this happen:
  9900.  
  9901.  a. Check the remote Kermit's flow control setting (SHOW COMMUNICATIONS).
  9902.     If it is NONE, change it to XON/XOFF, or vice versa.  If it is XON/XOFF
  9903.     (or you just changed it to XOFF/XOFF), make sure the file sender is
  9904.     prefixing the XON and XOFF characters.  In the most drastic case, use
  9905.     "set prefix all" to force prefixing of all control characters.
  9906.  
  9907.  b. The remote Telnet server might chop off the 8th bit.  In that case, tell
  9908.     C-Kermit to "set parity space".  Or, you might be able to force the
  9909.     Telnet to allow eight-bit data by telling C-Kermit to "set telopt binary
  9910.     request accept" -- that is, request the Telnet server to enter binary
  9911.     mode, and accept binary-mode bids from the server.
  9912.  
  9913.  c. The remote Telnet server might have a buffering limitation.  If a and b
  9914.     don't cure the problem, tell the file receiver to "set receive
  9915.     packet-length 1000" (or other number -- use the largest one that works).
  9916.     This too, is no different from the non-streaming case (more about this
  9917.     in Section 4.20.2.3).
  9918.  
  9919. And remember you can continue interrupted binary-mode transfers where they
  9920. left off with the RESEND (= SEND /RECOVER) command.
  9921.  
  9922. Here are the figures for the same 84 trials between the same Sun and IBM
  9923. hosts as in 4.20.2.1, on the same network, but over a Telnet connection rather
  9924. than socket-to-socket:
  9925.  
  9926.                   Streaming    Nonstreaming
  9927.   Max CPS         350088        322523
  9928.   Min CPS          95547        173152
  9929.   Mean CPS        321372        281830
  9930.   Median CPS      342604        291469
  9931.   Std Dev          40503         29948
  9932.  
  9933. Correlations:
  9934.  
  9935.   CPS and window size:    0.001
  9936.   CPS and packet length:  0.152
  9937.   CPS and streaming:      0.128
  9938.  
  9939. Here the effect is not as emphatic as in the socket-to-socket case, yet on
  9940. the whole streaming tends to be beneficial.
  9941.  
  9942. Additional measurements on HP-UX using C-Kermit 7.0 Beta.06:
  9943.  
  9944.                   Windowing     Streaming
  9945.   HP-UX 8->8      not tested       14Kcps
  9946.   HP-UX 8->9      not tested       76Kcps
  9947.   HP-UX 8->10      36Kcps          66Kcps
  9948.   HP-UX 9->9      not tested      190Kcps
  9949.   HP-UX 9->10     160Kcps         378Kcps
  9950.  
  9951. 4.20.2.3. Streaming with Limited Packet Length
  9952.  
  9953. The IRIX telnet server (at least the ones observed in IRIX 5.3 and 6.2) does
  9954. not allow Kermit to send packets longer than 4096 bytes.  Thus when sending
  9955. from IRIX C-Kermit when it is on the remote end of a Telnet connection, the
  9956. packet length must be 4K or less.  Trials in this case (in which packet
  9957. lengths range from 1450 to 4000) show a strong advantage for streaming, which
  9958. would be evident in any other case where the packet length is restricted, and
  9959. stronger the shorter the maximum packet length.
  9960.  
  9961.                   Streaming    Nonstreaming
  9962.   Max CPS         426187        366870
  9963.   Min CPS         407500        276517
  9964.   Mean CPS        415226        339168
  9965.   Median CPS      414139        343803
  9966.   Std Dev           6094         25851
  9967.  
  9968. Correlations:
  9969.  
  9970.   CPS and window size:    0.116
  9971.   CPS and packet length:  0.241
  9972.   CPS and streaming:      0.901
  9973.  
  9974. 4.20.2.4. Streaming on Dialup Connections
  9975.  
  9976. Here "dialup" refers to a "direct" dialup connection, not a SLIP or PPP
  9977. connection, which is only a particular kind of TCP/IP connection.
  9978.  
  9979. Attempt this at your own risk, and then only if (a) you have error-correcting
  9980. modems, and (b) the connections between the modems and computers are also
  9981. error-free, perfectly flow-controlled, and free of interrupt conflicts.
  9982. Streaming can be used effectively and to fairly good advantage on such
  9983. connections, but remember that the transfer is fatal if even one error is
  9984. detected (also remember that should a binary-mode transfer fail, it can be
  9985. recovered from the point of failure with RESEND).
  9986.  
  9987. To use streaming on an unreliable connection, you must tell both Kermits that
  9988. the connection is reliable:
  9989.  
  9990.   kermit -I
  9991.  
  9992. or:
  9993.  
  9994.   C-Kermit> set reliable on
  9995.  
  9996. In this case, it will probably be necessary to prefix some control characters,
  9997. for example if your connection is through a terminal server that has an escape
  9998. character.  Most Cisco terminal servers, for example, require Ctrl-^ (30, as
  9999. well as its high-bit equivalent, 158) to be prefixed.  To unprefix these,
  10000. you'll need to defeat the "clear channel" feature:
  10001.  
  10002.   C-Kermit> set reliable on
  10003.   C-Kermit> set clear-channel off
  10004.   C-Kermit> set prefixing none
  10005.   C-Kermit> set control prefix 1 13 30 158 ; and whatever else is necessary
  10006.  
  10007. Dialup trials were done using fixed large window and packet sizes.  They
  10008. compare uploading and downloading of two common types of files, with and
  10009. without streaming.  Configuration:
  10010.  
  10011.   HP-9000/715/33 -- 57600bps, RTS/CTS -- USR Courier V.34 -- V.34+V.42,
  10012.   31200bps -- USR V.34+ Rackmount -- 57600bps, RTS/CTS -- Cisco terminal
  10013.   server -- Solaris 2.5.1.  Packet size = 8000, Window Size = 30, Control
  10014.   Character Unprefixing Minimal (but including the Cisco escape character).
  10015.  
  10016. Since this is not a truly reliable connection, a few trials failed when a bad
  10017. packet was received (most likely due to UART overruns); the failure was
  10018. graceful and immediate, and the message was informative.  The results of ten
  10019. successful trials uploading and downloading the two files with and without
  10020. streaming are:
  10021.  
  10022.             Streaming..
  10023.             Off    On
  10024.    Upload   5194   5565   txt (= C source code, 78K)
  10025.             3135   3406   gz  (= gzip file, compressed, 85K)
  10026.  Download   5194   5565   txt
  10027.             3041   3406   gz
  10028.  
  10029. Each CPS figure is the mean of 10 results.
  10030.  
  10031. A brief test was also performed on a LAT-based dialout connection from a VAX
  10032. 3100 with VMS 5.5 to a USR Courier V.34 connected to a DECserver 700 at 19200
  10033. bps.  The 1-MB Sparc executable downloaded from a Sun to the VAX at 1100cps
  10034. without streaming and 1900cps with streaming, using 8000-byte packets, 30
  10035. window slots, and minimal prefixing in both cases.
  10036.  
  10037. 4.20.2.5. Streaming on X.25 Connections
  10038.  
  10039. We have only limited access to X.25 networks.  One trial was performed in
  10040. which the 1MB Solaris 2.4 Sparc executable was transferred over a SunLink X.25
  10041. connection; nothing is known about the actual physical connection.  With a
  10042. packet length of 8000 and a window size of 30, the file transferred at 6400
  10043. cps (using a maximum of 6 window slots).  With the same packet length, but
  10044. with streaming, it transferred without mishap at 6710 cps, about 5% faster.
  10045.  
  10046. 4.20.3. Streaming - Preliminary Conclusions
  10047.  
  10048. The results vary with the particular connection, but are good overall.
  10049. Although numerous lower-level tricks can be used to improve performance on
  10050. specific platforms or connection methods, streaming occurs at a high,
  10051. system-independent level of the Kermit protocol and therefore can apply to all
  10052. types of platforms and (reliable) connections transparently.
  10053.  
  10054. 4.21. The TRANSMIT Command
  10055.  
  10056. Prior to C-Kermit 7.0, the TRANSMIT command transmitted in text or binary
  10057. mode according to SET FILE TYPE { TEXT, BINARY }.  But now that binary mode
  10058. is likely to be the default for protocol transfers, it is evident that this
  10059. not also an appropriate default for TRANSMIT, since binary-mode TRANSMIT is
  10060. a rather specialized and tricky operation.  Therefore, TRANSMIT defaults to
  10061. text mode always, regardless of the FILE TYPE setting.
  10062.  
  10063. C-Kermit 7.0 expands the capabilities of the TRANSMIT command by adding the
  10064. following switches (see Section 1.5).  The new syntax is:
  10065.  
  10066.   TRANSMIT [ switches... ] filename
  10067.  
  10068. Zero or more switches may be included:
  10069.  
  10070. /PIPE
  10071.   When /PIPE is included, "filename" is interpreted as a system command
  10072.   or program whose output is to be sent.  Synonym: /COMMAND.  Example:
  10073.  
  10074.     transmit /pipe finger
  10075.  
  10076.   You may enclose the command in braces, but you don't have to:
  10077.  
  10078.     xmit /pipe {ls -l | sort -r +0.22 -0.32 | head}
  10079.  
  10080. /BINARY
  10081.   Transmits the file (or pipe output) in binary mode.
  10082.  
  10083. /TEXT
  10084.   Transmits the file (or pipe output) in line-oriented text mode.
  10085.   Current FILE CHARACTER-SET and TERMINAL CHARACTER-SET selections govern
  10086.   translation.  Default.
  10087.  
  10088. /TRANSPARENT
  10089.   Specifies text mode without character-set translation, no matter what the
  10090.   FILE and TERMINAL CHARACTER-SET selections are.
  10091.  
  10092. /NOWAIT
  10093.   This is equivalent to SET TRANSMIT PROMPT 0, but for this TRANSMIT command
  10094.   only.  Applies only to text mode; it means to not wait for any kind of
  10095.   echo or turnaround character after sending a line before sending the next
  10096.   line.  (Normally Kermit waits for a linefeed.)
  10097.  
  10098. When TRANSMIT ECHO is ON, C-Kermit tries to read back the echo of each
  10099. character that is sent.  Prior to C-Kermit 7.0, 1 second was allowed for each
  10100. echo to appear; if it didn't show up in a second, the TRANSMIT command would
  10101. fail.  Similarly for the TRANSMIT PROMPT character.  However, with today's
  10102. congested Internet connections, etc, more time is often needed:
  10103.  
  10104. SET TRANSMIT TIMEOUT <number>
  10105.   Specifies the number of seconds to wait for an echo or the prompt character
  10106.   when TRANSMIT PROMPT is nonzero; the default wait is 1 second.  If you
  10107.   specify 0, the wait is indefinite.  When a timeout interval of 0 is
  10108.   specified, and a desired echo or prompt does not show up, the TRANSMIT
  10109.   command will not terminate until or unless you interrupt it with Ctrl-C;
  10110.   use SET TRANSMIT TIMEOUT 0 with caution.
  10111.  
  10112. Note: to blast a file out the communications connection without any kind of
  10113. synchronization or timeouts or other manner of checking, use:
  10114.  
  10115.   SET TRANSMIT ECHO OFF
  10116.   SET TRANSMIT PROMPT 0 (or include the /NOWAIT switch)
  10117.   SET TRANSMIT PAUSE 0
  10118.   TRANSMIT [ switches ] <filename>
  10119.  
  10120. In this case, text-file transmission is not-line oriented and large blocks
  10121. can be sent, resulting in a significant performance improvement over
  10122. line-at-at-time transmission.  Successful operation depends (even more than
  10123. usual for the TRANSMIT command!) on a clean connection with effective flow
  10124. control.
  10125.  
  10126. For details on TRANSMIT and character sets, see Section 6.6.5.4.
  10127.  
  10128. 4.22. Coping with Faulty Kermit Implementations
  10129.  
  10130. Kermit protocol has been implemented in quite a few third-party commercial,
  10131. shareware, and freeware software packages, with varying degrees of success.
  10132. In most cases operation is satisfactory but slow -- only the bare minimum
  10133. subset of the protocol is available -- short packets, no sliding windows,
  10134. no attributes, etc.  In other cases, the implementation is incorrect,
  10135. resulting in failures at the initial negotiation stage or corrupted files.
  10136.  
  10137. C-Kermit 7.0 and Kermit 95 1.1.18 include some new defense mechanisms to
  10138. help cope with the most common situations.  However, bear in mind there is
  10139. only so much we can do in such cases -- the responsibility for fixing the
  10140. problem lies with the maker of the faulty software.
  10141.  
  10142. 4.22.1. Failure to Accept Modern Negotiation Strings
  10143.  
  10144. The published Kermit protocol specification states that new fields can be
  10145. added to the parameter negotiation string.  These are to be ignored by any
  10146. Kermit implementation that does not understand them; this is what makes the
  10147. Kermit protocol extensible.  Unfortunately, some Kermit implementations become
  10148. confused (or worse) when receiving a negotiation string longer than the one
  10149. they expect.  You can try working around such problems by telling Kermit to
  10150. shorten its negotiation string (and thus disable the corresponding new
  10151. features):
  10152.  
  10153.   SET SEND NEGOTIATION-STRING-MAX-LENGTH number
  10154.  
  10155. Try a number like 10.  If that doesn't work, try 9, 8, 7, 6, and so on.
  10156.  
  10157. 4.22.2. Failure to Negotiate 8th-bit Prefixing
  10158.  
  10159. The published Kermit protocol specification states that 8th-bit prefixing
  10160. (which allows transfer of 8-bit data over a 7-bit connection) occurs if the
  10161. file sender puts a valid prefix character (normally "&") in the 8th-bit-prefix
  10162. field of the negotiation string, and the receiver puts either a letter "Y" or
  10163. the same prefix character.  At least one faulty Kermit implementation exists
  10164. that does not accept the letter "Y".  To force C-Kermit / K-95 to reply with
  10165. the other Kermit's prefix character rather than a "Y", give the following
  10166. (invisible) command:
  10167.  
  10168.   SET Q8FLAG ON
  10169.  
  10170. Use SET Q8FLAG OFF to restore the normal behavior.
  10171.  
  10172. 4.22.3. Corrupt Files
  10173.  
  10174. Refer to Section 4.22.2.  Some Kermit implementations mistakenly interpret the
  10175. "Y" as a prefix character.  Then, whenever a letter Y appears in the data, the
  10176. Y and the character that follows it are replaced by a garbage character.  At
  10177. this writing, we are not sure if there is any solution, but try "set send
  10178. negotiation-string-max-length 6" and/or "set q8flag on".
  10179.  
  10180. File corruption can also occur when control characters within the file data
  10181. are sent without prefixing, as at least some are by default in C-Kermit 7.0
  10182. and K-95.  Some Kermit implementations do not handle incoming "bare" control
  10183. characters.  To work around, "set prefixing all".
  10184.  
  10185. 4.22.4. Spurious Cancellations
  10186.  
  10187. The Kermit protocol specification states that if an ACK to a Data packet
  10188. contains X in its data field, the transfer of the current file is canceled,
  10189. and if it contains a Z, the entire transfer is canceled.  At least one
  10190. overzealous Kermit implementation applies this rule to non-Data packets as
  10191. well, the typical symptom being that any attempt to transfer a file whose name
  10192. begins with X or Z results in cancellation.  This is because the file receiver
  10193. typically sends back the name under which it stored the file (which might not
  10194. be the same as the name it was sent with) in the ACK to the File Header
  10195. packet.  This is information only and should not cause cancellation.  To work
  10196. around the problem, use:
  10197.  
  10198.   SET F-ACK-BUG { ON, OFF }
  10199.  
  10200. ON tells Kermit not to send back the filename in the ACK to the file header
  10201. packet as it normally would do (OFF puts Kermit back to normal after using ON).
  10202.  
  10203. A variation on the this bug occurs in an obscure Kermit program for MUMPS:
  10204. When this Kermit program sends a file called (say) FOO.BAR, it requires that
  10205. the ACK to its F packet contain exactly the same name, FOO.BAR.  However,
  10206. C-Kermit likes to send back the full pathname, causing the MUMPS Kermit to
  10207. fail.  SET F-ACK-BUG ON doesn't help here.  So a separate command has been
  10208. added to handle this situation:
  10209.  
  10210.   SET F-ACK-PATH { ON, OFF }
  10211.  
  10212. Normally it is ON (regardless of the SET SEND PATHNAMES setting).  Use
  10213. SET F-ACK-PATH OFF to instruct Kermit to send back only the filename without
  10214. the path in the ACK to the F packet.
  10215.  
  10216. 4.22.5. Spurious Refusals
  10217.  
  10218. Some Kermit implementations, notably PDP-11 Kermit 3.60 and earlier, have bugs
  10219. in their handling of Attribute packets that can cause unwarranted refusal of
  10220. incoming files, e.g. based on date or size.  This can be worked around by
  10221. telling one or both of the Kermit partners to:
  10222.  
  10223.   SET ATTRIBUTES OFF
  10224.  
  10225. 4.22.6. Failures during the Data Transfer Phase
  10226.  
  10227. This can be caused by control-character unprefixing (Section 4.22.3), and
  10228. fixed by:
  10229.  
  10230.   SET PREFIXING ALL
  10231.  
  10232. It can also have numerous other causes, explained in Chapter 10 of "Using
  10233. C-Kermit": the connection is not 8-bit transparent (so use "set parity space"
  10234. or somesuch), inadequate flow control, etc.  Consult the manual.
  10235.  
  10236. 4.22.7. Fractured Filenames
  10237.  
  10238. At least one well-known PC-based communications package negotiates data
  10239. compression, which (according to the protocol specification) applies to both
  10240. the filename and the file data, but then fails to decompress the filename.
  10241. Example: C-Kermit sends a file called R000101.DAT (where 000101 might be
  10242. non-Y2K-wise YYMMDD notation), and the package in question stores the files
  10243. as R~#0101.DAT.  Workaround: Tell C-Kermit to SET REPEAT COUNTS OFF.
  10244.  
  10245. 4.22.8. Bad File Dates
  10246.  
  10247. At least one well-known PC-based communications package negotiates the
  10248. passing of file timestamps from sender to receiver, but when it is sending
  10249. files, it always gives them a timestamp of 1 February 1970.  Workaround:
  10250. tell C-Kermit to SET ATTRIBUTE DATE OFF.  You don't get the file's real date,
  10251. but you also don't get 1 Feb 1970; instead the file gets the current date
  10252. and time.
  10253.  
  10254. 4.23. File Transfer Recovery
  10255.  
  10256. Prior to C-Kermit 7.0, RESEND (SEND /RECOVER) and REGET (GET /RECOVER) refused
  10257. to work if FILE TYPE was not BINARY or the /BINARY switch was not included.
  10258. Now these commands include an implied /BINARY switch, meaning they set the
  10259. file type to binary for the duration of the command automatically.
  10260.  
  10261. In the client/server arrangement, this also forces the server into binary
  10262. mode (if it is C-Kermit 7.0 or greater, or K95 1.1.18 or greater) so the
  10263. recovery operation proceeds, just as you asked and expected.
  10264.  
  10265. BUT...  Just as before, the results are correct only under the following
  10266. conditions:
  10267.  
  10268.  . If the prior interrupted transfer was also in binary mode; or:
  10269.  
  10270.  . If the prior transfer was in text mode and the other computer was
  10271.    a "like platform" (e.g. UNIX-to-UNIX, Windows-to-Windows, DOS-to-Windows)
  10272.    AND there was no character-set translation (i.e. TRANSFER CHARACTER-SET
  10273.    was TRANSPARENT).
  10274.  
  10275. Note that these circumstances are more likely to obtain in C-Kermit 7.0,
  10276. in which:
  10277.  
  10278.  . The default FILE TYPE in C-Kermit 7.0 is BINARY.
  10279.  
  10280.  . The default FILE INCOMPLETE setting is AUTO, which means KEEP if the
  10281.    transfer is in binary mode, DISCARD otherwise.
  10282.  
  10283.  . C-Kermit 7.0, Kermit 95 1.1.17, and MS-DOS Kermit 3.15 and later can
  10284.    recognize "like platforms" and switch into binary mode automatically.
  10285.    Transfers between like platforms are always binary unless character-set
  10286.    translation has been requested, and then is still binary for all files
  10287.    whose names match a binary pattern, unless the automatic mechanisms
  10288.    have been disabled (with a /TEXT switch, or with SET TRANSFER MODE
  10289.    MANUAL).
  10290.  
  10291.  . SEND /BINARY and GET /BINARY always force binary-mode transfers,
  10292.    even when FILE TYPE is TEXT, even when TRANSFER MODE is AUTOMATIC,
  10293.    even when PATTERNS are ON and the file's name matches a text pattern.
  10294.  
  10295. But also note that the automatic client/server transfer-mode adjustments
  10296. do not work with versions of C-Kermit prior to 7.0 or K95 prior to 1.1.16.
  10297.  
  10298. If the prior transfer was in text mode:
  10299.  
  10300.  . If text-mode transfers between the two platforms are "length-changing"
  10301.    (as they are between UNIX -- which terminates text lines with LF -- and
  10302.    DOS or Windows -- which terminates text lines with CRLF), the recovered
  10303.    file will be corrupt.
  10304.  
  10305.  . If text-mode transfers between the two platforms are not length-changing,
  10306.    but character-set translation was active in the prior transfer, the result
  10307.    will be a file in which the first part has translated characters and the
  10308.    second part does not.
  10309.  
  10310. But in C-Kermit 7.0 and K95 1.1.18 and later, incompletely transferred text
  10311. files are not kept unless you change the default.  But if you have done this,
  10312. and you have an incompletely transferred text file, you'll need to:
  10313.  
  10314.  . Transfer the whole file again in text mode, or:
  10315.  
  10316.  . Use SEND /STARTING-AT: to recover the transfer at the correct point;
  10317.    but you have to find out what that point is, as described in the
  10318.    manual.
  10319.  
  10320. Kermit has no way of knowing whether the previous transfer was in text or
  10321. binary mode so it is your responsibility to choose the appropriate recovery
  10322. method.
  10323.  
  10324. If you use C-Kermit to maintain parallel directories on different computers,
  10325. using SET FILE COLLISION to transfer only those files that changed since last
  10326. time, and the files are big enough (or the connection slow enough) to require
  10327. SEND /RECOVER to resume interrupted transfers, you should remember that SEND
  10328. /RECOVER (RESEND) overrides all FILE COLLISION settings.  Therefore you
  10329. should use SEND /RECOVER (RESEND) only on the file that was interrupted, not
  10330. the file group.  For example, if the original transfer was initiated with:
  10331.  
  10332.   SEND *
  10333.  
  10334. and was interrupted, then after reestablishing your connection and starting
  10335. the Kermit receiver with SET FILE COLLISION UPDATE on the remote end, use the
  10336. following sequence at the sender to resume the transfer:
  10337.  
  10338.   SEND /RECOVER <name-of-interrupted-file>
  10339.  
  10340. and then:
  10341.  
  10342.   SEND *
  10343.  
  10344. (In C-Kermit 7.0 and later, \v(filename) contains the name of the file
  10345. most recently transferred, as long you have not EXITed from Kermit or
  10346. changed directory, etc.
  10347.  
  10348. 4.24. FILE COLLISION UPDATE Clarification
  10349.  
  10350. In UNIX, file modification dates are used when comparing the file date with
  10351. the date in the attribute packet.  In VMS, however, the file creation date
  10352. is used.  These two policies reflect the preferences of the two user
  10353. communities.
  10354.  
  10355. Also, remember that the file date/time given in the attribute packet is the
  10356. local time at the file sender.  At present, no timezone conversions are
  10357. defined in or performed by the Kermit protocol.  This is primarily because
  10358. this feature was designed at a time when many of the systems where Kermit runs
  10359. had no concept of timezone, and therefore would be unable to convert (say,
  10360. to/from GMT or UTC or Zulu time).
  10361.  
  10362. As a consequence, some unexpected results might occur when transferring files
  10363. across timezones; e.g. commands on the target system that are sensitive to
  10364. file dates might work (UNIX "make", backups, etc).
  10365.  
  10366. Timezone handling is deferred for a future release.
  10367.  
  10368. 4.25. Autodownload Improvements
  10369.  
  10370. Refer to pages 164-165 of "Using C-Kermit" about the hazards of autodownload
  10371. when C-Kermit is "in the middle".  As of C-Kermit 7.0, no more hazards.  If
  10372. C-Kermit has TERMINAL AUTODOWNLOAD ON and it detects a packet of the current
  10373. protocol type (Kermit or Zmodem), it "erases" the visual aspect of the packet
  10374. that would be seen by the terminal (or, more to the point, the emulator, such
  10375. as K95).  This way, only C-Kermit goes into RECEIVE mode, and not also the
  10376. terminal emulator through which C-Kermit is accessed.  And therefore, it is no
  10377. longer necessary to SET TERMINAL AUTODOWNLOAD OFF to prevent multiple Kermits
  10378. from going into receive mode at once, but of course it is still necessary to
  10379. ensure that, when you have multiple Kermits in a chain, that the desired one
  10380. receives the autodownload.
  10381.  
  10382. The defaults have not been changed; Kermit 95 still has autodownload ON by
  10383. default, and C-Kermit has it OFF by default.
  10384.  
  10385.  
  10386. (5) CLIENT/SERVER
  10387.  
  10388. 5.0. Hints
  10389.  
  10390. If you use SET SERVER GET-PATH to set up your server, and the GET-PATH does
  10391. not include the server's current directory, clients can become quite confused.
  10392. For example, "remote dir oofa.txt" shows a file named oofa.txt, but "get
  10393. oofa.txt" fails.  In this situation, you should either DISABLE DIR or make
  10394. your GET-PATH include the current directory.
  10395.  
  10396. 5.1. New Command-Line Options
  10397.  
  10398. The -G command-line option is like -g (GET), except the incoming file is
  10399. sent to standard output rather than written to disk.
  10400.  
  10401. The -I option ("Internet") is used to tell a remote C-Kermit program that you
  10402. are coming in  via Internet Telnet or Rlogin and therefore have a reliable
  10403. connection.  The -I option is equivalent to SET RELIABLE ON and SET FLOW
  10404. NONE.
  10405.  
  10406. The -O option ("Only One") tells C-Kermit to enter server mode but then exit
  10407. after the first client operation.
  10408.  
  10409. See section 9.3 for details.
  10410.  
  10411. 5.2. New Client Commands
  10412.  
  10413. BYE and FINISH no longer try to do anything if a connection is not active.
  10414. Thus a sequence like "hangup" followed by "bye" or "finish" will no longer get
  10415. stuck in a long timeout-and-retransmission cycle, nor will it try to open a
  10416. new connection.
  10417.  
  10418. REMOTE EXIT
  10419.   Similar to FINISH, except it ensures that the Kermit server program exits
  10420.   back to the operating system or shell prompt.  (FINISH would return it to
  10421.   its interactive prompt if it was started in interactive mode, and would
  10422.   cause it to exit if it entered server mode via command-line option.)  When
  10423.   C-Kermit is to be the server, you can use { ENABLE, DISABLE } EXIT to
  10424.   control the client's access to this feature.
  10425.  
  10426. REMOTE MKDIR <directory-name>
  10427.   Tells the client to ask the server to create a directory with the given
  10428.   name, which can be absolute or relative.  The syntax of the directory name
  10429.   depends on the Kermit server (see next section); in all cases, it can be in
  10430.   the syntax of the system where the server is running (UNIX, VMS, DOS, etc)
  10431.   but newer servers also accept UNIX syntax, no matter what the underlying
  10432.   platform.  The server will not execute this command if (a) it does not
  10433.   understand it, (b) a DISABLE MKDIR command has been given, or (c) a DISABLE
  10434.   CWD command has been given; otherwise, the command is executed, but will
  10435.   fail if the directory can not be created, in which cases most servers will
  10436.   attempt to return a message giving the reason for failure.  The REMOTE MKDIR
  10437.   command succeeds if the remote directory is created, or if it already exists
  10438.   and therefore does not need to be created, and fails otherwise.
  10439.  
  10440. REMOTE RMDIR <directory-name>
  10441.   Tells the client to ask the server to remove (delete) a directory with the
  10442.   given name.  The same considerations apply as for REMOTE MKDIR.
  10443.  
  10444. REMOTE SET FILE INCOMPLETE { DISCARD, KEEP, AUTO }
  10445.   Previously this was only available in its earlier form, REMOTE SET
  10446.   INCOMPLETE (no FILE).  The earlier form is still available, but invisible.
  10447.   Also, AUTO was added, meaning KEEP if in binary mode, DISCARD otherwise.
  10448.  
  10449. REMOTE SET TRANSFER MODE { AUTOMATIC, MANUAL }
  10450.   Tells the client to ask the server to set the given file-transfer mode.
  10451.   Automatic means (roughly): if the client and the server are running on the
  10452.   same kind of computer (e.g. both are on UNIX), then use binary mode
  10453.   automatically; if the system types are different, use some other method
  10454.   to automatically determine text or binary mode, such as filename pattern
  10455.   matching.  MANUAL means, in this context, obey the client's FILE TYPE
  10456.   setting (TEXT or BINARY).  Synonym: REMOTE SET XFER MODE ...
  10457.  
  10458. [ REMOTE ] QUERY KERMIT function(args...)
  10459.   Prior to C-Kermit 7.0, the arguments were not evaluated locally.  Thus it
  10460.   was not possible to have the server run the function with client-side
  10461.   variables as arguments.  Now:
  10462.     define \%a oofa.*
  10463.     remote query kermit files(\%a)    ; Client's \%a
  10464.     remote query kermit files(\\%a)   ; Server's \%a
  10465.  
  10466. [ REMOTE ] LOGIN [ <user> [ <password ] ]
  10467.   LOGIN is now a synonym for REMOTE LOGIN.
  10468.  
  10469. LOGOUT
  10470.   This command, when given in local mode, is equivalent to REMOTE LOGOUT.
  10471.   When given at the IKSD prompt, it logs out the IKSD.  When given at the
  10472.   C-Kermit prompt when it has no connection, it does nothing.
  10473.  
  10474. Note that in C-Kermit 7.0, the REMOTE (or R) prefix is not required for QUERY,
  10475. since there is no local QUERY command.  The new top-level QUERY command does
  10476. exactly what REMOTE QUERY (RQUERY) does.
  10477.  
  10478. All REMOTE commands now have single-word shortcuts:
  10479.  
  10480.  Shortcut   Full Form
  10481.   RASG       REMOTE ASSIGN
  10482.   RCD        REMOTE CD
  10483.   RCOPY      REMOTE COPY
  10484.   RDEL       REMOTE DELETE
  10485.   RDIR       REMOTE DIRECTORY
  10486.   REXIT      REMOTE EXIT
  10487.   RHELP      REMOTE HELP
  10488.   RHOST      REMOTE HOST
  10489.   RPWD       REMOTE PWD
  10490.   RSET       REMOTE SET
  10491.   etc.
  10492.  
  10493. The R prefix is not applied to LOGIN because there is already an RLOGIN
  10494. command with a different meaning.  It is not applied to LOGOUT either, since
  10495. LOGOUT knows what to do in each case, and for symmetry with LOGIN.
  10496.  
  10497. 5.2.1. Remote Procedure Definitions and Calls
  10498.  
  10499. This is nothing new, but it might not be obvious...  REMOTE ASSIGN and REMOTE
  10500. QUERY may be used to achieve remote procedure execution.  The remote procedure
  10501. can be defined locally or remotely.
  10502.  
  10503. A remote procedure call is accomplished as noted in the previous section:
  10504.  
  10505.   [ remote ] query kermit function-name(args...)
  10506.  
  10507. This invokes any function that is built in to the Kermit server, e.g.:
  10508.  
  10509.   [ remote ] query kermit size(foo.bar)
  10510.  
  10511. returns the size of the remote file, foo.bar.
  10512.  
  10513. Now note that C-Kermit includes an \fexecute() function, allowing it to
  10514. execute any macro as if it were a built-in function.  So suppose MYMACRO
  10515. is the name of a macro defined in the server.  You can execute it from
  10516. the client as follows (the redundant "remote" prefix is omitted in the
  10517. remaining examples):
  10518.  
  10519.   query kermit execute(mymacro arg1 arg2...)
  10520.  
  10521. The return value, if any, is the value of the RETURN command that terminated
  10522. execution of the macro, for example:
  10523.  
  10524.   define addtwonumbers return \feval(\%1+\%2)
  10525.  
  10526. The client invocation would be:
  10527.  
  10528.   query kermit execute(addtwonumbers 3 4)
  10529.   7
  10530.  
  10531. The result ("7" in this case) is also assigned to the client's \v(query)
  10532. variable.
  10533.  
  10534. To execute a remote system command or command procedure (shell script, etc)
  10535. use:
  10536.  
  10537.   query kermit command(name args...)
  10538.  
  10539. Finally, suppose you want the client to send a macro to the server to be
  10540. executed on the server end.  This is done as follows:
  10541.  
  10542.   remote assign macroname definition
  10543.   query kermit execute(macroname arg1 arg2...)
  10544.  
  10545. Quoting is required if the definition contains formal parameters.
  10546.  
  10547. 5.3. New Server Capabilities
  10548.  
  10549. 5.3.1. Creating and Removing Directories
  10550.  
  10551. The C-Kermit 7.0 server responds to REMOTE MKDIR and REMOTE RMDIR commands.
  10552. The directory name may be in either the native format of the server's
  10553. computer, or in UNIX format.  For example, a server running on VMS with a
  10554. current directory of [IVAN] can accept commands from the client like:
  10555.  
  10556.   remote mkdir olga         ; Makes [IVAN.OLGA] (nonspecific format)
  10557.   remote mkdir .olga        ; Makes [IVAN.OLGA] (VMS format without brackets)
  10558.   remote mkdir olga/        ; Makes [IVAN.OLGA] (UNIX relative format)
  10559.   remote mkdir /ivan/olga   ; Makes [IVAN.OLGA] (UNIX absolute format)
  10560.   remote mkdir [ivan.olga]  ; Makes [IVAN.OLGA] (VMS absolute format)
  10561.   remote mkdir [.olga]      ; Makes [IVAN.OLGA] (VMS relative format)
  10562.  
  10563. 5.3.1.1. Creating Directories
  10564.  
  10565. If a directory name is given that contains more than one segment that does not
  10566. exist, the server attempts to create all the segments.  For example, if the
  10567. client says:
  10568.  
  10569.   REMOTE MKDIR letters/angry
  10570.  
  10571. a "letters" subdirectory is created in the server's current directory if it
  10572. does not already exist, and then an "angry" subdirectory is created beneath
  10573. it, if it does not already have one.  This can repeated to any reasonable
  10574. depth:
  10575.  
  10576.   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
  10577.  
  10578. 5.3.1.2. Removing Directories
  10579.  
  10580. When attempting to execute a REMOTE RMDIR, the server can remove only a single
  10581. directory, not an entire sequence or tree.  The system service that is called
  10582. to remove the directory generally requires not only that the server process
  10583. has write delete access, but also that the directory contain no files.
  10584.  
  10585. In the future, a REMOTE RMDIR /RECURSIVE command (and the accompanying
  10586. protocol) might be added.  For now, use the equivalent REMOTE HOST command(s),
  10587. if any.
  10588.  
  10589. 5.3.2. Directory Listings
  10590.  
  10591. Directory listings are generated by C-Kermit itself, rather than by running
  10592. the underlying system's directory command.  Some control over the listing
  10593. format can be obtained with the SET OPTIONS DIRECTORY command (Section 4.5.1).
  10594. The following options affect listings sent by the server: /[NO]HEADING,
  10595. /[NO]DOTFILES, and /[NO]BACKUP.  In UNIX and VMS, the listing is always sorted
  10596. by filename.  There is, at present, no protocol defined for the client to
  10597. request listing options of the server; this might be added in the future.
  10598.  
  10599. The server's directory listings are in the following format:
  10600.  
  10601. Protection or permissions:
  10602.   In UNIX and OS-9, this is a 10-character field, left adjusted.  In VMS it
  10603.   is a 22-character field, left-adjusted.  In each case, the protection /
  10604.   permission codes are shown in the server platform's native format.  In
  10605.   other operating systems, this field is not shown.
  10606.  
  10607. Size in bytes:
  10608.   This is always a 10-character field.  The file's size is shown as a decimal
  10609.   number, right adjusted in the field.  If the file is a directory and its
  10610.   size can not be obtained, the size is shown as "<DIR>".  Two blanks follow
  10611.   this field.
  10612.  
  10613. Date:
  10614.   Always in yyyy-mm-dd hh:mm:ss numeric format, and therefore 19 characters
  10615.   long.   If the file's date/time can't be obtained, zeros (0) are shown for
  10616.   all the digits.  This field is followed by two blanks.
  10617.  
  10618. Filename:
  10619.   This field extends to the end of the line.  Filenames are shown relative
  10620.   to the server's current directory.  In UNIX, symbolic links are shown as
  10621.   they are in an "ls -l" listing as "linkname -> filename".
  10622.  
  10623. In UNIX and VMS, listings are returned by the server in alphabetical order of
  10624. filename.  There are presently no other sort or selection options.
  10625.  
  10626. However, since these are fixed-field listings, all fields can be used as
  10627. sort keys by external sort programs.  Note, in particular, that the format
  10628. used for the date allows a normal lexical on that field to achieve the date
  10629. ordering.  For example, let's assume we have a UNIX client and a UNIX server.
  10630. In this case, the server's listing has the date in columns 22-40, and thus
  10631. could be sorted by the UNIX sort program using "sort +0.22 -0.40" or in
  10632. reverse order by "sort +0.22 -0.40r".
  10633.  
  10634. Since the UNIX client can pipe responses to REMOTE commands through filters,
  10635. any desired sorting can be accomplished this way, for example:
  10636.  
  10637.   C-Kermit> remote directory | sort +0.22 -0.40
  10638.  
  10639. You can also sort by size:
  10640.  
  10641.   C-Kermit> remote directory | sort +0.11 -0.19
  10642.  
  10643. You can use sort options to select reverse or ascending order.  "man sort"
  10644. (in UNIX) for more information.  And of course, you can pipe these listings
  10645. through any other filter of your choice, such as grep to skip unwanted lines.
  10646.  
  10647. 5.4. Syntax for Remote Filenames with Embedded Spaces
  10648.  
  10649. C-Kermit and K95, when in server mode, assume that any spaces in the file
  10650. specification in an incoming GET command are filename separators.  Thus if
  10651. the client gives a command like:
  10652.  
  10653.   get {oofa.txt oofa.bin}
  10654.  
  10655. or, equivalently:
  10656.  
  10657.   mget oofa.txt oofa.bin
  10658.  
  10659. the server tries to send the two files, oofa.txt and oofa.bin.  But what if
  10660. you want the server to send you a file named, say:
  10661.  
  10662.   D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL
  10663.  
  10664. How does the server know this is supposed to be one file and not seven?
  10665. In this case, you need to the send file name to the server enclosed in either
  10666. curly braces:
  10667.  
  10668.   {D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}
  10669.  
  10670. or ASCII doublequotes:
  10671.  
  10672.   "D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL"
  10673.  
  10674. The method for doing this depends on your client.  If your client is C-Kermit
  10675. 7.0, any recent version of Kermit 95, or MS-DOS Kermit 3.16, then you have
  10676. to enclose the name in braces just so the client can parse it, so to send
  10677. braces or doublequotes to the server, you must put them inside the first,
  10678. outside pair of braces.  And you also need to double the backslashes to
  10679. prevent them from being interpreted:
  10680.  
  10681.   get {{D:\\HP OfficeJet 500\\Images\\My Pretty Picture Dot PCL}}
  10682.   get {"D:\\HP OfficeJet 500\\Images\\My Pretty Picture Dot PCL"}
  10683.  
  10684. To get around the requirement to double backslashes in literal filenames,
  10685. of course you can also use:
  10686.  
  10687.   set command quoting off
  10688.   get {{D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}}
  10689.   get {"D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL"}
  10690.   set command quoting on
  10691.  
  10692. If you are giving a "kermit" command to the UNIX shell, you have to observe
  10693. the shell's quoting rules, something like this:
  10694.  
  10695.   kermit -ig "{D:\HP OfficeJet 500\Images\My Pretty Picture Dot PCL}"
  10696.  
  10697. Here, the quotes go on the outside so UNIX will pass the entire filename,
  10698. spaces, braces, and all, as a single argument to Kermit, and the backslashes
  10699. are not doubled because (a) the UNIX shell ignores them since they are in a
  10700. quoted string, and (b) Kermit ignores them since the interactive command parser
  10701. is not activated in this case.
  10702.  
  10703. 5.5. Automatic Orientation Messages upon Directory Change
  10704.  
  10705. C-Kermit 7.0, when acting as a server, can send an orientation message to
  10706. the client whenever the server directory changes.  For example, when the
  10707. client gives a REMOTE CD command, the server sends the contents of the
  10708. new directory's "Read Me" file to the client's screen.  The following commands
  10709. govern this feature:
  10710.  
  10711. SET SERVER CD-MESSAGE FILE <name>
  10712.   Given to the servr, allows the message-file name to be specified at runtime.
  10713.   A list of names to look for can be given in the following format:
  10714.  
  10715.     {{name1}{name2}{name3}{...}}
  10716.  
  10717.   e.g. SET SERVER CD-MESSAGE FILE {{./.readme}{README.TXT}{READ.ME}}
  10718.  
  10719. REMOTE SET SERVER CD-MESSAGE { ON, OFF }
  10720.   Given to the client, lets the client control whether the server sends
  10721.   automatic CD messages.
  10722.  
  10723. SHOW SERVER
  10724.   Given to server, includes CD-Message status.
  10725.  
  10726. The default CD message file name is system dependent.  SHOW CD or SHOW SERVER
  10727. displays the list.  Also see Section 4.5.2.
  10728.  
  10729. 5.6. New Server Controls
  10730.  
  10731. DISABLE ENABLE
  10732.   Allows the server to configured such that DISABLEd features can not be
  10733.   re-enabled by any means -- e.g. if the client is somehow able to get the
  10734.   server into command mode.  Once DISABLEd, ENABLE can not be re-ENABLEd.
  10735.  
  10736. SET SERVER IDLE-TIMEOUT <seconds>
  10737.   This was available previously in Kermit 95 only.  Now it can be used in
  10738.   C-Kermit also to specify a maximum number of seconds the server is allowed
  10739.   to be idle before exiting server mode.  0 seconds means no idle timeout.
  10740.   In C-Kermit (but not K-95), SET SERVER TIMEOUT and SET SERVER IDLE-TIMEOUT
  10741.   are mutually exclusive -- you can have one or the other (or neither), but
  10742.   not both.  (Server timeouts are for the benefit of primitive Kermit clients
  10743.   that are not capable of timing out on their own; to our knowledge, no such
  10744.   clients are still in circulation.)
  10745.  
  10746. SET SERVER KEEPALIVE { ON, OFF }
  10747.   (See next section).
  10748.  
  10749. 5.7. Timeouts during REMOTE HOST Command Execution
  10750.  
  10751. Prior to C-Kermit 7.0, the C-Kermit server would block waiting for output
  10752. from a system command invoked via REMOTE HOST from the client.  If the system
  10753. command took a long time to execute, the client would time out and send NAK
  10754. packets.  If the command took too long, the client would reach its retry limit
  10755. and give up.  Even if it didn't, the NAKs would cause unnecessary
  10756. retransmissions.
  10757.  
  10758. In version 7.0, the C-Kermit server (VMS and select()-capable UNIX versions
  10759. only), sends "keepalive packets" (empty data packets) once per second while
  10760. waiting for the system command to complete.  This procedure should be entirely
  10761. transparent to the Kermit client, and should prevent the unwanted timeouts and
  10762. NAKs.  When C-Kermit 7.0 itself (or K95 1.1.18) is the client, it prints dots
  10763. to show the keepalive packets.
  10764.  
  10765. The keepalive feature can be turned off and on with:
  10766.  
  10767.   SET SERVER KEEPALIVE { ON, OFF }
  10768.  
  10769. Normally it should be on.  Turn it off it if causes trouble with the client,
  10770. or if it seems to slow down the server (as it might on some platforms under
  10771. certain circumstances).
  10772.  
  10773.  
  10774. (6) INTERNATIONAL CHARACTER SETS
  10775.  
  10776. Support for several new single-byte character sets was added in C-Kermit
  10777. 7.0.  Unicode / ISO 10646 is not yet supported, but is a high priority for
  10778. forthcoming releases.
  10779.  
  10780. 6.0. ISO 8859-15 Latin Alphabet 9
  10781.  
  10782. To accommodate the Euro currency symbol, and to correct several other
  10783. longstanding problems with ISO Latin Alphabet 1, ISO 8859-15 Latin Alphabet 9
  10784. was issued in May 1998.  It is supported by C-Kermit 7.0 as a transfer
  10785. character set, a file character set, and a terminal character set.
  10786. Translations that preserve the new characters are available between Latin-9
  10787. and several other sets including:
  10788.  
  10789.   PC Code Page 858         (Western European languages, similar to CP850)
  10790.   Windows Code Page 1252   (Western European languages, similar to Latin-1)
  10791.   Windows Code Page 1250   (Eastern European languages, similar to Latin-2)
  10792.  
  10793. The Latin-9 transfer character set also allows for the OE digraph character,
  10794. used primarily in French, to be preserved in transfers involving the DEC MCS
  10795. or NeXT character sets.
  10796.  
  10797. The Euro character is also present in the Universal Character Set, described
  10798. in Section 6.6.
  10799.  
  10800. 6.1. The HP-Roman8 Character Set
  10801.  
  10802. The HP-Roman8 character set is supported in C-Kermit 6.0 but was omitted from
  10803. Table VII-4 due to lack of space.  See Appendix III below.
  10804.  
  10805. 6.2. Greek Character Sets
  10806.  
  10807. Greek character sets were added in 6.1:
  10808.  
  10809.   SET FILE CHARACTER-SET { CP869, ELOT927, GREEK-ISO }
  10810.   SET TRANSFER CHARACTER-SET { GREEK-ISO }
  10811.  
  10812. GREEK-ISO is ISO 8859-7, which the same as ELOT 928.
  10813.  
  10814. The new Greek character sets are listed in Appendix III.
  10815.  
  10816. 6.3. Additional Latin-2 Character Sets
  10817.  
  10818. The following have been added as FILE and TERMINAL CHARACTER-SETs:
  10819.  
  10820. MAZOVIA-PC
  10821.   A PC code page used in Poland, equivalent to CP437, but with 18
  10822.   substitutions needed for Polish.
  10823.  
  10824. CP1250
  10825.   The Windows Latin 2 Code Page.  Equivalent to ISO 8859-2, but with
  10826.   different encoding.
  10827.  
  10828. 6.4. Additional Cyrillic Character Sets
  10829.  
  10830. The following have been added as FILE and TERMINAL CHARACTER-SETs:
  10831.  
  10832. BULGARIA-PC
  10833.   This is the Cyrillic PC code page used in Bulgaria, where it is called
  10834.   Code Page 856.  It is attributed to a company called DATEC, Inc, but CP856
  10835.   is not a proper designation, since it refers to a Hebrew Code Page (see
  10836.   the IBM Registry).
  10837.  
  10838. CP855
  10839.   This PC Code Page
  10840.   contains all the Cyrillic letters that are also in ISO 8859-5, and is
  10841.   therefore useful for non-Russian Cyrillic text (Ukrainian, Belorussian,
  10842.   etc), unlike CP866, which has a smaller repertoire of Cyrillic letters.
  10843.  
  10844. CP1251
  10845.   The Windows Cyrillic Code Page.  Equivalent to CP855, but with different
  10846.   encoding.
  10847.  
  10848. KOI8R
  10849.   An extension to "Old KOI-8" that adds upper and lower case Cyrillic letter
  10850.   Io (looks like Roman E with diaeresis) plus a selection of box-drawing
  10851.   characters to columns 8 through 11, which are vacant in original Old KOI-8.
  10852.   KOI8-R is used for the Russian language.  It is specified in RFC 1489.
  10853.  
  10854. KOI8U
  10855.   A similar extension of Old KOI-8, but for Ukrainian.  It is specified in
  10856.   RFC 2319.
  10857.  
  10858. 6.5. Automatic Character-Set Switching
  10859.  
  10860. Prior to version 7.0, C-Kermit's file character-set always had to be set
  10861. explicitly.  In 7.0 and later, it is set automatically when:
  10862.  
  10863.  a. This feature is enabled (as it is unless you disable it).
  10864.  
  10865.  b. An incoming text-mode transfer includes a transfer-character-set
  10866.     announcer and you have not previously given a SET FILE CHARACTER-SET
  10867.     command.  In this case, C-Kermit switches to an appropriate file
  10868.     character set.  For example, on an HP-UX workstation, an incoming
  10869.     Latin-1 file automatically selects HP-Roman8 for the local copy of
  10870.     the file; in Data General AOS/VS, it would select DG International.
  10871.  
  10872.  c. You give a SET TRANSFER CHARACTER-SET command without having
  10873.     previously specified a FILE CHARACTER-SET.  An appropriate file
  10874.     character-set is chosen automatically.
  10875.  
  10876. In addition, when you give a SET FILE CHARACTER-SET command, the appropriate
  10877. transfer character-set is automatically chosen, to be used when you are
  10878. sending files (but this does not override the one announced by the sender
  10879. when you are receiving files).
  10880.  
  10881. You might not agree about what is "appropriate", so of course you can disable
  10882. or change all of the above actions.
  10883.  
  10884. You can disable (or re-enable) the new automatic character-set switching
  10885. feature in each direction separately:
  10886.  
  10887. SET RECEIVE CHARACTER-SET-SELECTION { AUTOMATIC, MANUAL }
  10888.   AUTOMATIC is the default, causing the behavior described above when an
  10889.   incoming file arrives.   Choose MANUAL to defeat this behavior and force
  10890.   your current FILE CHARACTER-SET setting to be used, no matter what it is.
  10891.   Note that SET RECEIVE CHARACTER-SET MANUAL does not disable recognition
  10892.   of the incoming transfer character-set announcer, and translation from the
  10893.   corresponding character-set to your current file character-set.  To disable
  10894.   that, use SET ATTRIBUTE CHARACTER-SET OFF.
  10895.  
  10896. SET SEND CHARACTER-SET-SELECTION { AUTOMATIC, MANUAL }
  10897.   Again AUTOMATIC is the default, causing the behavior described above when
  10898.   you give a SET { FILE, TRANSFER } CHARACTER-SET command.  Use MANUAL to
  10899.   allow you to specify the transfer and file character-sets independently.
  10900.  
  10901. SHOW CHARACTER-SETS
  10902.   Tells settings of { SEND, RECEIVE } CHARACTER-SET-SELECTION.
  10903.  
  10904. Normally, however, it is more convenient to leave automatic switching active,
  10905. and change any associations that are not appropriate for your application,
  10906. area, or country.  The commands are:
  10907.  
  10908. SHOW ASSOCIATIONS
  10909.   This command lists all the associations in each direction: for each possible
  10910.   transfer character-set, it lists the associated file character-set, and
  10911.   vice versa.  These are two separate and independent lists.
  10912.  
  10913. ASSOCIATE TRANSFER-CHARACTER-SET <name1> [ <name2> ]
  10914.   Changes the association for the transfer character-set <name1> to be the
  10915.   file character-set <name2>.  If <name2> is omitted, automatic switching is
  10916.   disabled for this transfer character-set only.
  10917.  
  10918. ASSOCIATE FILE-CHARACTER-SET <name1> [ <name2> ]
  10919.   Changes the association for the file character-set <name1> to be the
  10920.   transfer character-set <name2>.  If <name2> is omitted, automatic switching
  10921.   is disabled for this file character-set only.
  10922.  
  10923. 6.6. UNICODE
  10924.  
  10925. C-Kermit 7.0 adds support for Unicode, the Universal Character Set, for:
  10926.  
  10927.  . File Transfer (SEND, RECEIVE, GET, etc)
  10928.  . Terminal connection (CONNECT)
  10929.  . Unguarded file capture (LOG SESSION)
  10930.  . Unguarded file transmission (TRANSMIT)
  10931.  . Local file character-set conversion (TRANSLATE)
  10932.  
  10933. C-Kermit is not, however, a "Unicode application" in the sense that its
  10934. commands, messages, or user interface are Unicode.  Rather, it is "Unicode
  10935. aware" in its ability to handle and convert Unicode text in the course of file
  10936. transfer and terminal connection, and you can also use Kermit to convert local
  10937. files between Unicode and other character sets.
  10938.  
  10939. TLA's:
  10940.  
  10941.   BMP - Base Multilingual Plane
  10942.   BOM - Byte Order Mark
  10943.   CJK - Chinese, Japanese, and Korean
  10944.   ISO - International Standards Organization
  10945.   TLA - Three-Letter Acronym
  10946.   UCS - Universal Character Set
  10947.   UTF - UCS Transformation Format
  10948.  
  10949. Unicode and ISO 10646 are the coordinated and compatible corporate and
  10950. international standards for the Universal Character Set (UCS).  Unlike
  10951. single-byte and even most multibyte character sets, the UCS can represent all
  10952. characters in every existing writing system.  A flat plain-text file encoded
  10953. in some form of UCS can contain any mixture of English, Spanish, Italian,
  10954. German, Hebrew, Arabic, Greek, Russian, Armenian, Georgian, Japanese, Chinese,
  10955. Korean, Vietnamese, Tibetan, Hindi, Bengali, Tamil, Thai, Ethiopic, and so on,
  10956. plus scientific and mathematical notation, as well as texts in Runes, Ogham,
  10957. Glagolitic, and other historic scripts.
  10958.  
  10959. The UCS already covers these scripts and many more, but it's an evolving
  10960. standard with efforts underway to accommodate even more languages and writing
  10961. systems.  Support is growing for native UCS use on many platforms and in many
  10962. applications.  The goal of the framers of the UCS is for it to replace ASCII,
  10963. the ISO Latin Alphabets, ISCII, VISCII, the Chinese, Japanese, and Korean
  10964. (CJK) multibyte sets, etc, as well as the many private character sets in use
  10965. today, in other words to become *the* Universal Character Set.
  10966.  
  10967. Until that time, however, conversions between existing sets and the UCS will
  10968. be necessary when moving text between platforms and applications.  Now Kermit
  10969. can help.
  10970.  
  10971. 6.6.1. Overview of Unicode
  10972.  
  10973. For a more complete picture, please visit:
  10974.  
  10975.   http://www.unicode.org/
  10976.  
  10977. and access the various online introductions, FAQs, technical reports, and
  10978. other information.  For greater depth, order the latest version of the
  10979. published Unicode Standard.  The following overview contains a great many
  10980. oversimplifications and perhaps an opinion or two.
  10981.  
  10982. At present, the UCS is a 16-bit (2-byte) character set, but with provisions to
  10983. grow to a 4-byte set.  UCS-2 refers to the two-byte set, also called the Base
  10984. Multilingual Plane (BMP), in which each character has 16 bits, and therefore
  10985. there are 2^16 = 65536 possible characters.  The first 128 characters are the
  10986. same as US ASCII (C0 control characters and DEL included), the next 32 are the
  10987. C1 control characters of ISO 6429, and the next 96 are the Right Half of ISO
  10988. 8859-1 Latin Alphabet 1.  The remaining tens of thousands of characters are
  10989. arranged newly for the UCS, usually (but not always) in sections corresponding
  10990. to existing standards, such as ISO Latin/Cyrillic, often plus additional
  10991. characters not appearing in the existing standards due to lack of space (or
  10992. other reasons).
  10993.  
  10994. ISO 10646 allows for additional planes, e.g. for Egyptian hieroglyphics or
  10995. ancient (or other esoteric) CJK characters, but these planes are not yet
  10996. defined and so we will say nothing more about them here, except that their use
  10997. will require the 4-byte form of UCS, called UCS-4, in some form (more about
  10998. "forms" in Section 6.6.2).
  10999.  
  11000. Unicode and ISO 10646 are constantly under revision, mainly to add new
  11001. characters.  The Unicode revision is denoted by a version number, such as 1.0,
  11002. 1.1, 2.0, 3.0.  The ISO 10646 standard revision is identified by Edition (such
  11003. as ISO 10646-1 1993), plus reference to any amendments.  The first versions of
  11004. these standards included encodings for Korean Hangul syllables (Jamos); these
  11005. encodings were changed in version 1.1 of Unicode and by Amendment 5 to ISO
  11006. 10646-1.  The Unicode Technical Committee and the ISO acknowledge that this
  11007. was a bad thing to do, and promise never change encodings or character names
  11008. again, since this poses serious problems for conformance and data interchange.
  11009.  
  11010. A UCS-2 value is customarily written like this:
  11011.  
  11012.   U+xxxx
  11013.  
  11014. where "xxxx" represents four hexadecimal digits, 0-9 and A-F.  For example,
  11015. U+0041 is "A", U+00C1 is A-acute, U+042F is uppercase Cyrillic "Ya", U+FB4F is
  11016. Hebrew Ligature Alef Lamed, and U+FFFD is the special character that means
  11017. "not a character".
  11018.  
  11019. Most characters from widely-used alphabetic writing systems such as the West
  11020. European ones, Cyrillic, Greek, Hebrew, Vietnamese, etc, are available in
  11021. "precomposed" form; for example Uppercase Latin Letter A with Acute Accent is
  11022. a single character (as it is in Latin-1).  However, the UCS also permits
  11023. composition of a base character with one or more nonspacing diacritics.  This
  11024. means the same character can be represented in more than one way, which can
  11025. present problems in many application areas, including transfer and
  11026. character-set conversion of text.
  11027.  
  11028. Conversion from ASCII or Latin-1 to UCS-2 text is "trivial": simply insert a
  11029. NUL (0) byte before each ASCII or Latin-1 byte.  Converting in the reverse
  11030. direction (provided the UCS-2 file contains only U+0000 to U+00FF) is equally
  11031. simple (if we ignore the issue of composition): remove every second (NUL)
  11032. byte.  Conversion of other character sets to and from UCS, however, requires
  11033. tables or algorithms specific to each set.  Nevertheless, the relatively
  11034. transparent upwards compatibility from ASCII and Latin-1, in which a very
  11035. large share of the world's textual data is encoded, gives the UCS an entree
  11036. onto existing platforms.
  11037.  
  11038. But the 2-byte format and the preponderance of NUL and other control bytes in
  11039. UCS-2 text pose problems for current applications and transmission methods.
  11040. And to make matters worse, different hardware platforms store UCS-2 characters
  11041. in different byte order.  Thus a UCS-2 file transferred by FTP (or accessed
  11042. via NFS, etc) between two computers with different architecture might have its
  11043. bytes in the wrong order (or worse; see Section 6.6.5.1).
  11044.  
  11045. 6.6.2. UCS Byte Order
  11046.  
  11047. Consider the number 1.  In an 8-bit byte, this would be represented by the
  11048. following series of 0- and 1-bits:
  11049.  
  11050.   +-----------------+
  11051.   | 0 0 0 0 0 0 0 1 |
  11052.   +-----------------+
  11053.  
  11054. Therefore in a 16-bit "word" the representation might be:
  11055.  
  11056.   +-----------------+-----------------+
  11057.   | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 1 |
  11058.   +-----------------+-----------------+
  11059.  
  11060. Now consider the number 256, which is 2 to the 8th power.  The binary
  11061. representation is 100000000 (1 followed by 8 zeros).  256 would go into a
  11062. 16-bit word like this:
  11063.  
  11064.   +-----------------+-----------------+
  11065.   | 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0 |
  11066.   +-----------------+-----------------+
  11067.  
  11068. When a computer works this way, it is said to be Big Endian, meaning it puts
  11069. the most significant (biggest) byte first (on the "left") in a 16-bit word, and
  11070. the least significant byte second (on the right).
  11071.  
  11072. However, some other computers have the opposite arrangement, called Little
  11073. Endian, in which 1 is:
  11074.  
  11075.   +-----------------+-----------------+
  11076.   | 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0 |
  11077.   +-----------------+-----------------+
  11078.  
  11079. and 256 is:
  11080.  
  11081.   +-----------------+-----------------+
  11082.   | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 1 |
  11083.   +-----------------+-----------------+
  11084.  
  11085. Computers such as Sparc, MIPS, PA-RISC, and PowerPC are Big Endian, whereas
  11086. the PC and the Alpha are Little Endian.  Endianness has never been an issue
  11087. with 7- or 8-bit characters, but it is with UCS characters.  It can be a
  11088. tricky business to share or transfer a UCS-2 file between two different kinds
  11089. of computers.
  11090.  
  11091. To alleviate (but not entirely solve) the problem, UCS-2 files are supposed to
  11092. begin with the Unicode character U+FEFF, Zero-Width No-Break Space (ZWNBS).
  11093. This is a kind of "no-op" (note: any such assertion must normally be qualified
  11094. with many "but ifs" and "excepts" which are omitted here in the interest of
  11095. brevity).  If the bytes are reversed the ZWNBS becomes U+FFFE, which is not
  11096. (and never will be) a defined UCS character.  U+FEFF at the beginning of a UCS
  11097. file is therefore called a Byte Order Mark, or BOM.
  11098.  
  11099. Any application that creates a UCS-2 (or UTF-16, or UCS-4) file should include
  11100. a BOM, and any application that reads one should test for a BOM, and if one is
  11101. found, infer the byte order from it.  This is a convention, however -- not a
  11102. standard or a requirement -- and applications vary in their ability to handle
  11103. BOMs and "backwards" UCS-2 files.
  11104.  
  11105. Note that a BOM is useful only at the beginning of a file.  If you append one
  11106. UCS-2 file to another, and both have BOMs, the internal BOM is no longer a
  11107. BOM.  And if the byte orders of the two files differ, then either the first
  11108. part or the second will be backwards.  (Various other undesirable effects
  11109. might also occur, not discussed here.)
  11110.  
  11111. 6.6.2. UCS Transformation Formats
  11112.  
  11113. UCS textual data can be modified in various ways for transmission or storage.
  11114. Any officially sanctioned method of doing this is called a UCS Transformation
  11115. Format, or UTF.  One such method, called UTF-16, is essentially identical with
  11116. UCS-2 except that it designates certain code values as "escape sequences"
  11117. (called surrogate pairs) to access characters in other planes without having
  11118. to use full UCS-4.  We won't discuss UTF-16 further here, since at the moment
  11119. there are no other planes.  Several other UTF's (such as UTF-1, UTF-2, and
  11120. UTF-7) have fallen into disuse and are not discussed here.  The most important
  11121. transformation format today is UTF-8.
  11122.  
  11123. UTF-8, so called because it "serializes" UCS-2 data into a stream of 8-bit
  11124. bytes, is designed to allow the UCS to work with present-day communications
  11125. gear, computers, and software.  The most important properties of UTF-8 are
  11126. that byte order is constant (no byte swapping) and all (7-bit) ASCII
  11127. characters represent themselves.  Therefore conversion between ASCII and UTF-8
  11128. is no conversion at all, and applications or platforms (such as Plan 9 from
  11129. Bell Labs) that use UTF-8 "for everything" can still run traditional
  11130. ASCII-only applications and be accessed from them.  In particular, unlike
  11131. UCS-2, ASCII characters are not padded with NUL bytes.  But also unlike UCS-2,
  11132. there is no transparency for Latin-1 or any other non-ASCII character set.
  11133. Every non-ASCII UCS-2 character is represented by a sequence of 2 or 3 UTF-8
  11134. bytes.  Thus UTF-8 is more compact than UCS-2 for text containing a
  11135. preponderance of ABC's (or other ASCII characters), about the same as UCS-2
  11136. for other alphabetic scripts (Cyrillic, Roman, Greek, etc), and larger than
  11137. UCS-2 for Chinese, Japanese, and Korean.
  11138.  
  11139. The UTF-8 uncoding of the UCS has been adopted by the Internet as the
  11140. preferred character set for new applications, and is gradually being
  11141. retrofitted into traditional applications like FTP (RFC 2640).
  11142.  
  11143. 6.6.3. Conformance Levels
  11144.  
  11145. Although the Unicode and ISO 10646 standards both describe the same character
  11146. set, these standards differ in many ways, including their stated requirements
  11147. for conformance and their classification of conformance levels.
  11148.  
  11149. Kermit has always abided by ISO character-set standards, including ISO
  11150. character-set designation and invocation methods.  In adapting Unicode,
  11151. therefore, we had to choose from among the available ISO designations which,
  11152. in turn, correspond with ISO 10646 conformance levels.  At present, Kermit
  11153. claims the lowest conformance level, 1, meaning (roughly) that it does not
  11154. handle combining forms and it does not handle Korean Hangul Jamos (just as,
  11155. at present, it does not handle Korean in general).  Note that ISO 10646
  11156. Conformance Levels 1 and 2 sidestep the issue of the code changes for Korean
  11157. Hangul by announcing non-support for Hangul regardless of encoding.
  11158.  
  11159. ISO 10646 Conformance Level 1 is approximately equivalent to Unicode
  11160. Normalization Form C (described in Unicode Technical Report 15, incorporated
  11161. into Unicode 3.0).
  11162.  
  11163. As noted in Section 6.6.2, Kermit does not claim to support UTF-16 at the
  11164. present time, hence the UCS-2 nomenclature.  Kermit treats surrogates just as
  11165. if they were any other UCS-2 characters, rather than as escapes to other
  11166. planes, which means that (except when converting between UCS-2 and UTF-8) they
  11167. are translated to "error" characters, since (a) no other planes are defined
  11168. yet (and if they were, no other character sets supported by Kermit would
  11169. encode their characters), and (b) no valid surrogate character corresponds to
  11170. any other UCS-2 character.
  11171.  
  11172. A minor yet significant aspect of Unicode 3.0 and some recent perturbation of
  11173. ISO 10646-1 (probably Amendment 18, "Symbols and Other Characters") is the
  11174. addition of the Euro Sign at U+20AC.  As noted in Section 6.0, Kermit's "Euro
  11175. compliance" includes conversion between Latin Alphabet 9 and various PC code
  11176. pages.  Text can also be converted between UCS-2 or UTF-8 and any other
  11177. Euro-compliant character set (Latin-9, CP858, CP1250, CP1252) without loss of
  11178. the Euro Sign.
  11179.  
  11180. 6.6.4. Relationship of Unicode with Kermit's Other Character Sets
  11181.  
  11182. Kermit's character sets are divided into two groups: single-byte sets (such
  11183. as Roman, Hebrew, Cyrillic, Greek) and multibyte (various Japanese sets).  The
  11184. two groups are distinct since one normally would not expect to convert Kanji
  11185. ideograms to Roman (or other) letters, or vice versa.
  11186.  
  11187. Unicode character-set conversion works with both groups, but obviously the
  11188. result depends on the repertoires of the source and destination character-sets
  11189. both including the characters in the file.  For example, you can translate a
  11190. Hungarian text file between Latin-2 and Unicode, but not between (say) Unicode
  11191. and Latin/Greek.  By the same token you can convert Japanese text from
  11192. Shift-JIS or EUC or JIS-7 to Unicode and back, but you can't convert the same
  11193. file to (say) Latin-1 if it contains Japanese characters.
  11194.  
  11195.   JIS-7 is equivalent to DEC Kanji and ISO-2022-JP except that the latter
  11196.   two do not support halfwidth Katakana.  Kermit treats all three of these
  11197.   sets the same way, i.e. as JIS-7.
  11198.  
  11199. As noted, Kermit presently does not handle combining diacritics, and so will
  11200. not correctly convert UCS files that use them into a single-byte character
  11201. set.  For example, if a UCS file contains Latin Capital Letter A (U+0041)
  11202. followed by Combining Acute Accent (U+0301), the result will be a
  11203. two-character sequence, A followed by another character.  This is what is
  11204. meant by Conformance Level 1.  (The situation grows worse with multiple
  11205. diacritics, since they can occur in any order.)
  11206.  
  11207. A higher level of conformance is possible, in which "canonical equivalences"
  11208. are handled via algorithms and databases, at some (perhaps considerable) cost
  11209. in performance, since a fair amount of additional code must be executed for
  11210. every character during data transfer (database lookup, sorting of combining
  11211. sequences into canonical order, etc).  This can be added in future releases if
  11212. there is a need (but in many cases, pre- and postpostprocessing might be a
  11213. better option).
  11214.  
  11215. Within these constraints, Kermit converts between the UCS and its other
  11216. character sets.  For example, a mixture of Russian and English (and/or Dutch,
  11217. or Latin) text can bet converted between the UCS and ISO Latin/Cyrillic or
  11218. KOI-8.  But since Kermit does not presently support Arabic character-set
  11219. conversion, the new availability of UCS conversion does not mean that Kermit
  11220. can convert from Arabic UCS text to some other character set, because Kermit
  11221. does not support any other character set that includes Arabic.  Ditto for
  11222. Thai, Armenian, Georgian, Tibetan, Chinese, Korean, etc.  However, Kermit CAN
  11223. convert Arabic (or any other script) between UCS-2 and UTF-8.
  11224.  
  11225. Considering Cyrillic more carefully, note that the UCS also contains numerous
  11226. Cyrillic characters not found in any of the Cyrillic sets (ISO Latin/Cyrillic,
  11227. KOI8, CP866, etc) that Kermit supports; characters needed for Abkhasian,
  11228. Yakut, Tatar, Bashkir, Altaic, Old Church Slavonic, etc; UCS text containing
  11229. any of these historic or "extended" Cyrillic characters can not be converted
  11230. to any of Kermit's current single-byte Cyrillic sets without loss.  The
  11231. situation is similar for Greek, Hebrew, etc, and even worse for Japanese
  11232. since Unicode contains thousands of Kanjis that are lacking from the Japanese
  11233. character sets based on JIS X 0208, such as EUC-JP, JIS-7, and Shift-JIS.
  11234.  
  11235. In general, when converting from UCS to a single-byte set, there is always the
  11236. possibility of data loss, just as there is when converting from any larger set
  11237. to a smaller one.  For example, if a UCS file contains Devanagari characters,
  11238. these characters will be lost when converting to (say) Latin-1, just as Roman
  11239. vowels with acute accents are lost when converting from Latin-1 (an 8-bit set)
  11240. to German ISO 646 (a 7-bit set).
  11241.  
  11242. 6.6.5. Kermit's Unicode Features
  11243.  
  11244. C-Kermit can convert between UCS-2 or UTF-8 and any of its other character
  11245. sets, and also between UCS-2 and UTF-8.  When converting between UCS-2 or
  11246. UTF-8 and a non-Unicode character set (such as Latin-1), the UCS Line
  11247. Separator (LS, U+2028) and Paragraph Separator (PS, U+2029) characters are
  11248. converted to the appropriate line terminator (CR, LF, or CRLF).  When
  11249. converting from a non-Unicode set to UCS-2 or UTF-8, however, line terminators
  11250. are not converted to LS or PS.  This is in accordance with the recommendations
  11251. of Unicode Technical Report #13.
  11252.  
  11253. When C-Kermit starts, it tests the native byte order of the computer.  You can
  11254. see the result in the SHOW FEATURES or SHOW FILE display.  It's also available
  11255. in the variable \v(byteorder): 0 means Big Endian, 1 means Little Endian.
  11256.  
  11257. When UCS-2 is involved in file transfer or translation, the following commands
  11258. tell C-Kermit what to do about byte order:
  11259.  
  11260. SET FILE UCS BYTE-ORDER { BIG-ENDIAN, LITTLE-ENDIAN }
  11261.   This is for reading UCS-2 files that don't have a BOM, and also for
  11262.   writing UCS-2 files.  If this command is not given, the machine's native
  11263.   byte order is used when writing UCS-2 files, and also when reading UCS-2
  11264.   files that don't have a BOM.
  11265.  
  11266. SET FILE UCS BOM { ON, OFF }
  11267.   This setting is used when creating UCS-2 files.  A BOM is added at the
  11268.   beginning by default.  Use OFF to not add the BOM.  This command has
  11269.   no affect when writing files.
  11270.  
  11271. COPY /SWAP-BYTES <sourcefile> <destinationfile>
  11272.   Use this for fixing a UCS-2 file whose bytes are in the wrong order.
  11273.  
  11274. Use SHOW FILE to display the FILE UCS settings.
  11275.  
  11276. Please note, again, that C-Kermit's user interface, including its script
  11277. language, is not internationalized in any way.  String comparisons, case
  11278. conversion, and so on, work only for US ASCII (comparisons for equality work
  11279. with other sets, but not lexically-greater-or-less-than or caseless
  11280. comparisons; even comparisons for equality can fail when composed characters
  11281. or byte order are involved).  String functions such as \findex() and
  11282. \fsubstring() that reference byte positions do just that; they won't work with
  11283. UTF-8 text that contains any non-ASCII characters, and they will not work with
  11284. UCS-2 text at all since they use C strings internally, which are
  11285. NUL-terminated.  These are just a few examples to illustrate that neither
  11286. Unicode nor any other character-set beyond ASCII is supported at the
  11287. user-interface, command, or scripting level in this version of C-Kermit.
  11288.  
  11289. 6.6.5.1. File Transfer
  11290.  
  11291. Kermit supports both UCS-2 and UTF-8 as file and transfer character sets
  11292. in text-mode file transfer.
  11293.  
  11294. To select UCS-2 or UTF-8 as a file character-set, use:
  11295.  
  11296.   SET FILE CHARACTER-SET { UCS2, UTF8 }
  11297.  
  11298. If you want to send a UCS-2 text file (or save an incoming file in UCS-2
  11299. format), tell Kermit to:
  11300.  
  11301.   SET FILE CHARACTER-SET UCS2
  11302.  
  11303. and if you want to send a UTF-8 text file (or store an incoming file in
  11304. UTF-8 format), tell Kermit to:
  11305.  
  11306.   SET FILE CHARACTER-SET UTF8
  11307.  
  11308. When sending UCS-2 files, Kermit determines the byte order from the BOM, if
  11309. there is one (and if there is a BOM, it is stripped, i.e. not sent).  If there
  11310. is no BOM, the byte order is the one specified in the most recent SET FILE UCS
  11311. BYTE-ORDER command, if any, otherwise the computer's native byte order is
  11312. assumed.  When storing incoming files as UCS-2, the byte order is according
  11313. SET FILE UCS BYTE-ORDER, if given, otherwise the native one; a BOM is written
  11314. according to SET FILE UCS BOM.
  11315.  
  11316. A transfer character-set should be chosen that includes all of the characters
  11317. in the source file.  So, for example, if you are sending a UCS-2 file
  11318. containing only German-language text, your transfer character-set can be
  11319. Latin-1, Latin-2, Latin-9, UCS-2, or UTF-8.  But if you are sending a file
  11320. that contains a combination of Hebrew and Greek, your transfer character-set
  11321. must be UCS-2 or UTF-8 if you don't want to lose one script or the other.
  11322. Furthermore, the transfer character-set must be one that is supported by the
  11323. receiving Kermit program.  Since UCS support is new, it is possible that the
  11324. other Kermit program (if it supports character sets at all) does not support
  11325. it, but does support single-byte sets such as Latin-1, Latin/Cyrillic, etc.
  11326.  
  11327. To select UCS-2 or UTF-8 as a transfer character-set, use:
  11328.  
  11329.   SET TRANSFER CHARACTER-SET { UCS2, UTF8 }
  11330.  
  11331. It is up to the receiving Kermit program to convert the transfer format to its
  11332. own local format, if necessary.  If it does not understand the UTF-8 or UCS-2
  11333. transfer character-set, and your file can not be adequately represented by any
  11334. single-byte transfer character-set (such as Latin-1 or Latin/Cyrillic) then,
  11335. if UTF-8 format is acceptable on the receiving computer, use UTF-8 as the
  11336. transfer character-set, with the receiver told to "set unknown-char keep", or
  11337. with the sender told to "set attribute char off".  If you want the file to be
  11338. stored in UCS-2 format at the receiver, send it it binary mode if the source
  11339. file is also UCS-2, or else use the TRANSLATE command (next section) to
  11340. convert it to UCS-2 first, then send it in binary mode.  You should not use
  11341. UCS-2 as a transfer character-set in text-mode transfers to Kermit programs
  11342. that don't support it, because they are likely to corrupt the result the same
  11343. way FTP would (see the final paragraph of this section).
  11344.  
  11345. When UCS-2 is the transfer character set, it always goes into Kermit packets
  11346. in Big Endian format, with no BOM.  As always, the transfer character-set is
  11347. announced by the sender to the receiver.  The announcement for UCS-2 is "I162"
  11348. (ISO Registration 162 = UCS-2 Level 1) and by definition it is Big Endian (the
  11349. standards say that when UCS-2 is serialized into bytes, the order must be Big
  11350. Endian).  The announcement for UTF-8 is "I190" (UTF-8 Level 1).
  11351.  
  11352. When receiving a file whose transfer character-set is UCS-2 or UTF-8, you must
  11353. choose the appropriate file character set for the result.  There is no way
  11354. Kermit can do this for you automatically, since UCS data can be in any script
  11355. at all, or any combination.
  11356.  
  11357. In general, UTF-8 or UCS-2 should be chosen as a transfer character-set if the
  11358. source file is also encoded in some form of UCS and it contains more than one
  11359. script.  But there are other situations where where UTF-8 or UCS-2 offer
  11360. advantages.  For example, suppose the source file is on a NeXTstation and the
  11361. destination file is on VMS.  Both the NeXT and the DEC Multinational character
  11362. sets include the French OE digraph, but Latin-1 does not.  Therefore French
  11363. words containing this character might not arrive intact when Latin-1 is the
  11364. transfer character-set, but will with UTF-8 or UCS-2, since the UCS includes
  11365. the OE digraph (but so does Latin-9).
  11366.  
  11367. UCS-2 should be chosen as a transfer character-set only for Japanese text
  11368. files that contain a large preponderance of Kanji, since in this case (and
  11369. only this case) UCS-2 (two bytes per Kanji) is more efficient than UTF-8
  11370. (threeábytes per Kanji).  The same will be true for Chinese and Korean when
  11371. they are supported by Kermit.  UCS-2 should never be used as a transfer
  11372. character-set with a transfer partner that does not support UCS-2 since this
  11373. can cause file corruption (see last paragraph in this section).
  11374.  
  11375. Note that Kermit's repeat-count compression is 100% ineffective for UCS-2,
  11376. and is also ineffective for multibyte characters in UTF-8 and EUC-JP; this is
  11377. because repeat-compression is a transport-level mechanism that operates on
  11378. a per-byte basis; it has no knowledge of the distinction between a byte and
  11379. a character.
  11380.  
  11381. When C-Kermit starts, it sets up associations (Section 6.5) for incoming files
  11382. whose transfer character sets are UCS-2 or UTF-8 appropriately for the
  11383. platform so that the file character-set for the incoming file is UCS-2 in
  11384. Windows and UTF-8 elsewhere.  Otherwise, C-Kermit does not make any default
  11385. associations for UCS-2 or UTF-8, but of course you may add or change
  11386. associations to suit your needs and preferences by including the appropriate
  11387. ASSOCIATE commands in your Kermit startup file.  For example, if you are a PC
  11388. user and deal only with text written in Greek and English, you can:
  11389.  
  11390.   ASSOCIATE TRANSFER-CHARACTER-SET UTF8 CP869
  11391.   ASSOCIATE TRANSFER-CHARACTER-SET UCS2 CP869
  11392.   ASSOCIATE FILE-CHARACTER-SET CP869 UTF8
  11393.  
  11394. Note that when file transfer involves conversion between a single-byte
  11395. character set and UCS-2 or UTF-8, the file-transfer thermometer and estimated
  11396. time left might be inaccurate, since they are based on the source file size,
  11397. not the transfer encoding.  This is purely a cosmetic issue and does not
  11398. effect the final result.  (And is not, strictly speaking, a bug; Kermit
  11399. protocol presently includes no method for the sender to furnish an "estimated
  11400. transfer size" to the receiver, and in any case any such guess could be as
  11401. far off as the file size, given the many other factors that come into play,
  11402. such as compression and prefixing).
  11403.  
  11404. A caution about FTP and UCS-2.  As noted previously, if you transfer a UCS-2
  11405. file with FTP in binary mode between two computers with opposite Endianness,
  11406. the result will have its bytes in the wrong order.  However, if you use FTP to
  11407. transfer a UCS-2 file in "ascii" (text) mode to ANY computer, even if it is
  11408. identical to yours, the result will be corrupted because FTP's line-terminator
  11409. conversions do not account for UCS-2.  The same holds when sending from a
  11410. UCS-aware Kermit program to an older Kermit program in text mode with a
  11411. transfer character-set of UCS-2.  So use UCS-2 as a transfer character-set
  11412. ONLY with a UCS-2-aware Kermit partner.
  11413.  
  11414. 6.6.5.2. The TRANSLATE Command
  11415.  
  11416. In Kermit versions that have Unicode support included, TRANSLATE now always
  11417. goes through Unicode; that is, the source set is converted to UCS-2 and thence
  11418. to the target set.  This is a major improvement, since in prior releases,
  11419. C-Kermit had to pick the "most appropriate" transfer character-set as the
  11420. intermediate set, and this would result in the loss of any characters that the
  11421. source and target sets had in common but were lacking from the intermediate
  11422. set (for example the OE digraph when translating from NeXT to DEC MCS through
  11423. Latin-1).  This never happens when Unicode is the intermediate set because
  11424. Unicode is a superset of all other character sets supported by Kermit.  A more
  11425. dramatic example would be translation between Cyrillic PC code page 866 and
  11426. KOI8-R (Section 6.4); formerly all the line- and box-drawing characters would
  11427. be lost (since ISO 8859-5 does not have any); now the ones that these two sets
  11428. have in common are preserved.
  11429.  
  11430. UCS-2 and UTF-8 are now both supported as source-file and destination-file
  11431. character sets by C-Kermit's TRANSLATE command, for example:
  11432.  
  11433.   translate oofa.txt ucs2 latin1 oofa-l1.txt
  11434.  
  11435. translates oofa.txt from UCS-2 to Latin-1, storing the result as oofa-l1.txt
  11436. Similarly:
  11437.  
  11438.   translate oofa.txt utf8 latin1 oofa-l1.txt
  11439.   translate oofa.txt latin1 ucs2 oofa-ucs2.txt
  11440.   translate oofa.txt latin1 utf8 oofa-utf8.txt
  11441.   translate oofa.txt ucs2 utf8 oofa-utf8.txt
  11442.   translate oofa.txt utf8 ucs2 oofa-ucs2.txt
  11443.  
  11444. Treatment of the UCS-2 BOM is exactly the same as for file transfer.  Note
  11445. that if a UCS-2 source file is in the "wrong" byte order and lacks a BOM, and
  11446. you don't tell Kermit about it with SET FILE UCS BYTE-ORDER, the result of the
  11447. translation is total gibberish.  Recall that you can use COPY /SWAP-BYTES to
  11448. switch the byte order of an errant UCS-2 file (or any other file for that
  11449. matter, if you can think of a reason to).  Also note that:
  11450.  
  11451.   translate oofa.txt ucs2 ucs2 new.txt
  11452.  
  11453. Produces a result in the native (or SET FILE UCS) byte-order as long as
  11454. oofa.txt has a BOM.
  11455.  
  11456. As a side benefit of the Unicode work, the TRANSLATE command now works
  11457. for the first time also for all Japanese character sets that Kermit supports.
  11458. In other words, if you have a Japanese text file in any of the following
  11459. encodings:
  11460.  
  11461.   EUC-JP
  11462.   Shift-JIS
  11463.   JIS-7
  11464.   UCS-2
  11465.   UTF-8
  11466.  
  11467. You can use the TRANSLATE command to convert to any other encoding from the
  11468. same list.
  11469.  
  11470. 6.6.5.3. Terminal Connection
  11471.  
  11472. The CONNECT command now allows UTF-8 as a local or remote terminal
  11473. character-set:
  11474.  
  11475.   SET TERMINAL CHARACTER-SET { ..., UTF8 } { ..., UTF8 }
  11476.   SET TERMINAL REMOTE-CHARACTER-SET { ..., UTF8 }
  11477.   SET TERMINAL LOCAL-CHARACTER-SET { ..., UTF8 }
  11478.  
  11479. (Recall that Kermit's terminal character-set has two "ends" -- the set used
  11480. on the host to which Kermit is connected, and the set used on the local
  11481. keyboard and screen.)
  11482.  
  11483. UCS-2 is not supported as a terminal character-set (either end) since (a) it
  11484. is not used that way anywhere to our knowledge, and (b) the problems of
  11485. Endianness and the high likelihood of loss of synchronization make it
  11486. impractical.  (Telecommunications is byte-oriented; if one byte, or any odd
  11487. number of bytes, is lost because of buffer overruns, circuit resets, etc (or
  11488. likewise if a burst of noise appears that takes the guise of an odd number of
  11489. bytes), the byte order of the subsequent data stream will be backwards; unlike
  11490. UTF-8 and traditional byte-based character sets, UCS-2 is not "self
  11491. synchronizing".)
  11492.  
  11493. UTF-8 does not have byte-order or synchronization problems and is growing in
  11494. popularity as a terminal character set as well as in other application areas.
  11495. It allows a single terminal session to use multiple scripts (Roman, Cyrillic,
  11496. Greek, etc) without ISO 2022 character-set switching (which terminal emulators
  11497. like Kermit 95 can handle but few host applications understand or use), and
  11498. meshes nicely with the Unicode screen fonts that are beginning to appear.
  11499.  
  11500. UTF-8 was first used in Plan 9 and soon will be available in Linux.  It will
  11501. probably spread from there (Unicode in some form is, of course, also used in
  11502. Windows NT, but only internally -- not for access from outside).
  11503.  
  11504. To use UTF-8 or any other character set that uses 8-bit bytes in your terminal
  11505. session, be sure to tell C-Kermit to:
  11506.  
  11507.   SET TERMINAL BYTESIZE 8
  11508.   SET COMMAND BYTESIZE 8
  11509.   SET PARITY NONE
  11510.  
  11511. (or use the shortcut command, EIGHTBIT, which does all three at once).
  11512.  
  11513. In a setup where your local Kermit program uses a single-byte character set
  11514. such as PC Code Page 850 and the remote host uses UTF-8:
  11515.  
  11516.   SET TERM CHAR UTF8 CP850
  11517.  
  11518. or:
  11519.  
  11520.   SET TERM REMOTE CHAR UTF8
  11521.   SET TERM LOCAL CHAR CP850
  11522.  
  11523. all works as expected.  UTF-8 text on the remote displays correctly on your
  11524. screen, and when you type CP850 characters, they are translated to UTF-8
  11525. sequences for transmission, and the echo from the host is translated from
  11526. UTF-8 back to CP850.  Telnet negotiations and autodownload take place before
  11527. any character-set translation and work as before.  The session log (if text
  11528. mode was selected for it) contains only the local terminal character-set.
  11529. And so on.
  11530.  
  11531. Kermit merely supplies translations from UTF-8 to your local terminal
  11532. character-set (this includes treating UTF-8 Line Separator and Paragraph
  11533. separator as CRLF).  However, Kermit does does not, at present, perform
  11534. "canonicalization" of composed sequences, nor does it automatically execute
  11535. bidirectionality algorithms for display of mixed-direction text (e.g. Hebrew
  11536. and English).  Such presentation issues, like all others in the terminal-host
  11537. regime, are left to the host.
  11538.  
  11539. By the way, C-Kermit also allows UTF-8 to be the local end of the terminal
  11540. character-set, but so far this code is not tested, since we don't have a UTF-8
  11541. console or terminal to work with.  However, it can be stated without doubt
  11542. that C-Kermit's key mapping will not work for UTF-8 values, since (a) the key
  11543. map is indexed by 8-bit byte values and (b) C-Kermit reads keystrokes a byte
  11544. at a time (these comments do not apply to K95, which has direct access to the
  11545. keyboard and can read "wide" keycodes and uses them to index a "wide" keymap).
  11546.  
  11547. Restrictions: As noted, the CONNECT command does not support UCS-2 as a REMOTE
  11548. TERMINAL character-set.  Neither does it support the Japanese sets EUC-JP,
  11549. JIS-7, and Shift-JIS.  Support for the Japanese sets (and possibly Chinese and
  11550. Korean too) might be added in a future release.  Since the TRANSMIT command
  11551. (next section) uses the same REMOTE TERMINAL character-sets as the CONNECT
  11552. command, it has the same restrictions.
  11553.  
  11554. 6.6.5.4. The TRANSMIT Command
  11555.  
  11556. As described in Chapter 15 of "Using C-Kermit" and Section 4.21 of this
  11557. document, the TRANSMIT command can be used to upload a file without protocol,
  11558. more or less as if you were typing it on your keyboard while connected to the
  11559. host.  When TRANSMITting in text mode, the file's character set is converted
  11560. to the host's unless you have SET TERMINAL CHARACTER-SET TRANSPARENT, or you
  11561. include the new TRANSMIT switch, /TRANSPARENT.
  11562.  
  11563. Before C-Kermit 7.0, the file character-set was assumed to be the same as the
  11564. local end of the terminal character-set, and the TRANSMIT command used the
  11565. same translations as the CONNECT command, ignoring the file character-set.
  11566.  
  11567. In C-Kermit 7.0, that assumption (a poor one to begin with) can no longer be
  11568. made, since UCS-2 can be a file character-set but not a terminal
  11569. character-set.  So now the file's character-set is given by your most recent
  11570. SET FILE CHARACTER-SET command.  The host's character set is the remote end of
  11571. your most recent SET TERMINAL CHARACTER-SET command:
  11572.  
  11573.   SET TERMINAL CHARACTER-SET <remote-set> [ <local-set> ]
  11574.  
  11575. or:
  11576.  
  11577.   SET TERMINAL REMOTE-CHARACTER-SET <remote-set>
  11578.  
  11579. The TRANSMIT command converts each source-file character from the FILE
  11580. character-set to the REMOTE TERMINAL character-set, and then transmits the
  11581. translated characters according to your SET TRANSMIT preferences (Chapter 15).
  11582.  
  11583. If you have SET TRANSMIT ECHO ON, and the host is echoing the transmitted
  11584. characters, the echos are converted from the remote terminal character-set to
  11585. the local terminal character-set.
  11586.  
  11587.   [ A picture would help... ]
  11588.  
  11589. Confused?  Let's work through an example.  Suppose your local computer is a
  11590. NeXTstation, on which text files are encoded in the NeXT character set, and
  11591. that the remote computer is a Data General AViiON, which uses the Data General
  11592. International character set.  Further suppose that you are logged in to the
  11593. NeXT from a VT220 terminal which uses the DEC Multinational character set.
  11594.  
  11595. You need to convert the file from NeXT encoding to DG encoding and convert the
  11596. echoes from DG encoding to DEC encoding.  So on the NeXT, tell C-Kermit to:
  11597.  
  11598.   eightbit
  11599.   set file character-set next
  11600.   set term character-set dg-international dec-mcs
  11601.   transmit /text nextdata.txt
  11602.  
  11603. (This assumes you have some sort of collection process already set up on the
  11604. Data General, such as a text editor or the venerable "cat > foo".  The
  11605. EIGHTBIT command is equivalent to SET TERMINAL BYTESIZE 8, SET COMMAND
  11606. BYTESIZE 8, SET PARITY NONE.)
  11607.  
  11608. To further complicate matters, suppose your local terminal character set is
  11609. the same as the remote one, so you don't need terminal character-set
  11610. translation, but you need to TRANSMIT a file that is in a different character
  11611. set and you want it translated to the host set.  In this case, use SET TERM
  11612. CHARACTER-SET to actually specify the character set used on each end, rather
  11613. than specifying TRANSPARENT:
  11614.  
  11615.   eightbit
  11616.   set file character-set ucs2
  11617.   set term character-set latin1 latin1
  11618.   transmit /text ucs2data.txt
  11619.  
  11620. The distinction between:
  11621.  
  11622.   SET TERMINAL CHARACTER-SET xxx yyy
  11623.  
  11624. (where xxx and yyy are the same set) and:
  11625.  
  11626.   SET TERMINAL CHARACTER-SET TRANSPARENT
  11627.  
  11628. is new to C-Kermit 7.0, but affects only the TRANSMIT command.
  11629.  
  11630. The TRANSMIT command currently does nothing special with UCS-2/UTF-8 Line and
  11631. Paragraph Separator characters; more experience is required to find out how
  11632. these behave in a genuine Unicode terminal-host setting.
  11633.  
  11634. Restrictions: As noted, the TRANSMIT command translates from the FILE
  11635. character-set to the REMOTE TERMINAL character-set.  This rules out
  11636. translations to any character set that is not supported as a REMOTE TERMINAL
  11637. character-set, such as UCS-2, EUC-JP, JIS-7, and Shift-JIS.
  11638.  
  11639. 6.6.5.5. Summary of Kermit Unicode Commands
  11640.  
  11641. Specifying file character-set and byte order:
  11642.   SET FILE CHARACTER-SET { ..., UCS2, UTF8 }
  11643.   REMOTE SET FILE CHARACTER-SET { ..., UCS2, UTF8 } (See next section)
  11644.   SET FILE UCS BOM { ON, OFF }
  11645.   SET FILE UCS BYTE-ORDER { BIG-ENDIAN, LITTLE-ENDIAN }
  11646.  
  11647. Specifying the transfer character-set:
  11648.   SET TRANSFER CHARACTER-SET { ..., UCS-2, UTF-8 }
  11649.   REMOTE SET TRANSFER CHARACTER-SET { ..., UCS-2, UTF-8 }
  11650.  
  11651. Specifying the terminal character-set:
  11652.   SET TERMINAL CHARACTER-SET { ..., UTF8 } { ..., UTF8 }
  11653.   SET TERMINAL REMOTE-CHARACTER-SET { ..., UTF8 }
  11654.   SET TERMINAL LOCAL-CHARACTER-SET { ..., UTF8 }
  11655.  
  11656. Displaying settings:
  11657.   SHOW FILE
  11658.   SHOW TRANSFER
  11659.   SHOW TERMINAL
  11660.   SHOW CHARACTER-SETS
  11661.  
  11662. Commands that use these settings include:
  11663.   SEND, RECEIVE, GET, etc.
  11664.   CONNECT
  11665.   TRANSMIT
  11666.   LOG SESSION
  11667.  
  11668. Converting files:
  11669.   TRANSLATE <infile> { ..., UCS-2, UTF-8 } { ..., UCS-2, UTF-8 } <outfile>
  11670.   COPY /SWAP-BYTES <infile> <outfile>
  11671.  
  11672. 6.7. Client/Server Character-Set Switching
  11673.  
  11674. A simple mechanism has been added to allow the client to change the server's
  11675. FILE CHARACTER-SET:
  11676.  
  11677. REMOTE SET FILE CHARACTER-SET <name>
  11678.   The client asks the server to change its file character-set to the one
  11679.   given.  The <name> must match one of the server's file character-set names.
  11680.   For convenience, C-Kermit uses its own file character-set keyword list for
  11681.   parsing this command so you can use ? for help and Tab or Esc for completion.
  11682.   However, since the server might have a different repertoire (or even use
  11683.   different names for the same sets), C-Kermit accepts any string you supply
  11684.   and sends it to the server.  The server, if it supports this command
  11685.   (C-Kermit 7.0 and K95 1.1.18 do), sets its file character-set as requested,
  11686.   and also disables automatic character-set switching (Section 6.5).  If the
  11687.   server does not support this command or if it does not support the given
  11688.   character set, the REMOTE SET FILE CHARACTER-SET command fails.
  11689.  
  11690. Here's an example that sends a Japanese text file encoded in Shift-JIS to
  11691. a server using every combination of Kermit's Japanese-capable file and
  11692. transfer character sets:
  11693.  
  11694. dcl \&x[] = euc ucs2 utf8             ; transfer character-sets
  11695. dcl \&y[] = eu uc ut                  ; 2-letter abbreviations for them
  11696. dcl \&f[] = shift euc jis7 ucs2 utf8  ; file character-sets
  11697. dcl \&g[] = sj eu j7 uc ut            ; 2-letter abbreviations
  11698.  
  11699. set file char shift-jis               ; local file character-set is Shift-JIS
  11700. for \%i 1 \fdim(&x) 1 {               ; for each transfer character-set...
  11701.     set xfer char \&x[\%i]            ; set it
  11702.     for \%j 1 \fdim(&f) 1 {           ; for each remote file character-set...
  11703.     remote set file char \&f[\%j] ; set it
  11704.         if fail exit 1 SERVER REJECTED CHARSET
  11705.         send /text meibo-sj.html meibo-sj-\&y[\%i]-\&g[\%j].txt ; send the file
  11706.         if fail exit 1 TRANSFER FAILED
  11707.     }
  11708. }
  11709.  
  11710. The Kermit-370 server does not support REMOTE SET FILE CHARACTER-SET, but
  11711. since it supports REMOTE KERMIT commands, you can get the same effect with
  11712. REMOTE KERMIT SET FILE CHARACTER-SET <name>.
  11713.  
  11714.  
  11715. (7) SCRIPT PROGRAMMING
  11716.  
  11717. (Also see Section 2.8, Scripting Local Programs.)
  11718.  
  11719. 7.0. Bug Fixes
  11720.  
  11721. The following script programming bugs were fixed in C-Kermit 7.0:
  11722.  
  11723.  . IF EXIST and IF DIRECTORY were fixed to properly strip braces from around
  11724.    their arguments, so "if directory {C:\Program Files}", etc, would work as
  11725.    expected.  However, this means that if the file or directory name is
  11726.    actually enclosed in braces, the braces must be doubled.
  11727.  
  11728.  . The READ command did not fail if the READ file wasn't open; now it does.
  11729.  
  11730.  . The READ command refused to read the last or only line of a file if it did
  11731.    not end with a proper line terminator; now it does.
  11732.  
  11733.  . The END command, when given from within a SWITCH statement, did not exit
  11734.    from the current macro or command file; instead it just terminated the
  11735.    SWITCH.
  11736.  
  11737. 7.1. The INPUT Command
  11738.  
  11739. 7.1.1. INPUT Timeouts
  11740.  
  11741. The description of the INPUT command on page 422 fails to mention the
  11742. following two points about the timeout (which apply to C-Kermit 6.0 and later):
  11743.  
  11744.  1. "INPUT -1 text" (or "INPUT \%x text", where \%x is any variable whose
  11745.     value is -1 or less) means "wait forever".  This form of the INPUT command
  11746.     fails only if it is interrupted, since it will never time out.
  11747.  
  11748.  2. INPUT 0 performs a nonblocking read of material that has already arrived
  11749.     but has not yet been read, and succeeds immediately if the target string
  11750.     is found, or fails immediately if it is not found.
  11751.  
  11752. The same points apply to MINPUT.  REINPUT ignores its timeout parameter.
  11753.  
  11754. 7.1.2. New INPUT Controls
  11755.  
  11756. The following new INPUT controls were added in version 7.0:
  11757.  
  11758. SET INPUT AUTODOWNLOAD { ON, OFF }
  11759.   Explained in section 7.7.
  11760.  
  11761. SET INPUT CANCELLATION { ON, OFF }
  11762.   This governs whether an INPUT command can be canceled by "pressing any key"
  11763.   on the keyboard.  Normally it can be, in which case the INPUT command fails
  11764.   immediately and \v(instatus) is set to 2, indicating interruption.  SET INPUT
  11765.   CANCELLATION OFF disables keyboard cancellations; thus if the search text is
  11766.   not encountered, the INPUT command will run for its entire timeout interval.
  11767.   SET INPUT CANCELLATION OFF does not disable interruption by Ctrl-C, however;
  11768.   every command needs an emergency exit.  (If you really want to disable
  11769.   interruption by Ctrl-C, use SET COMMAND INTERRUPTION OFF.)
  11770.  
  11771. Also see Section 7.2 for any new variables related to INPUT.
  11772.  
  11773. 7.1.3. INPUT with Pattern Matching
  11774.  
  11775. C-Kermit 7.0 allows INPUT, MINPUT, and REINPUT targets to be a pattern
  11776. (explained in Sections 1.19 and 4.9).  This solves a long-standing problem
  11777. illustrated by the following scenario: a certain company has a bank of TCP/IP
  11778. modem servers, with hostnames server1, server2, server3, and so on.  Each
  11779. server's prompt is its name, followed by a colon (:), for example "Server72:".
  11780. Without INPUT patterns, it would be rather difficult to wait for the prompt.
  11781. The brute force approach:
  11782.  
  11783.   minput 20 Server1: Server2: Server3: ... (enumerating each one)
  11784.  
  11785. is subject to failure whenever a new server is added.  A more subtle approach:
  11786.  
  11787.   input 20 Server
  11788.   if fail ...
  11789.   input 2 :
  11790.  
  11791. is liable to false positives, e.g. "Welcome to the XYZ Corp Modem Server.
  11792. Please read the following message:"...
  11793.  
  11794. With patterns, you can match the prompt with "Server*:" (which doesn't solve
  11795. the "false positives" problem, but certainly is more compact than the brute
  11796. force method), or with more specific patterns such as "Server[1-9]:" and
  11797. "Server[1-9][0-9]:", or equivalently:
  11798.  
  11799.   Server{[1-9],[1-9][0-9]}:
  11800.  
  11801. meaning the word "Server" followed by a single digit (1-9) or by two digits
  11802. representing a number from 1 to 99, followed by a colon.
  11803.  
  11804. INPUT pattern matching has been added in a way that does not interfere with
  11805. existing scripts.  No new commands or switches are used.  The simple rule is:
  11806. if an INPUT search target is the argument of the (new) \fpattern() function,
  11807. it is a pattern.  Otherwise it is taken literally, as before.  For example:
  11808.  
  11809.   input 5 a*b
  11810.  
  11811. searches for an 'a' followed by an asterisk ('*'), followed by a 'b'.  But:
  11812.  
  11813.   input 5 \fpattern(a*b)
  11814.  
  11815. searches for an 'a' followed by anything at all up to and including the first
  11816. 'b'.  This means that any search target to INPUT, MINPUT, or REINPUT can be a
  11817. pattern or a literal string, and in particular that MINPUT can accommodate any
  11818. mixture of patterns and literal strings.
  11819.  
  11820. In selecting patterns, note that:
  11821.  
  11822.  . A leading '*' is always implied so there is no need to include one.
  11823.  . A trailing '*' is meaningless and ignored.
  11824.  . A '*' by itself matches the first character that arrives.
  11825.  
  11826. A syntax note: If your pattern is a selection list, meaning a list of
  11827. alternatives separated by commas and enclosed in braces, then the outer braces
  11828. will be stripped by various levels of parsers, so you must include three of
  11829. each:
  11830.  
  11831.   input 10 \fpattern({{{abc,mno,xyz}}})
  11832.  
  11833. Note that this is equivalent to:
  11834.  
  11835.   minput 10 abc mno xyz
  11836.  
  11837. except for the setting of the \v(minput) variable.
  11838.  
  11839. And a caution: INPUT pattern matching has a limitation that you probably never
  11840. noticed with literal-string matching, namely that there is a limit on the size
  11841. of the match.  For example, if the pattern is "a*b", the match will succeed
  11842. if the 'a' and 'b' are not separated by more than (say) 8K bytes, but will
  11843. fail if they are farther apart than that.  In such cases, it better to use
  11844. two INPUTs (e.g. "input 10 a" and then "input 100 b").
  11845.  
  11846. 7.1.4. The INPUT Match Result
  11847.  
  11848. The result of any INPUT, MINPUT, or REINPUT command, no matter whether the
  11849. search targets are patterns or literal strings, is available in the new
  11850. \v(inmatch) variable.  For example:
  11851.  
  11852.   minput 10 cat \fpattern([dh]og)
  11853.   if success echo MINPUT matched "\v(inmatch)"
  11854.  
  11855. This is especially useful when a pattern was matched, since it makes the
  11856. string that matched the pattern available to Kermit; there would be no way
  11857. to get it otherwise.
  11858.  
  11859. After an INPUT command, you can view all the INPUT-related variables by
  11860. typing "show variables in" (abbreviate as "sho var in"), which shows the
  11861. values of all built-in variables whose names start with "in".
  11862.  
  11863. 7.2. New or Improved Built-In Variables
  11864.  
  11865. \v(blockcheck) - Current BLOCK-CHECK setting, 1, 2, 3, or 4.  4 is the
  11866.                  code for BLANK-FREE-2.
  11867.  
  11868. \v(byteorder)  - The machine's byte order: 0 = Big Endian, 1 = Little Endian.
  11869.  
  11870. \v(cmdbufsize) - The length of the command buffer, which is the maximum
  11871.                  size for a macro, a command, a variable, or anything else
  11872.                  in C-Kermit's script language.
  11873.  
  11874. \v(ctty)       - The device name of C-Kermit's controlling (login) terminal.
  11875.  
  11876. \v(filename)   - Described in Sections 4.1 and 4.2.
  11877. \v(filenumber) - Described in Sections 4.1 and 4.2.
  11878.  
  11879. \v(filespec)   - As of C-Kermit 7.0, contains fully qualified filenames rather
  11880.                  than (usually) relative ones.
  11881.  
  11882. \v(return)     - Now holds the END <n> value of the macro that most recently
  11883.                  returned, in case END was used rather than RETURN.
  11884.  
  11885. \v(editor)     - Pathname of preferred text editor
  11886. \v(editopts)   - Command-line options for editor
  11887. \v(editfile)   - File most recently edited
  11888.  
  11889. \v(browser)    - Pathname of preferred Web browser
  11890. \v(browsopts)  - Command-line options for Web browser
  11891. \v(browsurl)   - URL most recently given to Web browser
  11892.  
  11893. \v(dialtype)   - Type of call most recently placed (see section 2.1.11).
  11894.  
  11895. \v(kbchar)     - The character, if any, that was typed at the keyboard to
  11896.                  to interrupt the most recent PAUSE, SLEEP, WAIT, MSLEEP,
  11897.                  or INPUT command; empty if the most recent such command was
  11898.                  not interrupted from the keyboard.
  11899.  
  11900. \v(lockdir)    - UNIX only - The name of the UUCP lockfile directory, if
  11901.                  known, otherwise "(unknown)".
  11902.  
  11903. \v(lockpid)    - UNIX only - PID of process that owns the communication port
  11904.                  that you tried to open with a SET LINE command that failed
  11905.                  because the port was in use, otherwise empty.  This variable
  11906.                  is set with every SET LINE command.
  11907.  
  11908. \v(cx_time)    - If no connection (SET HOST, SET LINE, DIAL, TELNET, etc)
  11909.                  is active, this is 0.  If a connection is active, this is
  11910.                  the number of seconds since the connection was made.
  11911.  
  11912. \v(hwparity)   - If hardware parity is in effect, this variable gives its
  11913.                  value, such as "even" or "odd" (in which case, the \v(parity)
  11914.                  variable will be "none").  Otherwise this variable is empty.
  11915.  
  11916. \v(serial)     - Current serial port settings in 8N1 format (Section 2.10).
  11917.  
  11918. \v(errno)      - In UNIX, the current value of the C runtime errno variable,
  11919.                  which is quite volatile (meaning that often an "interesting"
  11920.                  error code can be overwritten by some other library call or
  11921.                  system service that sets errno before you have a chance to
  11922.                  look at it).
  11923.                  In VMS, the error code returned by the system or library
  11924.                  call that most recently failed (success codes are not saved).
  11925.                  Not available in other operating systems.
  11926.  
  11927. \v(errstring)  - The UNIX or VMS system error message that corresponds to
  11928.                  \v(errno).  Not available in other OS's.
  11929.                  Also see \ferrstring().
  11930.  
  11931. \v(setlinemsg) - The error message, if any, from the most recent SET LINE,
  11932.                  SET PORT, SET HOST, TELNET, or other connection-making
  11933.                  command.  This is not necessarily the same as \v(errstring)
  11934.                  since these commands might fail without generating a system
  11935.                  error code, for example (in UNIX) because a lockfile existed
  11936.                  indicating the device was assigned by another user.
  11937.  
  11938. \v(exitstatus) - The exit status C-Kermit would return if it exited now.
  11939.  
  11940. \v(pexitstat) -  The exit status of the inferior process most recently invoked
  11941.                  by C-Kermit (by RUN, !, REDIRECT, SEND /COMMAND, etc).  In
  11942.                  VMS, this code can be given to \ferrstring() to get the
  11943.                  corresponding error message (in UNIX, program/command return
  11944.                  codes are not the same as system error codes).  Not available
  11945.                  in operating systems other than UNIX and VMS.  See section
  11946.                  4.2.5 for details.
  11947.  
  11948. \v(inmatch)    - The incoming string of characters, if any, that matched the
  11949.                  most recent INPUT, REINPUT, or MINPUT command.
  11950.  
  11951. \v(intime)     - The number of milliseconds (thousandths of seconds) it took
  11952.                  for the most recent INPUT command to find its match, or -1
  11953.                  if no INPUT command has been given yet.  If the INPUT command
  11954.                  timed out, the value is approximately equal to 1000 times the
  11955.                  INPUT timeout.  If INPUT failed for some other reason, the
  11956.                  value is undefined (\v(instatus) gives INPUT completion
  11957.                  status).  If your version of C-Kermit is built without
  11958.                  high-precision floating-point timers, this number will always
  11959.                  be a multiple of 1000.
  11960.  
  11961. \v(inwait)     - The number of seconds specified as the timeout in the most
  11962.                  recent INPUT command.
  11963.  
  11964. \v(dialsuffix)   Dialing suffix for use during PDIAL sequence; see Section
  11965.                  2.1.10.
  11966.  
  11967. \v(pid)       -  UNIX, VMS, and K95 only.  C-Kermit's primary process ID,
  11968.                  numeric, decimal.  If you want to show it in hex, use
  11969.                  \fn2hex(\v(pid)).  If you want to show it in octal, use
  11970.                  \fn2octal(\v(pid)).
  11971.  
  11972. \v(printer)    - Current printer name or SET PRINTER value.
  11973.  
  11974. \v(p_ctl)      - Control prefix char
  11975. \v(p_8bit)     - 8-bit prefix char (if parity not none)
  11976. \v(p_rpt)      - Repeat prefix char (if repeat compression enabled)
  11977.  
  11978. \v(herald)     - Kermit's version herald
  11979.  
  11980. \v(test)       - Kermit's test version, if any, or 0 if this is not a test
  11981.                  version.  Typical values for test versions are "Alpha.03"
  11982.                  or "Beta.14".
  11983.  
  11984. \v(sendlist)   - The number of entries in the SEND-LIST, 0 if none.  Note:
  11985.                  entries do not necessarily correspond to files, since an
  11986.                  entry might contain wildcards.  Also note that the value does
  11987.                  not go back to 0 after the files in the list are sent.  To
  11988.                  reset this variable, use CLEAR SEND-LIST.  The purpose of
  11989.                  this variable is to determine if a SEND command, when given
  11990.                  without any filenames, will be legal.  Example:
  11991.                    xif \v(sendlist) { send } else { send oofa.txt }
  11992.  
  11993. \v(trigger)    - If the most recent CONNECT session was terminated
  11994.                  automatically by a trigger, this variable contains the
  11995.                  trigger value.
  11996.  
  11997. \v(ty_ln)      - TYPE line number (during TYPE)
  11998. \v(ty_lc)      - TYPE line count  (after TYPE)
  11999. \v(ty_mc)      - TYPE match count (after TYPE)
  12000.  
  12001. \v(xferstat)   - Status of most recent file
  12002.           -1: No transfer yet
  12003.            0: Succeeded
  12004.            1: Failed
  12005.  
  12006. \v(xfermsg)    - If the most recent file transfer failed, this is the reason.
  12007.                  If it succeeded, \v(xfermsg) is an empty string.
  12008.  
  12009. \v(tftime)     - Total elapsed time of most recent file transfer operation,
  12010.                  in seconds.
  12011.  
  12012. \v(textdir)    - Directory that holds (or is supposed to hold) Kermit text
  12013.                  files such as installation instructions, release notes,
  12014.                  update notes, read-me files, "beware" files, etc.
  12015.  
  12016. \v(name)       - The name with which the Kermit program was invoked, e.g.
  12017.                  "kermit", "wermit", "k95", "k2", etc (see section 9.1).
  12018.  
  12019. \v(osname)     - Name of operating system on computer where C-Kermit is
  12020.                  running, obtained at runtime (from uname or equivalent).
  12021.  
  12022. \v(osversion)  - Version of operating system on computer where C-Kermit is
  12023.                  running, obtained at runtime (from uname or equivalent).
  12024.  
  12025. \v(osrelease)  - Release of operating system on computer where C-Kermit is
  12026.                  running, obtained at runtime (from uname or equivalent).
  12027.  
  12028. \v(model)      - The specific hardware model of the computer where C-Kermit
  12029.                  is running, if known.
  12030.  
  12031. \v(math_pi)    - The value of Pi (see Section 7.23)
  12032. \v(math_e)     - The value of e  (see Section 7.23)
  12033. \v(math_precision) - How many significant digits in a floating-point number.
  12034.  
  12035. \v(f_count)    - Result of the most recent FILE COUNT (FCOUNT) command.
  12036. \v(f_error)    - Numeric error code of most recent FILE command.
  12037. \v(f_max)      - Maximum number of files open simultaneously.
  12038.  
  12039. The math constants are given in the precision of underlying computer's
  12040. floating-point arithmetic.
  12041.  
  12042. Note the distinction between \v(osname)-\v(osversion) and \v(platform); the
  12043. latter refers to the platform for which and/or upon which C-Kermit was built,
  12044. as opposed to the one on which it is actually running.  Also note that each
  12045. operating system can, and probably will, interpret and fill in the os*
  12046. variables differently, or not at all.
  12047.  
  12048. The SHOW VARIABLES command now accepts a variable name, prefix, or pattern:
  12049.  
  12050.   show variables         Shows all variables.
  12051.   show variables t       Shows all variables that start with "t".
  12052.   show variables *ver*   Shows all variables whose names contain "ver".
  12053.   show variables *ver    Ditto (an implied "*" is appended).
  12054.  
  12055. 7.3. New or Improved Built-In Functions
  12056.  
  12057. The following new file-i/o functions are explained in Section 1.22.
  12058.  
  12059.   \f_status(channel)           Status of file open on channel
  12060.   \f_pos(channel)              Read/write (byte) pointer of given file
  12061.   \f_line(channel)             Current line of file
  12062.   \f_handle(channel)           Handle of file
  12063.   \f_eof(channel)              Whether given file is at EOF
  12064.   \f_getchar(channel)          Read a char from given file
  12065.   \f_getline(channel)          Read a line from given file
  12066.   \f_getblock(channel,n)       Read a block from given file
  12067.   \f_putchar(channel,c)        Write a char to given file
  12068.   \f_putline(channel,string)   Write a line to given file
  12069.   \f_putblock(channel,string)  Write a block to given file
  12070.  
  12071. The following new date-time-related functions are explained in Section 1.6:
  12072.  
  12073.   \fday()                Returns day of week of given date
  12074.   \fnday()               Returns numeric day of week of given date
  12075.   \ftime()               Returns time portion of given date-time
  12076.   \fntime()              Converts time to seconds since midnight
  12077.   \fn2time()             Converts seconds since midnight to hh:mm:ss
  12078.   \fcvtdate(date-time)   Converts free-format date to yyyymmdd hh:mm:ss
  12079.   \fdayofyear(date-time) Converts date to yyyyddd (day-of-year) format
  12080.   \fdoy(date-time)       Synonym for \fdayofyear()
  12081.   \fdoy2date(dayofyear)  Converts yyyyddd to yyyymmdd
  12082.   \fmjd(date-time)       Converts free-format date to Modified Julian Date
  12083.   \fmjd2date(mjd)        Converts modified Julian date to yyyymmdd
  12084.  
  12085. The new floating-point arithmetic functions are explained in Section 7.23.  f1
  12086. and f2 are floating-point (real) numbers; d is the number of decimal places to
  12087. show:
  12088.  
  12089.   \ffpabsolute(f1,d)     Absolute value of f1
  12090.   \ffpadd(f1,f2,d)       f1 + f1
  12091.   \ffpcosine(f1,d)       Cosine of f1
  12092.   \ffpdivide(f1,f2,d)    f1 divided by f2
  12093.   \ffpexp(f1,d)          e to the f1 power
  12094.   \ffpint(f1)            Integer part of f1
  12095.   \ffplog10(f1,d)        Log base 10 of f1
  12096.   \ffplogn(f1,d)         Natural log of f1
  12097.   \ffpmaximum(f1,f2,d)   Maximum of f1 and f2
  12098.   \ffpminimum(f1,f2,d)   Minimum of f1 and f2
  12099.   \ffpmodulus(f1,f2,d)   Modulus of f1 and f2
  12100.   \ffpmultiply(f1,f2,d)  Product of f1 and f2
  12101.   \ffpraise(f1,f2,d)     Raise f1 to power f2
  12102.   \ffpround(f1,d)        Round f1 to d places
  12103.   \ffpsine(f1,d)         Sine of f1
  12104.   \ffpsqrt(f1,d)         Square root of f1
  12105.   \ffpsubtract(f1,f2,d)  f2 - f1
  12106.   \ffptangent(f1,d)      Tangent of f1
  12107.  
  12108. Integer number functions:
  12109.  
  12110. \fabsolute(n)
  12111.   Absolute value of integer n.
  12112.  
  12113. \frandom(n)
  12114.   Returns a random integer between 0 and n-1.
  12115.  
  12116. \fradix(s,n1,n2)
  12117.   If the string s is an integer in radix n1, the result is the same number
  12118.   expressed in radix n2, where n1 and n2 may be any number from 2 through 36,
  12119.   expressed as decimal numbers, or variables (etc) that evaluate to decimal
  12120.   numbers.  For the source and result, the digits of any radix, r, are the
  12121.   first r characters in the sequence 0-9,a-z (case doesn't matter for the
  12122.   letters).  The string s may have a sign, + or -; if it starts with a minus
  12123.   (-) sign, the result also has a minus sign.
  12124.  
  12125. The \fradix() function does not work with floating-point numbers.  It does not
  12126. reveal the internal storage format of a number; for example, \fradix(-1,10,16)
  12127. is -1, not something like FFFFFFFFFF.  If all three arguments are not given,
  12128. or if n1 or n2 are not numbers between 2 and 36 inclusive, or s is not a
  12129. number in radix n1, an error occurs and the empty string is returned.
  12130. \fradix() also does not offer extended-precision arithmetic; number values are
  12131. limited to those expressed as a long integer in the architecture of the
  12132. underlying computer, usually 32 or 64 bits.  If you give it an argument whose
  12133. absolute value is larger than can be held in an unsigned long, the result is
  12134. -1.
  12135.  
  12136. The next four are shorthand functions for decimal/hexadecimal and
  12137. decimal/octal number conversion:
  12138.  
  12139. \fn2hex(n)
  12140.   Returns the hexadecimal (base 16) representation of the integer n.  This is
  12141.   different from \fhexify(s), which treats its argument as a string rather
  12142.   than a number.  The result is always left-padded with 0's to make its
  12143.   length even.  Examples:
  12144.     \n2hex(0)   = "00"                    \fhexify(0)   = "30"
  12145.     \n2hex(255) = "ff"                    \fhexify(255) = "323535"
  12146.     \n2hex(256) = "0100"                  \fhexify(256) = "323536"
  12147.  
  12148. \fhex2n(x)
  12149.   Converts hexadecimal number x to decimal equivalent decimal number.
  12150.   This is the inverse of \fn2hex().  Equivalent to \fradix(s,16,10).
  12151.  
  12152. \fn2octal(n)
  12153.   Returns the octal (base 8) representation of the number n.  Examples:
  12154.   \n2octal(0) = "0"
  12155.   \n2oct(255) = "377"
  12156.   \n2oct(256) = "400"
  12157.   Equivalent to \fradix(n,10,8).
  12158.  
  12159. \foct2n(n)
  12160.   Returns the decimal representation of the given octal number, n.  The
  12161.   inverse of \fn2octal().  Equivalent to \fradix(n,8,10).
  12162.  
  12163. String functions:
  12164.  
  12165. \s(name[n:m])
  12166.   Equivalent to \fsubstring(\m(name),n,m) (Section 7.24).
  12167.  
  12168. \:(name[n:m])
  12169.   Equivalent to \fsubstring(name,n,m) (where "name" is any \-quantity)
  12170.   (Section 7.24).
  12171.  
  12172. \fleft(s,n)
  12173.   The leftmost n characters of string s; equivalent to \fsubstring(s,1,n).
  12174.  
  12175. \fstripx(string,char)
  12176.   Returns the part of the string up to the rightmost occurrence, if any, of
  12177.   the given character.  The default character is period (.)  Examples:
  12178.     \fstripx(foo/bar,/)                 = "foo"
  12179.     \fstripx(foo/bar/baz,/)             = "foo/bar"
  12180.     \fstripx(autoexec.bat,.)            = "autoexec"
  12181.     \fstripx(autoexec.bat)              = "autoexec"
  12182.     \fstripx(fstripx(foo/bar/baz,/),/)  = "foo"
  12183.  
  12184. \flop(string,character)
  12185.   Returns the portion of the string starting after the first occurrence of
  12186.   the given character.  The default character is period (.)  Examples:
  12187.     \flop(autoexec.bat)                 = "bat"
  12188.     \flop(baz.foo/bar)                  = "foo/bar"
  12189.     \flop(baz.foo/bar,/)                = "bar
  12190.  
  12191. \fstripn(string,n)
  12192.   Returns the string with n characters removed from the end.  Example:
  12193.   \fstripn(12345678,3)                  = "12345"
  12194.  
  12195. (For more discussion of \fstripx(), \fstripn(), and \flop() see section 4.2.3).
  12196.  
  12197. \fb64encode(s)
  12198.   Returns the Base-64 encoding of the string s.
  12199.  
  12200. \fb64decode(s)
  12201.   Returns the decoding of the Base-64 string s.  Fails if s is not a Base-64
  12202.   string, or if its length is not a multiple of 4.  Note that if any of the
  12203.   result bytes are null (0), the result string stops there.  There is no way
  12204.   to represent strings that contain null bytes in C-Kermit (the same is true
  12205.   for \funhexify()).
  12206.  
  12207. \fword(s1,n,s2,s3)
  12208.   Extracts word number n from string s1.  By default, a "word" is any sequence
  12209.   of ASCII letters or digits; n is 1-based.  If n is omitted, "1" is used.
  12210.   Examples:
  12211.  
  12212.     \fword(one two three)    = "one"
  12213.     \fword(one two three,1)  = "one"
  12214.     \fword(one two three,2)  = "two"
  12215.     \fword(one two three,3)  = "three"
  12216.  
  12217.   and:
  12218.  
  12219.     \fword(\v(dialresult),2) = "31200"
  12220.  
  12221.   is "31200" if \v(dialresult) is (e.g.) "CONNECT 31200/ARQ/V32/LAPM/V42BIS".
  12222.  
  12223.   If you include s2, this replaces the default break set.  For example,
  12224.   suppose you have a string \%a whose value is:
  12225.  
  12226.     $150.00 $300.00 $39.95
  12227.  
  12228.   and you want each dollar amount to be a word; use:
  12229.  
  12230.     \fword(\%a,\%n,{ })
  12231.  
  12232.   This returns dollar amount number \%n, e.g. "$300.00" for \%n = 2.  "{ }"
  12233.   denotes a space (you must enclose it in braces, otherwise it is squeezed
  12234.   out).  Note that ASCII control characters are always included in the break
  12235.   set; you don't have to specify them (and you can't not specify them).
  12236.  
  12237.   The optional s3 argument lists characters (even control characters) that
  12238.   normally would be considered separators that you want included in words.
  12239.   So the dollars-and-cents example could also be handled this way:
  12240.  
  12241.     \fword(\%a,\%n,,$.)
  12242.  
  12243.   in other words, use the default separator list, but remove "$" and "."
  12244.   from it so they will be considered part of a word.
  12245.  
  12246. \fsplit(s1,&a,s2,s3)
  12247.   This is like \fword(), except instead of extracting and returning a
  12248.   particular word from string s1, it counts the words and optionally assigns
  12249.   them to the array whose identifying letter, a-z, is given after the "&" in
  12250.   the second argument, with the first word going into element 1, the second
  12251.   into element 2, and so on.  The rules regarding break and include lists (s2
  12252.   and s3) are exactly the same as for \fword().  \fsplit() returns the number
  12253.   of words that were assigned, which is either the number of words in the
  12254.   string, or the dimension of the array, whichever is less.  If the array is
  12255.   not declared, \fsplit() creates it and returns a number which is both the
  12256.   number of words in s1 and the dimension of the new array.  Examples:
  12257.  
  12258.      declare \&w[20]        ; (Optional.)
  12259.      ...
  12260.      read \%s               ; \%s is "This is a sentence with seven words."
  12261.      ...
  12262.      echo "\fsplit(\%s)"    ; This would print "7".
  12263.      echo "\fsplit(\%s,&w)" ; Ditto, and also assigns them to array \&w[].
  12264.  
  12265.      echo "\&w[7]"          ; This would print "words".
  12266.  
  12267.   If the line contained fields that were delimited by colon (:), you would use
  12268.   \fsplit(\%s,&w,:).  If the fields were delimited by comma, then you would
  12269.   use \fsplit(\%s,&w,{,}); in this case the literal comma must be enclosed in
  12270.   braces to distinguish it from the comma that separates function arguments.
  12271.   To get a word count without loading an array, but still specify break
  12272.   and/or include lists, leave the array argument empty:
  12273.  
  12274.      echo "\fsplit(\%s,,:)" ; Use colon as the separator.
  12275.  
  12276.   WARNINGS:
  12277.    a. If you use the same array repeatedly, \fsplit() leaves any trailing
  12278.       members undisturbed.  For example:
  12279.          dcl \&w[10]
  12280.          \fsplit(1 2 3 4 5,&w) ; Sets \&w[1] thru \&w[5].
  12281.          \fsplit(a b c,&w)     ; Sets \&w[1]-[3] leaving [4]-[5] as they were.
  12282.    b. If you allow \fsplit to create the array (by not declaring it first),
  12283.       it is dimensioned to the number of elements it was created with:
  12284.          \fsplit(1 2 3,&x)     ; Creates an array \&x[] with 3 elements.
  12285.          \fsplit(a b c d e,&x) ; This overflows the array.
  12286.  
  12287.    Thus if you want to use \fsplit() repeatedly on the same array, either
  12288.    dimension it in advance to the maximum expected size (and then some --
  12289.    more efficient), or else destroy it after each use (to allow for
  12290.    unexpectedly large arguments).  Example using a dynamic array:
  12291.  
  12292.       fopen /read \%c some-file
  12293.       if fail ...
  12294.       set function error on    ; See Section 7.12
  12295.       while true {
  12296.           dcl \&w[]            ; Destroy \&[w] each time thru the loop
  12297.           fread /line \%c \%a
  12298.           if fail break
  12299.           asg \%x \fsplit(\%a,&w)
  12300.           if fail ...
  12301.           ; (do what you want with \&w[] here...)
  12302.       }
  12303.       fclose \%c
  12304.  
  12305. \frindex(s1,s2,n)
  12306.   The "n" argument to \frindex() now works consistently (in mirror image)
  12307.   with the corresponding \findex() argument.  In each case, the (n-1)-most
  12308.   characters of s2 are ignored in the search; for findex, this means the
  12309.   starting position of the search is n (the default n is 1, and 0 is treated
  12310.   like 1).  For \frindex() it means the default starting point is:
  12311.   length(s2) - length(s1) - n (with the same defaults for n).
  12312.  
  12313. \fsearch(pattern,string[,position])
  12314.   Exactly like \findex(), except with a pattern (see Section 7.9) rather
  12315.   than a literal string.
  12316.  
  12317. \frsearch(pattern,string[,position])
  12318.   Exactly like \frindex(), except with a pattern rather than a literal string.
  12319.  
  12320. File Functions:
  12321.  
  12322. \ffiles(), \fnextfile()
  12323.   It is no longer necessary to copy the file list to an array before use,
  12324.   as shown on p.398 of "Using C-Kermit" 2nd Edition.  \ffiles() and friends
  12325.   now make their own safe copies of the file list.  Thus constructions like
  12326.   the following are now possible:
  12327.  
  12328.     for \%i 1 \ffiles(*.txt) 1 { send \fnextfile() }
  12329.  
  12330.   The same is true for the new function \frfiles(), \fdirectories(), and
  12331.   \frdirectories(), described in section 4.11.3.
  12332.  
  12333.   But note that each reference to \fnextfile() still gets you the next file.
  12334.   So "if newer \fnextfile() foo.txt send \fnextfile()" compares one file's
  12335.   age with that of foo.txt, and then sends an entirely different file.  If
  12336.   you're going to refer to the same file more than once, assign it to a
  12337.   variable:  asg \%f \fnextfile(), if newer \%f foo.txt send \%f (note:
  12338.   assign, *not* define).
  12339.  
  12340.   Also note that \ffiles(), \frfiles(), \fdirectories() and \frdirectories()
  12341.   all now accept on optional 2nd argument: the name of an array to load with
  12342.   the resulting file or directory list, explained in Section 4.11.3.
  12343.   So you can also load an array with the filelist when you need to refer to
  12344.   the same file more than once:
  12345.   for \%i 1 \ffiles(*,&a) 1 { if newer \&a[\%i] foo.txt send \&a[\%i] }
  12346.  
  12347. \fpermissions(file)
  12348.   Returns the platform-specific permissions string for the file, such as
  12349.   "-rw-rw-r--" in UNIX or "(RWE,RWE,RE,E)" in VMS.
  12350.  
  12351. \fdirname(f)
  12352.   Given a file specification f, this function returns the complete pathname
  12353.   of directory the file is in.
  12354.  
  12355. Array Functions:
  12356.  
  12357. \fdimension(&a)
  12358.   Returns the dimension declared for the array whose identifying letter, a-z,
  12359.   or special character "_" or "@", is given after the "&" in the argument.
  12360.   If the array is not declared, 0 is returned.  Note that when used with the
  12361.   macro argument vector array, \&_[] (see Section 7.5), the value of this
  12362.   function is one less than \v(argc), and when used with the C-Kermit
  12363.   command-line argument vector array, \&@[], it is equal to the \v(args)
  12364.   variable.  Examples:
  12365.  
  12366.     echo \fdimension(&a)       ; Not declared.
  12367.     0
  12368.     declare \&a[12]            ; Now it's declared.
  12369.     echo \fdim(&a)
  12370.     12
  12371.  
  12372. \farraylook(pattern,arrayname)
  12373.   Looks in the given array for the pattern and returns the index of the first
  12374.   element that matches, if any, or -1 if none match.  The arrayname can
  12375.   include a range specifier to restrict to search to a segment of the array,
  12376.   e.g. \farraylook(*xyz*,&a[32:63]).  For greater detail see Section 7.10.7.
  12377.  
  12378. \ftablelook(keyword,arrayname[,delimiter])
  12379.   Looks in the given "table", which must be sorted, for the given keyword.
  12380.   Returns the index of the table element that uniquely matches the given
  12381.   keyword, or -1 if none match, or -2 if more than 1 match.
  12382.   For greater detail see Section 7.10.7.
  12383.  
  12384. Other new functions:
  12385.  
  12386. \fip2hex(s)
  12387.   Converts a dotted decimal IP address to an 8-digit hexadecimal number.
  12388.   \fip2hex(128.59.39.2) = 803b2702.
  12389.  
  12390. \fhex2ip(x)
  12391.   Converts an 8-digit hexadecimal IP address to dotted decimal form, e.g.
  12392.   \fhex2ip(803b2702) = 128.59.39.2.  The inverse of \fip2hex().
  12393.  
  12394. \fcommand()
  12395. \frawcommand()
  12396.   These run an external command and return its output; see Section 4.2.8.4.
  12397.  
  12398. \fdialconvert(s)
  12399.   s is a phone number in either literal or portable format (not a dialing
  12400.   directory entry name).  The function returns the dial string that would
  12401.   actually be used when dialing from the current location (after processing
  12402.   country code, area code, and other SET DIAL values).
  12403.  
  12404. \ferrstring(n)
  12405.   Returns the system error message associated with the (numeric) error code n.
  12406.   UNIX and VMS only.  Use in conjunction with \v(errno) or \v(pexitstat).  See
  12407.   section 4.2.5 for a usage example.  Note: This function doesn't work in
  12408.   Windows because there is not a consistent error-code-to-message mapping;
  12409.   error code "x" means something completely different depending on whether it
  12410.   comes from the C runtime library, Winsock, a Windows-32 API, TAPI, etc,
  12411.  
  12412. \fpattern(s)
  12413.   Used in INPUT, REINPUT, and MINPUT commands to denote search strings that
  12414.   are to be treated as patterns rather than literally.
  12415.  
  12416. Also see Section 7.8 on built-in help for functions.
  12417.  
  12418. 7.4. New IF Conditions
  12419.  
  12420. IF AVAILABLE <feature> <command>
  12421.   Executes the <command> if the given <feature> is available.  Presently used
  12422.   only to determine if specific authentication and encryption options are
  12423.   available.  Type "if available ?" to see which features may be tested.
  12424.  
  12425. IF FLOAT f1 <command>
  12426.   Executes <command> if f1 is a legal floating point number (which includes
  12427.   integers).  Use this to preverify arguments for the \ffp...() floating-point
  12428.   arithmetic functions, e.g. "if float \%1 echo \ffpint(\%1)".
  12429.  
  12430. IF == n1 n2 <command>
  12431.   Synonym for "if =" (numeric equality).  Note that as of C-Kermit 7.0, this
  12432.   and all other numeric comparison operators also work for floating-point
  12433.   numbers.
  12434.  
  12435. IF != n1 n2 <command>
  12436.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12437.   numbers and the value of n1 is not equal to the value of n2.  This is
  12438.   equivalent to "if not = n1 n2".
  12439.  
  12440. IF <= n1 n2 <command>
  12441.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12442.   numbers and the value of n1 is less than or equal to the value of n2.  This
  12443.   is equivalent to "if not > n1 n2".
  12444.  
  12445. IF >= n1 n2 <command>
  12446.   Executes the <command> if n1 and n2 are both numbers or variables containing
  12447.   numbers and the value of n1 is greater than or equal to the value of n2.
  12448.   Equivalent to "if not < n1 n2".
  12449.  
  12450. IF COMMAND <word> <command>
  12451.   Executes the <command> if <word> is a built-in C-Kermit command.
  12452.   Example: "if not command copy define { copy run copy \%1 \%2 }".
  12453.   This defines a COPY macro that runs an external COPY command if COPY
  12454.   is not already a built-in command.
  12455.  
  12456. IF LOCAL <command>
  12457.   Executes the <command> if Kermit is in local mode, i.e. if it has a
  12458.   SET LINE, SET PORT, or SET HOST (TELNET, RLOGIN, etc) device or connection
  12459.   open.  Does not execute the command if in remote mode.
  12460.  
  12461. IF MATCH <string> <pattern> <command>
  12462.   Executes the <command> if the <string> matches the <pattern>.  For a
  12463.   description of the syntax for the pattern, see Section 4.9.1.  If you want
  12464.   to test if the string contains pattern, use IF \fsearch(pattern,string).
  12465.  
  12466. IF OPEN { DEBUG-LOG, SESSION-LOG, TRANSACTION-LOG, ... } <command>
  12467.   Executes the <command> if the given file is open, fails if it is not open.
  12468.   Type IF OPEN ? for a complete list of files that can be checked (all the
  12469.   files that can be opened with the OPEN or LOG commands).
  12470.  
  12471. IF QUIET <command>
  12472.   Executes the command if SET QUIET is ON, and does not execute it if
  12473.   SET QUIET is OFF.  Example: IF NOT QUIET ECHO { This is a message.}.
  12474.  
  12475. IF READABLE <name>
  12476.   Succeeds if <name> is the name of an existing file or directory that is
  12477.   readable.
  12478.  
  12479. IF WRITEABLE <name>
  12480.   Succeeds if <name> is the name of an existing file or directory that is
  12481.   writeable, e.g.:
  12482.  
  12483.     if not writeable \v(lockdir) echo Please read installation instructions!
  12484.  
  12485. IF FLAG <command>
  12486.   This tests a user-settable condition, which can mean anything you like.
  12487.   SET FLAG ON causes subsequent IF FLAG commands to succeed; SET FLAG OFF
  12488.   causes them to fail.  One way to use it would be for debugging your
  12489.   scripts; precede any debugging statements with IF FLAG.  Then SET FLAG on
  12490.   to debug your script, SET FLAG OFF to run it without debugging.  Another
  12491.   common use is for causing an inner loop to cause an outer loop to exit.
  12492.  
  12493. IF C-KERMIT <command>
  12494.   C-Kermit, but not Kermit 95 or MS-DOS Kermit, executes the <command>.
  12495.  
  12496. IF K-95 <command>
  12497.   Kermit 95, but not C-Kermit or MS-DOS Kermit, executes the <command>.
  12498.  
  12499. IF MS-KERMIT <command>
  12500.   MS-DOS Kermit, but not C-Kermit or Kermit 95, executes the <command>.
  12501.  
  12502. 7.5. Using More than Ten Macro Arguments
  12503.  
  12504. The \v(argc) variable now gives the actual number of arguments, even if the
  12505. number is greater than 9:
  12506.  
  12507.   C-Kermit> define xx echo \v(argc)
  12508.   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
  12509.   27
  12510.  
  12511. Remember that \v(argc) includes the name of the macro itself, so it is always
  12512. at least 1, and is always 1 greater than the actual number of arguments.  As
  12513. in versions 6.0 and earlier, if more than 9 arguments are given, only the
  12514. first nine are assigned to the variables \%1..\%9.
  12515.  
  12516. The \&_[] array, discussed on page 353 of "Using C-Kermit", 2nd ed, now holds
  12517. all the arguments, up to some implementation-dependent limit (64 or greater),
  12518. rather than only the first 9.  To illustrate: the following macro tells the
  12519. number of arguments it was called with and then prints them:
  12520.  
  12521.   define show_all_args {
  12522.       local \%i
  12523.       echo \&_[0] - Number of arguments: \feval(\v(argc)-1)
  12524.       for \%i 1 \v(argc)-1 1 { echo \flpad(\%i,3). "\&_[\%i]" }
  12525.   }
  12526.  
  12527. Within a macro \&_[0], like \%0, contains the name of the macro.
  12528.  
  12529. At top level, the \&_[] array is filled as follows:
  12530.  
  12531.  . If the first argument on the C-Kermit command line was a filename,
  12532.    or C-Kermit was invoked from a "Kerbang" script (Section 7.19), element
  12533.    0 contains the filename, and elements 1 through \v(argc)-1 hold the
  12534.    remaining command-line arguments.
  12535.  
  12536.  . Otherwise the program name goes in element 0, and elements 1 through
  12537.    \v(argc)-1 hold any arguments that were included after "--" or "="
  12538.  
  12539. The new \%* variable, when used within a macro, is replaced by the text that
  12540. followed the macro name in the macro invocation.  If no arguments were given,
  12541. \%* is replaced by the empty string.  Examples:
  12542.  
  12543.   C-Kermit> define xx echo [\%*]
  12544.   C-Kermit> define \%a oofa
  12545.   C-Kermit> xx
  12546.   []
  12547.   C-Kermit> xx \%a
  12548.   [oofa]
  12549.   C-Kermit> xx a
  12550.   [a]
  12551.   C-Kermit> xx a b
  12552.   [a b]
  12553.   C-Kermit> xx a b c
  12554.   [a b c]
  12555.   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
  12556.   [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]
  12557.  
  12558. Note that \%* can not be used at top level, since Kermit does not have
  12559. access to the raw command line (only to its elements separately, after they
  12560. have been processed by the shell and the C library).
  12561.  
  12562. C-Kermit 7.0 also adds a SHIFT command:
  12563.  
  12564. SHIFT [ number ]
  12565.   Shifts the macro arguments (except argument 0) the given number of places
  12566.   to the left and adjusts \v(argc) accordingly.  The default number is 1.
  12567.  
  12568. To illustrate, suppose macro XXX is invoked as follows:
  12569.  
  12570.   xxx arg1 arg2 arg3
  12571.  
  12572. Then inside XXX, \%1 is "arg1", \%2 is "arg2", and \%3 is "arg3".  After a
  12573. SHIFT command is given inside XXX, then \%1 is "arg2", \%2 is "arg3", and \%3
  12574. is empty.  \%0 (the name of the macro) remains unchanged.
  12575.  
  12576. If more than 9 arguments were given, then arguments are shifted into the
  12577. \%1..9 variables from the argument vector array.
  12578.  
  12579. At top level, the SHIFT command operates on the \&_[] array and \%1..9
  12580. variables; the \&@[] array is not affected.  See Section 7.16 for details.
  12581.  
  12582. The \%* variable is not affected by the SHIFT command.
  12583.  
  12584. 7.6. Clarification of Function Call Syntax
  12585.  
  12586. Spaces are normally stripped from the front and back of each function
  12587. argument; to prevent this enclose the argument in braces:
  12588.  
  12589.   \fsplit(\%a,&a,{ })
  12590.  
  12591. However, function calls that contain spaces can make trouble when the function
  12592. is to be used in a "word" field, since space separates words.  For example:
  12593.  
  12594.   for \%i 1 \fsplit(\%a,&a,{ }) 1 {
  12595.     echo \%i. "\&a[\%i]"
  12596.   }
  12597.  
  12598. In most cases, the trouble can be averted by enclosing the function reference
  12599. in braces:
  12600.  
  12601.   for \%i 1 {\fsplit(\%a,&a,{ })} 1 {
  12602.     echo \%i. "\&a[\%i]"
  12603.   }
  12604.  
  12605. or by replacing spaces with \32 (the ASCII code for space):
  12606.  
  12607.   for \%i 1 \fsplit(\%a,&a,\32) 1 {
  12608.     echo \%i. "\&a[\%i]"
  12609.   }
  12610.  
  12611. Braces are also used in function calls to indicate grouping.  For example:
  12612.  
  12613.   \fsubstring(abcd,2,2) = "bc"
  12614.  
  12615. But suppose "abcd" needed to contain a comma:
  12616.  
  12617.   \fsubstring(ab,cd,2,2)
  12618.  
  12619. This would cause an error, since "cd" appears to be the second argument, when
  12620. really you want the first "2" to be the second argument.  Braces to the rescue:
  12621.  
  12622.   \fsubstring({ab,cd},2,2) = "b,"
  12623.  
  12624. Similarly, leading and trailing spaces are stripped from each argument, so:
  12625.  
  12626.   \fsubstring( abcd ,2,2) = "bc"
  12627.  
  12628. but braces preserve them:
  12629.  
  12630.   \fsubstring({ abcd },2,2) = "ab"
  12631.  
  12632. Given these special uses for braces, there is no way to pass literal braces to
  12633. the function itself.  For example:
  12634.  
  12635.   \fsubstring(ab{cd,2,2)
  12636.  
  12637. causes an error.
  12638.  
  12639. So if you need a function to include braces, define a variable containing the
  12640. string that has braces.  Example:
  12641.  
  12642.   define \%a ab{cd
  12643.   \fsubstring(\%a,2,2) = "b{"
  12644.  
  12645. If the string is to start with a leading brace and end with a closing brace,
  12646. then double braces must appear around the string (which itself is enclosed in
  12647. braces):
  12648.  
  12649.   define \%a {{{foo}}}
  12650.   \fsubstring(\%a) = "{foo}"
  12651.  
  12652. This also works for any other kind of string:
  12653.  
  12654.   define \%a {{ab{cd}}
  12655.   echo \fsubstring(\%a) = "ab{cd"
  12656.  
  12657. 7.7. Autodownload during INPUT Command Execution
  12658.  
  12659. As of 6.1 / 1.1.12, C-Kermit can be told to look for incoming Kermit (or
  12660. Zmodem) packets during execution of an INPUT command.  By default (for
  12661. consistency with earlier releases), this is not done.  You can enable this
  12662. feature with:
  12663.  
  12664.   SET INPUT AUTODOWNLOAD ON
  12665.  
  12666. (and disable it again with OFF.)
  12667.  
  12668. One possible use for this feature is as a server mode with a time limit:
  12669.  
  12670.   INPUT 3600 secret-string-to-end-the-INPUT-command
  12671.  
  12672. In this example, any GET, SEND, or REMOTE commands received within one hour
  12673. (3600 seconds) of when the INPUT command was issued will be executed.  Here's
  12674. another example, in which we want to stay open until 11:30pm, or until
  12675. interrupted by seven consecutive Ctrl-C (\3) characters:
  12676.  
  12677.   INPUT 23:30:00 \3\3\3\3\3\3\3
  12678.  
  12679. The INPUT AUTODOWNLOAD setting is displayed by SHOW SCRIPTS or SHOW INPUT.
  12680.  
  12681. 7.8. Built-in Help for Functions.
  12682.  
  12683. Beginning in C-Kermit 7.0, you may obtain a description of the calling
  12684. conventions and return values of any built-in function, such as
  12685. \fsubstring(), with the new HELP FUNCTION command; give the function's
  12686. name without the leading "\f", e.g. "help func substring".  You can use ?,
  12687. completion, and abbreviation in the normal manner.
  12688.  
  12689. 7.9. Variable Assignments
  12690.  
  12691. 7.9.1. Assignment Operators
  12692.  
  12693. Programmers accustomed to languages such as C or Fortran might find Kermit's
  12694. method of assigning values to variables unnatural or awkward.  Beginning in
  12695. C-Kermit 7.0, you can use the following alternative notation:
  12696.  
  12697.  .name = value    is equivalent to   DEFINE name value
  12698.  .name := value   is equivalent to   ASSIGN name value
  12699.  .name ::= value  is equivalent to   ASSIGN name \feval(value)
  12700.  
  12701. When the command begins with a period (.), this indicates an assignment.
  12702. The name can be a macro name, a \%{digit,letter} variable, or an array
  12703. element.  There can be space(s) between "." and the name.  Examples:
  12704.  
  12705.   .\%a = This is a string  ; Same as "define \%a This is a string"
  12706.   echo \%a
  12707.   This is a string
  12708.  
  12709.   .xxx = \%a               ; Same as "define xxx \%a"
  12710.   echo \m(xxx)
  12711.   \%a
  12712.  
  12713.   .xxx := \%a              ; Same as "assign xxx \%a"
  12714.   echo \m(xxx)
  12715.   This is a string
  12716.  
  12717.   declare \&a[2]           ; Use with arrays...
  12718.   define \%i 2
  12719.   .\&a[1] = first
  12720.   .\&a[\%i] = second
  12721.  
  12722. The following sequence illustrates the differences among three levels of
  12723. evaluation:
  12724.  
  12725.   .\%x = 2          ; Define a variable to have a numeric value
  12726.   .\%y = (3 + \%x)  ; Define another variable as an arithmetic expression
  12727.  
  12728.   .xxx = 4 * \%y    ; "=" simply copies the right-hand side.
  12729.   echo \m(xxx)
  12730.   4 * \%y
  12731.  
  12732.   .xxx := 4 * \%y   ; ":=" evaluates the variables first, then copies.
  12733.   echo \m(xxx)
  12734.   4 * (3 + 2)
  12735.  
  12736.   .xxx ::= 4 * \%y  ; "::=" evaluates the expression, then copies.
  12737.   echo \m(xxx)
  12738.   20
  12739.  
  12740. You can also use this syntax to clear (undefine) a variable:
  12741.  
  12742.   .\%a = oofa       ; Define the variable
  12743.   echo "\%a"
  12744.   "oofa"
  12745.   .\%a              ; Clear the variable
  12746.   echo "\%a"
  12747.   ""
  12748.  
  12749. Extra credit: Can you guess what happens below when the file "abc" does not
  12750. exist?
  12751.  
  12752.   fopen /read \%c abc
  12753.   if fail ...
  12754.  
  12755. 7.9.2. New Assignment Commands
  12756.  
  12757. Recall the DEFINE and ASSIGN commands, and their hidden counterparts,
  12758. _DEFINE and _ASSIGN.  The former take the variable name literally, the latter
  12759. evaluate the variable-name field to form the variable name dynamically.
  12760. Examples:
  12761.  
  12762.   DEFINE \%x foo    ; Sets the value of the variable \%x to "foo".
  12763.   DEFINE \%a \%x    ; Sets the value of the variable \%a to "\%x".
  12764.   _DEFINE x_\%a \%x ; Sets the value of the variable x_foo to "\%x".
  12765.   ASSIGN \%a \%x    ; Sets the value of the variable \%a to the "foo".
  12766.   _ASSIGN x_\%a \%x ; Sets the value of the variable x_foo to "foo".
  12767.  
  12768. This concept has been carried over to the remaining variable-assignment
  12769. commands: EVALUATE, INCREMENT, and DECREMENT:
  12770.  
  12771. EVALUATE <variablename> <expression>
  12772.   Evaluates the arithmetic <expression> and assigns its value to the
  12773.   variable whose name is given.  Example: "eval \%a 1+1" assigns "2" to \%a.
  12774.  
  12775. _EVALUATE <metaname> <expression>
  12776.   Evaluates the arithmetic <expression> and assigns its value to the
  12777.   variable whose name is computed from the given <metaname>.  Example:
  12778.   "eval foo<\%a>::\%1 \%2 * (\%3 + \%4)" assigns the value of
  12779.   "\%2 * (\%3 + \%4)" to the variable whose name is computed from
  12780.   "foo<\%a>::\%1".
  12781.  
  12782. INCREMENT <variablename> <expression>
  12783.   Evaluates the arithmetic <expression> and adds its value to the
  12784.   value of the variable whose name is given.  Example: "increment \%a".
  12785.  
  12786. _INCREMENT <metaname> <expression>
  12787.   Evaluates the arithmetic <expression> and adds its value to the
  12788.   value of the variable whose name is computed from the given <metaname>.
  12789.   Example: "_increment Words::\%1.count[\%2]".
  12790.  
  12791. DECREMENT <variablename> <expression>
  12792.   Evaluates the arithmetic <expression> and subtracts its value from the
  12793.   value of the variable whose name is given.
  12794.  
  12795. _DECREMENT <metaname> <expression>
  12796.   Evaluates the arithmetic <expression> and subtracts its value from the
  12797.   value of the variable whose name is computed from the given <metaname>.
  12798.  
  12799. WARNING: The syntax of the EVALUATE command has changed since C-Kermit 6.0
  12800. and K95 1.1.17.  Previously, it did not include a variable name, only an
  12801. expression.  To restore the old behavior, use SET EVALUATE OLD.  To return
  12802. to the new behavior after restoring the old behavior, use SET EVALUATE NEW.
  12803.  
  12804. NOTE: There are no analogs to the "_" commands for the operators described
  12805. in Section 7.9.1; those operators can not be used to assign values to
  12806. variables whose names must be computed.
  12807.  
  12808. 7.10. Arrays
  12809.  
  12810. C-Kermit 7.0 adds lots of new array-related features, and groups them together
  12811. under the NEW ARRAY command:
  12812.  
  12813.   ARRAY { CLEAR, COPY, DECLARE, DESTROY, RESIZE, SHOW, SORT }
  12814.  
  12815. In each of the ARRAY commands, wherever an array name is expected, "short
  12816. forms" may be used.  For example, all of the following are acceptable:
  12817.  
  12818.   array show \&a[]  (or SHOW ARRAY...)
  12819.   array show &a[]
  12820.   array show a[]
  12821.   array show &a
  12822.   array show a
  12823.  
  12824. In addition, ranges are accepted in the ARRAY COPY, ARRAY CLEAR, ARRAY SET,
  12825. ARRAY SHOW, and ARRAY SORT commands:
  12826.  
  12827.   array clear \&a[16]     ; Clears 16 thru end
  12828.   array clear &a[16]      ; Ditto
  12829.   array clear a[16]       ; Ditto
  12830.  
  12831.   array clear \&a[16:32]  ; Clears 16 thru 32
  12832.   array clear &a[16:32]   ; Ditto
  12833.   array clear a[16:32]    ; Ditto
  12834.  
  12835. When using array names as function arguments, you must omit the "\" and you
  12836. must include the "&".  You may optionally include empty brackets.  Examples:
  12837.  
  12838.   \fsplit(\%a,a)          ; Bad
  12839.   \fsplit(\%a,\&a)        ; Bad
  12840.   \fsplit(\%a,&a[3])      ; Bad
  12841.  
  12842.   \fsplit(\%a,&a)         ; Good
  12843.   \fsplit(\%a,&a[])       ; Good
  12844.  
  12845. 7.10.1. Array Initializers
  12846.  
  12847. Beginning in C-Kermit 7.0, you may initialize an array -- in whole or in part
  12848. -- in its declaration:
  12849.  
  12850.   [ ARRAY ] DECLARE <array-name>[<size>] [ = ] [ <value1> [ <value2> [...] ] ]
  12851.  
  12852. For compatibility with versions 5A and 6.0, the ARRAY keyword is optional.
  12853. DECLARE can also be spelled DCL.
  12854.  
  12855. Initializers are (a) optional, (b) start with element 1, (c) must be enclosed
  12856. in braces if they contain spaces, and (d) are evaluated according to normal
  12857. rules by the DECLARE command prior to assignment.  Thus the assignments made
  12858. here are the same as those made by the ASSIGN command.  This allows you to
  12859. initialize array elements from the values of other variables.  If you actually
  12860. want to initialize an array element to variable's name, as opposed to its
  12861. value, use double backslashes (as in "\\&a", "\\v(time)", etc).
  12862.  
  12863. The <size> (dimension) of the array is optional.  If the size is omitted, as
  12864. in "\&a[]", then the array sizes itself to the number of initializers; if
  12865. there are no initializers the array is not declared or, if it was declared
  12866. previously, it is destroyed.  If a size is given, any extra elements in the
  12867. initialization list are discarded and ignored.
  12868.  
  12869. NOTE: Unlike in C, the list of initializers is NOT enclosed in braces.
  12870. Instead, braces are used to group multiple words together.  So:
  12871.  
  12872.   ARRAY DECLARE \&a[] = { one two three }
  12873.  
  12874. would create an array with two elements (0 and 1), with element 1 having
  12875. the value " one two three ".
  12876.  
  12877. Examples:
  12878.  
  12879. ARRAY DECLARE \&a[16]
  12880.   Declares the array \&a with 17 elements (0 through 16), in which all
  12881.   elements are initially empty.  If the array \&a[] existed before, the
  12882.   earlier copy is destroyed.
  12883.  
  12884. ARRAY DECLARE &a[16]
  12885. ARRAY DECLARE a[16]
  12886. ARRAY DCL \&a[16]
  12887. ARRAY DCL &a[16]
  12888. ARRAY DCL a[16]
  12889. DECLARE \&a[16]
  12890. DECLARE &a[16]
  12891. DECLARE a[16]
  12892. DCL \&a[16]
  12893. DCL &a[16]
  12894. DCL a[16]
  12895.   All of the above are the same as the first example.
  12896.  
  12897. ARRAY DECLARE \&a[16] = alpha beta {gamma delta}
  12898.   Declares the array \&a with 17 elements (0 through 16), initializing \&a[1]
  12899.   to "alpha", \&a[2] to "beta", and \&a[3] to "gamma delta".  The remaining
  12900.   elements are empty.
  12901.  
  12902. ARRAY DECLARE \&a[] = alpha beta {gamma delta}
  12903.   Same as the previous example, but the array is automatically dimensioned
  12904.   to 3.
  12905.  
  12906. ARRAY DECLARE \&a[3] = alpha beta {gamma delta} epsilon zeta
  12907.   Too many initializers; only the first three are kept.
  12908.  
  12909. ARRAY DECLARE \&a[0]
  12910. ARRAY DECLARE \&a[]
  12911. ARRAY DECLARE &a[]
  12912. ARRAY DECLARE &a
  12913. ARRAY DECLARE a
  12914. DECLARE \&[0]
  12915. DECLARE a
  12916. DCL a
  12917.   All of these are equivalent.  Each destroys \&a[] if it exists.  Declaring
  12918.   an array with a dimension of 0 is the same as ARRAY DESTROY <arrayname>.
  12919.  
  12920. ARRAY DECLARE \&a[] = \%1 \%2 \%3
  12921.   Declares the array \&a with 3 elements (0 through 3), initializing \&a[1]
  12922.   to the value of \%1, \&a[2] to the value of \%2, and \&a[3] to the value of
  12923.   \%3.  In this case, any reference to one of these array elements is replaced
  12924.   by the value of the corresponding \%n variable at the time the declaration
  12925.   was executed (immediate evaluation; the array element's value does not
  12926.   change if the initializer variable's value changes).
  12927.  
  12928. ARRAY DECLARE \&a[] = \\%1 \\%2 \\%3
  12929.   Declares the array \&a with 3 elements (0 through 3), initializing \&a[1]
  12930.   to the string "\%1", \&a[2] to "\%2", and \&a[3] to "\%3".  In this case any
  12931.   reference to one of these array elements is replaced by the CURRENT value
  12932.   of the corresponding \%n variable (deferred evaluation -- the array element's
  12933.   value follows the value of the initializer variable).
  12934.  
  12935. The equal sign (=) preceding the initializer list is optional, but is
  12936. recommended for clarity.  If you need to initialize element 1 to a literal
  12937. equal sign, use two of them, separated by a space, as in this example:
  12938.  
  12939.   ARRAY DECLARE \&a[] = = + - * /
  12940.  
  12941. Remember, element 0 is not initialized by the DECLARE command.  To initialize
  12942. element 0, use a regular DEFINE or ASSIGN command:
  12943.  
  12944.   ARRAY DECLARE \&a[] one two three four five six seven eight nine
  12945.   DEFINE \&a[0] zero
  12946.  
  12947. Finally, remember that every command level has its own local array, \&_[],
  12948. containing all the macro arguments (\%0, \%1, ...) for that level.  See
  12949. Section 7.5 for details.
  12950.  
  12951. 7.10.2. Turning a String into an Array of Words
  12952.  
  12953. The \fsplit(s1,&a,s2,s3) function assigns the words of string s1 to successive
  12954. elements of the array (beginning with element 1) whose identifying letter,
  12955. a-z, is given after the "&" in the second argument, using break and include
  12956. characters given in s2 and s3.  See Section 7.3 for details.
  12957.  
  12958. 7.10.3. Arrays of Filenames
  12959.  
  12960. See Section 4.11.3 for news about how \ffiles() and related functions
  12961. can assign a list of filenames to an array.  To recapitulate briefly here:
  12962.  
  12963.   \ffiles(*,&a)
  12964.  
  12965. assigns all files that match the first argument to the array denoted by the
  12966. second argument.  If the array has not been declared, it is declared
  12967. automatically, with exactly the number of elements needed to hold the file
  12968. list; if it was previously declared, it is destroyed and reused.  The
  12969. filenames are assigned starting at array element 1.  Element 0 holds the
  12970. number of files in the list.
  12971.  
  12972. The DIRECTORY command (Section 4.5.1) can also create filename arrays if you
  12973. give it the /ARRAY: switch; this allows selection criteria beyond whether the
  12974. filename matches the given pattern.
  12975.  
  12976. All functions and commands that create filename arrays store the number of
  12977. filenames, n, as element 0 of the array, and the filenames as elements 1
  12978. through n.
  12979.  
  12980. 7.10.4. Automatic Arrays
  12981.  
  12982. In a command file or macro, you can now have local (automatic) arrays.
  12983. Just give the name followed by empty subscript brackets (no spaces inside
  12984. the brackets please) in a LOCAL command, and then declare the array:
  12985.  
  12986.   LOCAL \%a \&a[] oofa
  12987.   ARRAY DECLARE \&a[32] = value1 value2 value3 ...
  12988.  
  12989. This declares the scalar variable \%a, the array \&a[], and the macro name
  12990. "oofa" to be local, and then declares the new local copy of \&a[] with 32
  12991. elements, perhaps assigning some initial values.  When C-Kermit exits from the
  12992. command file or macro containing these command, the previous \&a[] array is
  12993. restored (and if there was no \&a[] at any higher level, this will still be
  12994. true).  The process can be repeated to any level.  Thus it is now safe to
  12995. write scripts or macros containing arrays without danger of interfering with
  12996. global arrays of the same name.
  12997.  
  12998. Just as scalars are inherited by lower command levels, so are arrays.  So, for
  12999. example, if \&a[] is declared at top level, all lower levels will see it
  13000. unless they include a "local \&a[]" statement, in which case all levels at and
  13001. beneath the level where the LOCAL statement was executed will see the local
  13002. copy.  This too can be repeated to any level.
  13003.  
  13004. On the other hand, if you DECLARE an array at a lower command level without
  13005. also making it LOCAL, this replaces the copy that was declared at the lowest
  13006. command level above this one.
  13007.  
  13008. 7.10.5. Sorting Arrays
  13009.  
  13010. Although arrays can be sorted using FOR loops as shown on page 383 of "Using
  13011. C-Kermit" 2nd Ed., this involves quite a bit of repetitive interpretation by
  13012. the command parser, and so can be slow for large arrays.  For this reason,
  13013. C-Kermit 7.0 adds a built-in SORT command:
  13014.  
  13015. ARRAY SORT [ switches ] array [ array2 ]
  13016.   Sorts the given array in place.  Sorting is strictly lexical (string based).
  13017.   The array name can be given fully, e.g. \&a[]", or the \ and/or & and/or
  13018.   brackets can be omitted, e.g. "array sort \&a[]", "sort &a", "sort a".
  13019.   Also, a range can be indicated in the brackets as noted in section 7.10,
  13020.   to restrict the sort to a range of elements (equivalent to the /RANGE
  13021.   switch, described just below), e.g. "array sort &a[20:30]"
  13022.  
  13023. A second array may be specified.  If it is, and if it is at least as big as
  13024. the first array, it is sorted according to the first array.  For a sample
  13025. application, see Section 7.10.10.
  13026.  
  13027. See Section 1.5 for an explanation of switches.  The optional switches are:
  13028.  
  13029. /CASE:{ON,OFF}
  13030.   /CASE:ON means that alphabetic case is significant in comparisons; uppercase
  13031.   letters are sorted before lowercase ones.  /CASE:OFF means case is ignored,
  13032.   e.g. "A" is the same as "a".  If this switch is not given, sorting is
  13033.   according the current SET CASE setting.
  13034.  
  13035. /KEY:n
  13036.   Comparison begins at position n (1-based) in each string.  If no
  13037.   key is given, the entire strings are compared.  Only one key can be
  13038.   given.  If an array element is shorter than the key value, n, that element
  13039.   is considered empty for comparison purposes, and therefore lexically
  13040.   less than any element at least n characters long.
  13041.  
  13042. /NUMERIC
  13043.   If this switch is included, it means sorting should be numeric, rather than
  13044.   lexical.  The sort key is the string starting at the key position, skipping
  13045.   any leading blanks or tabs, and then as much of the string from that point
  13046.   on that fits the definition of "numeric", terminating at the first character
  13047.   that does not qualify.  A numeric string has an optional sign (+ or -)
  13048.   followed by one or more digits, and (if your version of Kermit was built
  13049.   with floating-point support; see Section 7.23) zero or one decimal point
  13050.   (period).  If both /CASE and /NUMERIC are given, /NUMERIC takes precedence.
  13051.  
  13052. /RANGE:n[:m]
  13053.   Sort elements n through m of the array.  By default, the entire array
  13054.   from element 1 to its dimensioned size is sorted, which might produce
  13055.   surprising results if the array is not full; see example in Section 7.10.7.
  13056.   If ":m" is omitted from the range, the dimensioned size is used.  Thus,
  13057.   to sort an entire array, \&a[], including its 0th element, use
  13058.   "sort /range:0 &a".  You can also sort any desired section of an
  13059.   array, e.g. "sort /range:10:20 &a" or "sort /range:\%i:\%j-1 &b".
  13060.   As noted above, you can also specify a range in the array-name brackets.
  13061.   If you specify a range in the array-name brackets AND with a /RANGE
  13062.   switch, the ones in the brackets take precedence.
  13063.  
  13064. /REVERSE
  13065.   Sort in reverse order.  If this switch is not given, the array is
  13066.   sorted in ascending order.
  13067.  
  13068. Remember that numeric switch arguments can be numbers, arithmetic expressions,
  13069. or variables whose values are numbers or expressions, as illustrated in the
  13070. /RANGE examples above.
  13071.  
  13072. A typical sorting application might be to list students' test scores in
  13073. descending order.  Suppose you had the following records:
  13074.  
  13075. olaf      65
  13076. olga      98
  13077. ivan      83
  13078. xena     100
  13079.  
  13080. (and so on) stored in array \&s[] (e.g. by reading them from a file as
  13081. illustrated in section 7.10.7).  In these records, the student's name
  13082. is in columns 1-9 and the score in 10-12.  So to rearrange the list in
  13083. descending order of score:
  13084.  
  13085.   sort /key:10 /reverse &s
  13086.  
  13087. Then to list your top five students:
  13088.  
  13089.   for \%i 1 5 1 { echo \&s[\%i] }
  13090.  
  13091. Or more simply (see next section):
  13092.  
  13093.   show array a[1:5]
  13094.  
  13095. To illustrate the difference between a lexical and a numeric sort, suppose
  13096. you have the following records (the lines that are numbered, starting at
  13097. column 1) in array \&a[]:
  13098.  
  13099.     Column   1         2
  13100.     12345678901234567890
  13101.  
  13102.  1. Ivan      10.0
  13103.  2. Olaf      9.95
  13104.  3. Olga       101.5
  13105.  
  13106. ARRAY SORT /KEY:10 &a[] would order them 3,1,2, but
  13107. ARRAY SORT /KEY:10 /NUMERIC &a[] would order them 2,1,3.
  13108.  
  13109. 7.10.6. Displaying Arrays
  13110.  
  13111. The SHOW ARRAY command (or ARRAY SHOW) now accepts an optional array-name
  13112. argument:
  13113.  
  13114.   SHOW ARRAY \&a[]
  13115.  
  13116. (you can leave off the \, the \&, and/or the []'s if you like; "show array a"
  13117. is equivalent to "show array \&a[]").  When an array is specified, its
  13118. dimension is shown and all defined (non-empty) elements are listed.
  13119.  
  13120. Example:
  13121.  
  13122.   assign \%n \ffiles(*,&a)  ; Fill an array with filenames (Section 4.11.3)
  13123.   show array \&a[]          ; Show the array we just read
  13124.   array show \&a[]          ; Same as previous
  13125.   array sort \&a[]          ; Sort the array
  13126.   array show \&a[]          ; Show it after sorting
  13127.   array show \&a            ; Show it again
  13128.   array show &a             ; Show it again
  13129.   array show a              ; Show it again
  13130.  
  13131. (The final four commands demonstrate the alternative forms that are accepted
  13132. for the array name.)
  13133.  
  13134. If you SHOW ARRAY without giving an array name, all defined arrays are
  13135. listed by name and dimension, but their contents are not shown.
  13136.  
  13137. You can also show a piece of an array by including a subscript or range
  13138. within the array brackets:
  13139.  
  13140.   array show \&a[5]         ; Shows \&a[5]
  13141.   array show &a[3:8]        ; Shows \&a[3] through \&a[8]
  13142.   array show a[:\%n-1]      ; Shows \&a[0] through \&a[\%n-1]
  13143.  
  13144. 7.10.7. Other Array Operations
  13145.  
  13146. ARRAY DESTROY <arrayname>
  13147.   Destroys and undeclares the named array.  Subscripts or ranges are not
  13148.   accepted in this command.
  13149.  
  13150. ARRAY COPY <array1> <array2>
  13151.   Copies the first array to the second array.  If the target array has not
  13152.   been declared, it is created automatically with the same size as the first.
  13153.   If it has been declared, it will be used as declared; if the source array
  13154.   is larger, only as much of it as will fit is copied to the target array.
  13155.   Syntax for <array1> and <array2> is as in ARRAY SHOW (SHOW ARRAY).
  13156.  
  13157.   Example:
  13158.     .\%n := \ffiles(*,&a)  ; Create and load array A with a file list.
  13159.     array copy &a &b       ; Copy array A to array B.
  13160.  
  13161.   The ARRAY COPY command also lets you copy pieces of arrays by including
  13162.   range specifiers:
  13163.  
  13164.   ARRAY COPY \&a[4:27] \&b
  13165.     This copies \&a[] elements 4-27 to \&b[] elements 1-23, creating \&b[]
  13166.     if necessary or, if \&b[] is already declared, stopping early if its size
  13167.     is less than 23.
  13168.  
  13169.   ARRAY COPY \&a[4:27] \&b[12]
  13170.     This copies \&a[] elements 4-27 to \&b[] elements 12-35, creating \&b[]
  13171.     if necessary or, if \&b[] is already declared, stopping early if its size
  13172.     is less than 35.
  13173.  
  13174.   ARRAY COPY \&a[4:27] \&b[12:14]
  13175.     This copies \&a[] elements 4-6 to \&b[] elements 12-14, creating \&b[]
  13176.     if necessary or, if \&b[] is already declared, stopping early if its size
  13177.     is less than 14.
  13178.  
  13179.   ARRAY COPY \&a[17] \&b
  13180.     This copies all the elements of \&a[] starting with 17 until the last
  13181.     to \&b[], creating \&b[] if necessary or, if \&b[] is already declared,
  13182.     stopping early if \&b[] is not big enough.
  13183.  
  13184. ARRAY CLEAR <arrayname>
  13185.   Sets all the elements of the array to the empty value.  You may also include
  13186.   a range specifier to clear only a selected portion of the array; for example
  13187.   "array clear \&a[37:214]".  If the range is out of bounds, only the part of
  13188.   the array that is in bounds is cleared.
  13189.  
  13190. ARRAY SET <arrayname> [ <value> ]
  13191.   Sets all the elements of the array to the given value.  If no value is
  13192.   given, the array is cleared.  You may also include a range specifier to set
  13193.   only a selected portion of the array; for example "array set \&a[1:9] -1".
  13194.   If the range is out of bounds, only the part of the array that is in bounds
  13195.   is set.
  13196.  
  13197. ARRAY RESIZE <arrayname> <size>
  13198.   Resizes the given array.  If the <size> is greater than the array's current
  13199.   dimension, new empty elements are added to the end.  If the <size> is less
  13200.   than the current dimension, the extra elements are discarded.  Note: If you
  13201.   have stored the array size in element 0, ARRAY RESIZE does not change this
  13202.   value.  Alternative notation: ARRAY RESIZE <arrayname>[<size>].  For a
  13203.   practical example, see Section 7.10.11.
  13204.  
  13205. \farraylook(<pattern>,<arrayname>)
  13206.   This function returns the index of the first element of the given array
  13207.   that matches the given pattern (for details about pattern syntax, see
  13208.   section 4.9).  The array name can include a range specification to restrict
  13209.   the search to a given segment of the array.  If no elements match the
  13210.   pattern, -1 is returned.
  13211.  
  13212. \ftablelook(keyword,arrayname[,delimiter])
  13213.   Looks in the given "table", which must be sorted, for the given keyword.
  13214.   The keyword need not be spelled out in full.  Pattern-matching characters
  13215.   should not be included as part of the keyword.  The function returns the
  13216.   index of the table element that uniquely matches the given keyword, or -1
  13217.   if none match, or -2 if more than 1 match.
  13218.  
  13219. A "table" is an array that is sorted in lexical order; each of its elements
  13220. may contain multiple fields, delimited by the given delimiter character or,
  13221. if no delimiter is specified, a colon (:).
  13222.  
  13223. The \farraylook() function does exactly what you tell it.  If you give it
  13224. a pattern that does not include wildcard characters (such as *, ?, etc), it
  13225. requires an exact match.  For example:
  13226.  
  13227.   \farraylook(oofa,&a)
  13228.  
  13229. searches for the first element of \&a[] whose value is "oofa".  But:
  13230.  
  13231.   \farraylook(oofa*,&a)
  13232.  
  13233. finds the first element whose value starts with "oofa", and;
  13234.  
  13235.   \farraylook(*oofa,&a)
  13236.  
  13237. finds the first element whose value ends with "oofa", and;
  13238.  
  13239.   \farraylook(*oofa*,&a)
  13240.  
  13241. finds the first element whose value contains "oofa".
  13242.  
  13243. Here's a simple demonstration of looking up patterns in arrays:
  13244.  
  13245.   local \&a[] \%x \%n
  13246.   declare \&a[] = zero one two three four five six seven eight nine ten
  13247.   while true {
  13248.       .\%x = 1
  13249.       .\%n = 0
  13250.       ask \%a { Pattern? }
  13251.       if not def \%a exit 0 Done.
  13252.       while <= \%x \fdim(&a) {
  13253.       .\%x := \farraylook(\%a,&a[\%x])
  13254.       if ( < \%x 0 ) break
  13255.           echo \flpad(\%x,3). \&a[\%x]
  13256.           increment \%x
  13257.           increment \%n
  13258.       }
  13259.       if ( < \%n 1 ) echo Pattern not found - "\%a"
  13260.   }
  13261.  
  13262. The array need not be sorted.  When a pattern is given, a search is performed;
  13263. if there is a match, the matching element's index and the element itself are
  13264. printed, and the search begins again at the next element.  Thus each matching
  13265. element is printed.  If none match, the "Pattern not found" message is
  13266. printed.  The process repeats for as many patterns as the user wants to type,
  13267. and terminates when the user types an empty pattern.
  13268.  
  13269. Now let's build a little command parser, consisting of a keyword table,
  13270. and a loop to look up the user's commands in it with \ftablelook().  In this
  13271. case the array elements have "fields" separated by colon (:) -- a keyword
  13272. and a value.  Keyword tables must be sorted if \tablelook() is to work right,
  13273. so after declaring and initializing the table array, we sort it.
  13274.  
  13275.   local \&k[] \%a \%i \%n
  13276.  
  13277.   array declare \&k[] = drive:9 do:8 discuss:7 live:6 spend:5 help:4 quit:0
  13278.  
  13279.   array sort &k                             ; Make sure array is sorted
  13280.   echo Type "help" for help.                ; Print greeting & instructions
  13281.  
  13282.   while true {                              ; Loop to get commands
  13283.       undefine \%a
  13284.       while not defined \%a {               ; Get a command
  13285.           ask \%a { Command? }
  13286.       }
  13287.       .\%n := \ftablelook(\%a,&k)           ; Look up the command
  13288.       switch \%n {                          ; Handle errors
  13289.         :-1, echo Not found - "\%a"         ; Doesn't match
  13290.              continue
  13291.         :-2, echo Ambiguous - "\%a"         ; Matches too many
  13292.              continue
  13293.       }
  13294.       switch \fword(\&k[\%n],2) {           ; Dispatch according to value
  13295.      :9, echo Driving..., break
  13296.      :8, echo Doing..., break
  13297.      :7, echo Discussing..., break
  13298.      :6, echo Living..., break
  13299.      :5, echo Spending..., break
  13300.          :4, echo { Commands (may be abbreviated):}
  13301.              for \%i 1 \fdim(&k) 1 {
  13302.                 echo {  \%i. \fword(\&k[\%i],1) }
  13303.              }
  13304.              break
  13305.          :0, exit 0 Bye!
  13306.          :default, stop 1 Internal error
  13307.       }
  13308.   }
  13309.  
  13310. In this example, keywords are "drive", "do", "discuss", etc, and their values
  13311. are unique numbers (values need not be numbers, and there need not be only one
  13312. value -- there can be 0, 1, 2, or more of them).  The user types a command,
  13313. which can be the whole word (like "help") or any abbreviation (like "hel",
  13314. "he", or just "h").  If this does not match any keywords, \ftablelook() returns
  13315. -1; if it matches more than one (as would "d"), it returns -2.  Otherwise
  13316. the array index is returned, 1 or higher.
  13317.  
  13318. Given the array index \%n, we can get the table values as follows:
  13319.  
  13320.   \fword(\&k[\%n],1) is the keyword (first field)
  13321.   \fword(\&k[\%n],2) is the value (second field, in this case a number)
  13322.  
  13323. In our example, we use the value (number) as the SWITCH variable.  As noted,
  13324. \fablelook() expects the array elements to contain multiple fields separated
  13325. by colon (:) (or other character that you specify, e.g. \ftablelook(\%a,&a,^))
  13326. and when matching the keyword, ignores the first delimiter and everything
  13327. after it.
  13328.  
  13329. 7.10.8. Hints for Using Arrays
  13330.  
  13331. C programmers are accustomed to out-of-bounds array references causing core
  13332. dumps or worse.  In C-Kermit:
  13333.  
  13334.  . A reference to an an out-of-bounds array element returns the empty string.
  13335.  
  13336.  . An attempt to set the value of an array element that is out of bounds
  13337.    or that has not been declared simply fails.
  13338.  
  13339. C programmers expect an array of size n to have elements 0 through n-1.
  13340. Fortran programmers expect the same array to have elements 1 through n.
  13341. C-Kermit accommodates both styles; when you declare an array of size n, it
  13342. has n+1 elements, 0 through n, and you can use the array in your accustomed
  13343. manner, 0-based or 1-based.
  13344.  
  13345. However, note that C-Kermit has certain biases towards 1-based arrays:
  13346.  
  13347.  . Assignment of file lists starts with element 1 (Section 7.10.3).
  13348.  
  13349.  . Assignment by \fsplit() starts with element 1 (Section 7.3).
  13350.  
  13351.  . Array initialization skips the 0th element.  To initialize a 0-based
  13352.    array, use something like this:
  13353.  
  13354.      declare \&a[3] = one two three
  13355.      .\&a[0] = zero
  13356.  
  13357.  . The ARRAY SORT command skips the 0th element unless you include /RANGE:0
  13358.  
  13359.  . The SHIFT command ignores element 0 of the \&_[] array.
  13360.  
  13361. The distinction between an array's dimensioned size and the number of elements
  13362. in the array is important when sorting.  To illustrate:
  13363.  
  13364.   declare \&a[100]                  ; Declare array &a with 100 elements
  13365.   fopen /read \%c oofa.txt          ; Open a file
  13366.   if fail...
  13367.   for \%i 1 \fdim(&a) 1 {           ; Read the file into the array
  13368.       fread \%c \&a[\%i]
  13369.       if fail break
  13370.   }
  13371.   fclose \%c
  13372.   if > \%i \fdim(&a) end 1 File has too many lines for array.
  13373.   .\%n ::= \%i - 1
  13374.   echo File has \%n line(s).
  13375.  
  13376. Let's say the file had 95 lines.  This leaves elements 96-100 of the array
  13377. empty.  Now suppose you sort the array and write out the result:
  13378.  
  13379.   sort &a                           ; Sort the whole array
  13380.   fopen /write \%o oofa.txt.sorted  ; Open an output file
  13381.   if fail ...
  13382.   for \%i 1 \%n 1 {                 ; Write out 95 records
  13383.       fwrite /line \%o \&a[\%i]
  13384.       if fail end 1 Write error
  13385.   }
  13386.   close write
  13387.  
  13388. You might be surprised at the contents of "oofa.txt.sorted" -- five empty
  13389. elements, 96-100, floated to the top of the array in the sort, and since your
  13390. write loop only had 95 iterations, the final 5 lines of the sorted file are
  13391. lost.
  13392.  
  13393. Therefore, when dealing with partially filled arrays -- especially when
  13394. sorting them -- remember to specify the number of elements.  A handy way of
  13395. recording an array's "true" size is to put it in the 0th element.  That way,
  13396. it "travels with the array".  To illustrate (continuing the previous example
  13397. at the "close read" statement):
  13398.  
  13399.   close read
  13400.   if > \%i \fdim(&a) end 1 File has too many lines for array.
  13401.   .\&a[0] ::= \%i - 1     ; Assign number of lines to \&a[0].
  13402.   echo File has \&a[0] line(s).
  13403.   sort /range:1:\&a[0] &a
  13404.   open write oofa.txt.sorted
  13405.   if fail ...
  13406.   for \%i 1 \&a[0] 1 {
  13407.       writeln file \&a[\%j]
  13408.       if fail end 1 Write error
  13409.   }
  13410.   close write
  13411.  
  13412. Note the SORT switch, /RANGE:1:\&a[0].  This keeps the sort 1-based, and uses
  13413. element 0 of the array as its size indicator.
  13414.  
  13415. Finally, note that even though some commands or functions might put a size
  13416. in array element 0, no built-in functions or commands depend on a size
  13417. actually being there.  Thus you are perfectly free to replace the size with
  13418. something else and treat the array as 0-based.
  13419.  
  13420. 7.10.9. Do-It-Yourself Arrays
  13421.  
  13422. Kermit's \&x[] arrays are nice because of the accompanying built-in
  13423. functionality -- ARRAY commands, built-in functions that load and search
  13424. arrays, automatic evaluation of arithmetic expressions within the subscript
  13425. brackets, and so on.  Yet they also have certain limitations:
  13426.  
  13427.  a. Except when created by dynamic loading (e.g. by \ffiles()) they must
  13428.     be declared and dimensioned in advance.
  13429.  
  13430.  b. Indices must be numeric, positive, and in range.
  13431.  
  13432.  c. There can be only one dimension.  Matrices or other higher-dimensioned
  13433.     arrays are not available.
  13434.  
  13435. But none of this is to say you can't invent any kind of data structure you
  13436. like.  In Section 7.9.2 you can see some examples.  Here's another (courtesy
  13437. of Dat Thuc Nguyen), in which a pair of matrices is created and then added: no
  13438. dimensioning necessary.
  13439.  
  13440.   .row = 4
  13441.   .col = 9
  13442.  
  13443.   ; MACRO TO PRINT A MATRIX
  13444.   define PMATRIX {
  13445.       echo Matrix \%1:
  13446.       for \%r 1 \m(row) 1 {
  13447.       for \%c 1 \m(col) 1 {
  13448.           xecho \flpad(\m(\%1[\%r][\%c]),4)
  13449.       }
  13450.       echo
  13451.       }
  13452.       echo
  13453.   }
  13454.   ; CREATE MATRICES A AND B
  13455.   for \%r 1 \m(row) 1 {
  13456.       for \%c 1 \m(col) 1 {
  13457.       _eval A[\%r][\%c] \%r + \%c
  13458.       _eval B[\%r][\%c] \%r * \%c
  13459.       }
  13460.   }
  13461.   ; CREATE MATRIX C = SUM OF MATRIX A AND MATRIX B
  13462.   for \%r 1 \m(row) 1 {
  13463.       for \%c 1 \m(col) 1 {
  13464.       _eval C[\%r][\%c] \m(A[\%r][\%c]) + \m(B[\%r][\%c])
  13465.       }
  13466.   }
  13467.   pmatrix A  ; Print Matrix A
  13468.   pmatrix B  ; Print Matrix B
  13469.   pmatrix C  ; Print Matrix C
  13470.  
  13471. In the example, we use matrix-like notation to create macros with names
  13472. like "A[1][1]", "B[3][7]", and so on.
  13473.  
  13474. 7.10.10. Associative Arrays
  13475.  
  13476. An associative array is a special kind of Do-It-Yourself array.  It differs
  13477. from a regular array in that its indices need not be numbers -- they can be
  13478. anything at all -- words, filenames, names of months, any character string at
  13479. all, and that it doesn't have to be (and in fact can't be) declared.  An
  13480. associative array element is simply a macro whose name ends with an index
  13481. enclosed in angle brackets, for example:
  13482.  
  13483.   file<oofa.txt>
  13484.  
  13485. More formally:
  13486.  
  13487.   basename<index>
  13488.  
  13489. An associative array is a collection of all associative array elements that
  13490. have the same basename.  Any number of associative arrays, each with any
  13491. number of elements, can exist at the same time.
  13492.  
  13493. An associative array element can be assigned a value, such as "1", just like
  13494. any other macro:
  13495.  
  13496.   define file<oofa.txt> 1     ; Give "file<oofa.txt>" the value "1".
  13497.  
  13498. or:
  13499.  
  13500.   assign file<oofa.txt> \%a   ; Give it the value of the variable \%a.
  13501.  
  13502. However, since an associative array element is a macro, it may not have an
  13503. empty (null) value, since assigning an empty value to a macro undefines the
  13504. macro.
  13505.  
  13506. You can refer to the value of an associative array element using the familiar
  13507. notation for macro values:
  13508.  
  13509.   echo \m(file<oofa.txt>)     ; Echo the value of "file<oofa.txt>".
  13510.  
  13511. Associative arrays are most useful, however, when the value of the index is
  13512. a variable.  In that case, you must use the "hidden" forms of the DEFINE or
  13513. ASSIGN commands that evaluate the macro name before making the assignment (see
  13514. "Using C-Kermit", page 457).  Example:
  13515.  
  13516.   define \%f oofa.txt
  13517.   _define file<\%f> 1
  13518.   echo file<\%f> = \m(file<\%f>)
  13519.  
  13520. prints:
  13521.  
  13522.   file<oofa.txt> = 1
  13523.  
  13524. and then:
  13525.  
  13526.   _increment file<\%f>
  13527.   echo file<\%f> = \m(file<\%f>)
  13528.  
  13529. prints:
  13530.  
  13531.   file<oofa.txt> = 2
  13532.  
  13533. What are associative arrays good for?  The classic example is "word counts":
  13534. finding the number of times each word is used in a text without knowing in
  13535. advance what the words are.  Without associative arrays, your program would
  13536. have to build a table of some kind, and every time a word was encountered,
  13537. look it up in the table to find its position and counter, or add it to the
  13538. table if it wasn't found -- a time-consuming and laborious process.
  13539. Associative arrays, however, let you use the word itself as the table index
  13540. and therefore sidestep all the table building and lookups.
  13541.  
  13542. Let's work through a practical example.  Suppose you have a file-transfer log
  13543. in which each line is composed of a number of blank-separated fields, and the
  13544. 9th field is a filename (which happens to be the format of certain FTP server
  13545. logs, as well as of C-Kermit's new FTP-format transaction log, described in
  13546. Section 4.17.2), for example:
  13547.  
  13548.   Wed Jul 14 09:35:31 1999 22 xx.mit.edu 13412 /pub/ftp/mm/intro.txt ....
  13549.  
  13550. and you want to find out how many times each file was transferred.  The
  13551. following code builds an associative array, file<>, containing the counts for
  13552. each file:
  13553.  
  13554.   local name line max \%c \%n          ; Declare local variables
  13555.   fopen /read \%c /var/log/ftpd.log    ; Open the log file (Section 1.22)
  13556.   if fail exit 1 Can't open log        ; Check
  13557.   while true {                         ; Loop for each record
  13558.       fread /line \%c line             ; Read a line
  13559.       if fail break                    ; Check for end of file
  13560.       .name := \fword(\m(line),9,{ })  ; Get 9th field = filename (Sec 7.3)
  13561.       _increment file<\m(name)>        ; Increment its counter (Sec 7.9.2)
  13562.   }
  13563.   fclose \%c                           ; Close file when done.
  13564.  
  13565. Note that _INCREMENT (and INCREMENT, and [_]DECREMENT) treat an empty (i.e.
  13566. nonexistent) variable as having a value of 0, and therefore creates the
  13567. variable with a value of 1.
  13568.  
  13569. At this point, if you told Kermit to "show macro file<", it would list the
  13570. associative array.  But since you don't necessarily know the names of the
  13571. files in the array, or even how many elements are in the array, how can you
  13572. use it in a script program?
  13573.  
  13574. The idea of creating macro names that include character-string indices
  13575. enclosed in angle brackets is perfectly arbitrary and doesn't depend on any
  13576. Kermit features that weren't already there -- we could just as easily have
  13577. used some other notation, such as "file[index]", "file:index", or
  13578. "file.index", and the code above would have worked just as well (with the
  13579. corresponding syntax adjustments).  But to be able to use an associative array
  13580. in a program after the array is built, we need a method of accessing all its
  13581. elements without knowing in advance what they are.  That's where the chosen
  13582. notation comes in.
  13583.  
  13584. First of all, any macro name that ends with "<xxx>" (where "xxx" is any
  13585. string) is case sensitive, unlike all other macro names, which are case
  13586. independent.  To illustrate, "file<oofa.txt>" and "file<OOFA.TXT>" are two
  13587. distinct macros, whereas "OOFA", "Oofa", and "oofa", when used as macro names,
  13588. are all the same.
  13589.  
  13590. Second, the new \faaconvert() function converts an associative array (that is,
  13591. all macros with names of the form "base<index>" that have the same "base"
  13592. part) into a pair of regular arrays and returns the number of elements:
  13593.  
  13594.   \faaconvert(name,&a[,&b])
  13595.  
  13596. "name" is the name of the associative array, without the angle brackets or
  13597. index ("file" in our example).
  13598.  
  13599. The second argument is the name of a regular array in which to store the
  13600. indices of the associative array (filenames in our example); if an array of
  13601. this name already exists, it is destroyed unless the array is LOCAL.  The
  13602. third argument is the name of another regular array in which to store the
  13603. values (the counts in our example), with the same rules about array name
  13604. collisions.  If you care only about the indices and not the values, you can
  13605. omit the third argument to \faaconvert().  In any case, the associative array
  13606. is converted, not copied: its elements are moved to the specified regular
  13607. arrays, so after conversion the original associative array is gone.
  13608.  
  13609. As with other array-loading functions, \faaconvert() sets element 0 of each
  13610. array to the number of elements in the array.
  13611.  
  13612. To continue our example:
  13613.  
  13614.   .max := 0                                   ; Maximum count
  13615.   .\%n := \faaconvert(file,&a,&b)             ; Convert
  13616.   for \%i 1 \%n 1 {                           ; Loop through values
  13617.       echo \flpad(\%i,3). \&a[\%i]: \&b[\%i]  ; Echo this pair
  13618.       if ( > \&b[\%i] \m(max) ) {             ; Check for new maximum
  13619.           .name := \&a[\%i]
  13620.           .max  := \&b[\%i]
  13621.       }
  13622.   }
  13623.   echo Most popular file: \m(name), accesses: \m(max)
  13624.  
  13625. This lists the files and counts and then announces which file has the highest
  13626. count.
  13627.  
  13628. Now suppose you want to sort the array pair created from an associative array.
  13629. In our example, \&a[] contains filenames, and \&b[] contains the associated
  13630. counts.  Here we take advantage of the ARRAY SORT command's ability to sort a
  13631. second array according to the first one:
  13632.  
  13633.   array sort /reverse /numeric &b &a          ; Descending sort by count
  13634.  
  13635. Now to see the top five files and their counts:
  13636.  
  13637.   echo The top 5 files are:
  13638.   for \%i 1 5 1 {                             ; Loop through top 5 values
  13639.       echo \flpad(\%i,3). \&a[\%i]: \&b[\%i]  ; Echo this pair
  13640.   }
  13641.  
  13642. 7.10.11. Transferring Array Contents to Other Computers
  13643.  
  13644. The SEND /ARRAY:arrayname command (Section 4.7.1) allows you to send the
  13645. contents of any array, or any contiguous segment of it, in either text or
  13646. binary mode to another computer, using Kermit protocol.  When used in
  13647. conjunction with C-Kermit's other features (the array features described in
  13648. this section; the file i/o package from Section 1.22; its decision-making,
  13649. pattern-matching, and string manipulation capabilities, and so on) the
  13650. possibilities are endless: extracts of large files, remote database queries,
  13651. ..., all without recourse to system-dependent mechanisms such UNIX pipes and
  13652. filters, thus ensuring cross-platform portability of scripts that use these
  13653. features.
  13654.  
  13655. When sending an array in text mode, Kermit appends a line terminator to each
  13656. array element, even empty ones, and it also converts the character set from
  13657. your current FILE character-set to your current TRANSFER character-set, if
  13658. any.  No conversions are made or line terminations added in binary mode.  For
  13659. example, the following array:
  13660.  
  13661.   dcl \&a[] = One Two Three Four Five Six
  13662.  
  13663. is sent as six lines, one word per line, in text mode, and as the bare
  13664. unterminated string "OneTwoThreeFourFiveSix" in binary mode.
  13665.  
  13666. You should always include a /TEXT or /BINARY switch in any SEND /ARRAY command
  13667. to force the desired transfer mode, otherwise you're likely to be surprised
  13668. by the effects described in Section 4.3.
  13669.  
  13670. Here are some examples:
  13671.  
  13672. send /text /array:\&a[]
  13673.   Sends the entire contents of the array \&a[] in text mode.  Since an
  13674.   as-name is not included, the receiver is told the filename is _array_a_.
  13675.  
  13676. send /text /array:&a[]
  13677. send /text /array:a[]
  13678. send /text /array:&a
  13679. send /text /array:a
  13680.   These are all equivalent to the previous example.
  13681.  
  13682. send /text /array:&a /as-name:foo.bar
  13683.   As above, but the array is sent under the name foo.bar.
  13684.  
  13685. send /text /array:&a[100:199] /as:foo.bar
  13686.   As above, but only the elements from 100 through 199 are sent.
  13687.  
  13688. In text-mode transfers, character sets are translated according to your
  13689. current settings, just as for text files.  In binary mode, of course, there
  13690. is no character-set translation or other conversion of any kind.  But
  13691. remember that array elements can not contain the NUL (ASCII 0) character,
  13692. since they are implemented as NUL-terminated strings.
  13693.  
  13694. Here's an example that shows how to send all the lines (up to 1000 of them)
  13695. from a file animals.txt that contain the words "cat", "dog", or "hog" (see
  13696. section 4.9 about pattern matching):
  13697.  
  13698.   declare \&a[1000]
  13699.   fopen /read \%c animals.txt
  13700.   if fail exit 1
  13701.   .\%i = 0
  13702.   while true {
  13703.       fread \%c line
  13704.       if fail break
  13705.       if match {\m(line)} {*{cat,[dh]og}*} {
  13706.           increment \%i
  13707.           if ( > \%i \fdim(&a) ) break
  13708.           .\&a[\%i] := \m(line)
  13709.       }
  13710.   }
  13711.   fclose \%c
  13712.   send /array:a[1:\%i] /text
  13713.  
  13714. Note that we are careful to send only the part of the array that was filled,
  13715. not the entire array, because there are likely to be lots of unused elements
  13716. at the end, and these would be sent as blank lines otherwise.
  13717.  
  13718. This example raises an interesting question: what if we want to send ALL the
  13719. matching lines, even if there are more than 1000 of them, but we don't know
  13720. the number in advance?  Clearly the problem is limited by Kermit's (and the
  13721. computer's) memory.  If there are a thousand trillion matching lines, they
  13722. most likely will not fit in memory, and in this case the only solution is to
  13723. write them first to a temporary file on mass storage and then send the
  13724. temporary file and delete it afterwards.
  13725.  
  13726. However, when the selection is likely to fit in memory, the once-familiar
  13727. technique of initial allocation with extents can be used:
  13728.  
  13729.       if match {\m(line)} {*{cat,[dh]og}*} {
  13730.           increment \%i
  13731.       if ( > \%i \fdim(&a) ) {
  13732.           array resize a \fdim(&a)+100
  13733.           if fail stop 1 MEMORY FULL
  13734.           echo NEW DIMENSION: \fdim(&a)
  13735.       }
  13736.           .\&a[\%i] := \m(line)
  13737.       }
  13738.  
  13739. This grows the array in chunks of 100 as needed.
  13740.  
  13741. 7.11. OUTPUT Command Improvements
  13742.  
  13743. LINEOUT [ <text> ]
  13744.   This command is exactly like OUTPUT, except it supplies a carriage return
  13745.   at the end of the <text>.  "lineout exit" is exactly the same as
  13746.   "output exit\13".
  13747.  
  13748. SET OUTPUT SPECIAL-ESCAPES { ON, OFF }
  13749.   This command lets you tell C-Kermit whether to process \N, \L, and \B
  13750.   specially in an OUTPUT command, as distinct from other \-sequences (such
  13751.   as \%a, \13, \v(time), etc).  Normally the special escapes are handled.
  13752.   Use SET OUTPUT SPECIAL-ESCAPES OFF to disable them.
  13753.  
  13754. Disabling special escapes is necessary in situations when you need to transmit
  13755. lines of data and you have no control over what is in the lines.  For example,
  13756. a file oofa.txt that contains:
  13757.  
  13758.   This is a file
  13759.   It has \%a variables in it
  13760.   And it has \B in it.
  13761.   And it has \L in it.
  13762.   And it has \N in it.
  13763.   And this is the last line.
  13764.  
  13765. can be sent like this:
  13766.  
  13767.   local line
  13768.   set output special-escapes off
  13769.   fopen /read \%c oofa.txt
  13770.   if fail stop 1 Can't open oofa.txt
  13771.   while success {
  13772.       fread \%c line
  13773.       if fail break
  13774.       ; Add filtering or processing commands here...
  13775.       output \m(line)\13
  13776.   }
  13777.  
  13778. 7.12. Function and Variable Diagnostics
  13779.  
  13780. In C-Kermit 6.0 and earlier, the only diagnostic returned by a failing
  13781. function call was an empty value, which (a) could not be distinguished from
  13782. an empty value returned by a successful function call; (b) did not give any
  13783. indication of the cause of failure; and (c) did not cause the enclosing
  13784. statement to fail.  C-Kermit 7.0 corrects these deficiencies.
  13785.  
  13786. SET FUNCTION DIAGNOSTICS { ON, OFF }
  13787.   when ON, allows built-in functions to return diagnostic messages when
  13788.   improperly referenced, instead of an empty string.  FUNCTION DIAGNOSTICS are
  13789.   ON by default.  When OFF, improperly referenced functions continue to return
  13790.   an empty string.  This command also affects built-in variables; in this case,
  13791.   an error message is returned only if the variable does not exist.  When
  13792.   FUNCTION DIAGNOSTICS are ON, the error message is also printed.
  13793.  
  13794. For variables, the only message is:
  13795.  
  13796.   <ERROR:NO_SUCH_VARIABLE:\v(name)>
  13797.  
  13798. where "name" is the name of the nonexistent variable.
  13799.  
  13800. For functions, the diagnostic message is:
  13801.  
  13802.   <ERROR:message:\fname()>
  13803.  
  13804. where "message" is replaced by a message, and "name" is replaced by the
  13805. function name, e.g. <ERROR:ARG_NOT_NUMERIC:\fmod()>.  Messages include:
  13806.  
  13807.   ARG_BAD_ARRAY       An argument contains a malformed array reference.
  13808.   ARG_BAD_DATE        An argument contains a malformed date and/or time.
  13809.   ARG_BAD_PHONENUM    An argument contains a malformed telephone number.
  13810.   ARG_BAD_VARIABLE    An argument contains a malformed \%x variable.
  13811.   ARG_INCOMPLETE      An argument is incomplete (e.g. a broken Base64 string).
  13812.   ARG_EVAL_FAILURE    An argument could not be evaluated (internal error).
  13813.   ARG_NOT_ARRAY       An argument references an array that is not declared.
  13814.   ARG_NOT_NUMERIC     An argument that must be integer contains non-digits.
  13815.   ARG_NOT_FLOAT       An argument has bad floating-point number format.
  13816.   ARG_NOT_VARIABLE    An argument that must be a variable is not a variable.
  13817.   ARG_OUT_OF_RANGE    An argument's numeric value is too big or too small,
  13818.                       or an argument contains illegal characters (e.g. a hex
  13819.                       or Base-64 string).
  13820.   ARG_TOO_LONG        An argument's value is too long.
  13821.   ARRAY_FAILURE       Failure to create an array.
  13822.   DIVIDE_BY_ZERO      Execution of the function would cause division by zero.
  13823.   FLOATING_POINT_OP   Execution error in a floating-point operation.
  13824.   FILE_NOT_FOUND      Filename argument names a file that can't be found.
  13825.   FILE_NOT_READABLE   Filename argument is not a regular file.
  13826.   FILE_NOT_ACCESSIBLE Filename argument names a file that is read-protected.
  13827.   FILE_ERROR          Other error with filename argument.
  13828.   FILE_NOT_OPEN       A file function was given a channel that is not open.
  13829.   FILE_ERROR_-n       A file function got error -<n> (Section 1.22).
  13830.   LOOKUP_FAILURE      Error looking up function (shouldn't happen).
  13831.   MALLOC_FAILURE      Failure to allocate needed memory (shouldn't happen).
  13832.   NAME_AMBIGUOUS      The function is not uniquely identified.
  13833.   MISSING_ARG         A required argument is missing.
  13834.   NO_SUCH_FUNCTION    An argument references a function that is not defined.
  13835.   NO_SUCH_MACRO       An argument references a macro that is not defined.
  13836.   RESULT_TOO_LONG     The result of a function is too long.
  13837.   UNKNOWN_FUNCTION    Internal error locating function (shouldn't happen).
  13838.  
  13839. Examples:
  13840.  
  13841.   assign \%m \fmod()
  13842.   ?<ERROR:MISSING_ARG:\fmod()>
  13843.   echo "\fcontents(\%m)"
  13844.   "<ERROR:MISSING_ARG:\fmod()>"
  13845.   echo \fmod(3,x)
  13846.   ?<ERROR:ARG_NOT_NUMERIC:\fmod()>
  13847.   echo \fmod(3,4-2*2)
  13848.   ?<ERROR:DIVIDE_BY_ZERO:\fmod()>
  13849.  
  13850. Notice the use of \fcontents() in echoing the value of a variable that
  13851. contains a returned error message.  That's because the error message includes
  13852. the name of the variable or function that failed, so you must use \fcontents()
  13853. to prevent it from being evaluated again -- otherwise the same error will
  13854. occur.
  13855.  
  13856. The handling of function and variable errors is controlled by:
  13857.  
  13858. SET FUNCTION ERROR { ON, OFF }
  13859.   Tells whether invalid function calls or variable references should cause
  13860.   command errors.  FUNCTION ERROR is ON by default.  When ON, and an error is
  13861.   diagnosed in a built-in function or variable, the command that includes the
  13862.   function call or variable reference fails.  The failing command can be
  13863.   handled in the normal way with IF FAILURE / IF SUCCESS, SET TAKE ERROR, or
  13864.   SET MACRO ERROR.
  13865.  
  13866. When FUNCTION DIAGNOSTICS is OFF, there is no error message.
  13867.  
  13868. SHOW SCRIPTS displays the current FUNCTION DIAGNOSTICS and ERROR settings.
  13869.  
  13870. 7.13. Return Value of Macros
  13871.  
  13872. In C-Kermit 5A and 6.0, there are two ways to return one level from a macro:
  13873. RETURN <value> and END <number> <text>.  When RETURN is used, the <value>,
  13874. which can be a number or a text string, is assigned to \v(return).  When
  13875. END was used, however, \v(return) was not set.  SUCCESS/FAILURE was set
  13876. according to whether the <number> was zero, and the <text> was printed, but
  13877. the actual value of the <number> was lost.
  13878.  
  13879. In C-Kermit 7.0, the END <number> is available in the \v(return) variable.
  13880.  
  13881. 7.14. The ASSERT, FAIL, and SUCCEED Commands.
  13882.  
  13883. The ASSERT command is just like the IF command, but without a command to
  13884. execute.  It simply succeeds or fails, and this can be tested by a subsequent
  13885. IF SUCCESS or IF FAILURE command.  Example:
  13886.  
  13887.   ASSERT = 1 1
  13888.   IF SUCCESS echo 1 = 1.
  13889.  
  13890. The FAIL command does nothing, but always fails.
  13891. The SUCCEED command does nothing, but always succeeds.
  13892.  
  13893. These commands are handy in debugging scripts when you want to induce a
  13894. failure (or success) that normally would not occur, e.g. for testing blocks
  13895. of code that normally are not executed.
  13896.  
  13897. 7.15. Using Alarms
  13898.  
  13899. Alarms may be set in two ways:
  13900.  
  13901.   SET ALARM <number>
  13902.     Sets an alarm for the given number of seconds "from now", i.e. in the
  13903.     future, relative to when the SET ALARM command was given.  Examples:
  13904.       set alarm 60        ; 60 seconds from now
  13905.       set alarm +60       ; The same as "60"
  13906.       set alarm -60       ; Not legal - you can't set an alarm in the past.
  13907.       set alarm 60*60     ; 60 minutes from now.
  13908.       set alarm \%a+10    ; You can use variables, etc.
  13909.  
  13910.   SET ALARM <hh:mm:ss>
  13911.     Sets an alarm for the specified time.  If the given time is earlier than
  13912.     the current time, the alarm is set for the given time in the next day.
  13913.     You may give the time in various formats:
  13914.       set alarm 15:00:00  ; 3:00:00pm
  13915.       set alarm 3:00:00pm ; 3:00:00pm
  13916.       set alarm 3:00pm    ; 3:00:00pm
  13917.       set alarm 3pm       ; 3:00:00pm
  13918.  
  13919.   SHOW ALARM
  13920.     Displays the current alarm, if any, in standard date-time format
  13921.     (see Section 1.6): yyyymmdd hh:mm:ss.
  13922.  
  13923.   IF ALARM <command>
  13924.     Executes the <command> if an alarm has been set and the alarm time
  13925.     has passed.
  13926.  
  13927.   XIF ALARM { <command-list> } [ else { <command-list> } ]
  13928.     Executes the <command-list> if an alarm has been set and the alarm time
  13929.     has passed.  Otherwise, if an ELSE part is given, its command-list is
  13930.     executed.
  13931.  
  13932.   CLEAR ALARM
  13933.     Clears the alarm.
  13934.  
  13935. Only one alarm may be set at a time.
  13936.  
  13937. Example: Suppose you have a script that is always running, and that transfers
  13938. files periodically, and that keeps a transaction log.  Suppose you want to
  13939. start a new transaction log each day:
  13940.  
  13941.   log transactions \v(date).log
  13942.   set alarm 00:00:00                     ; Set an alarm for midnight
  13943.   while true {                           ; Main script loop
  13944.       xif alarm {                        ; If the alarm time is past...
  13945.           close transactions             ; Close current log
  13946.           log transactions \v(date).log  ; Start new one
  13947.           pause 1                        ; To make sure 00:00:00 is past
  13948.           set alarm 00:00:00             ; Set a new alarm
  13949.       }
  13950.       ; put the rest of the script here...
  13951.   }
  13952.  
  13953. Note that IF ALARM -- no matter whether it succeeds or fails -- does NOT
  13954. clear an expired alarm.  Thus, once an alarm has expired, every IF ALARM will
  13955. succeed until the alarm is cleared (with the CLEAR ALARM command) or reset
  13956. with a new SET ALARM command.
  13957.  
  13958. 7.16. Passing Arguments to Command Files
  13959.  
  13960. Beginning in version 7.0, C-Kermit accepts arguments on the TAKE command line,
  13961. for example:
  13962.  
  13963.   C-Kermit> take oofa.ksc one two {this is three} four
  13964.  
  13965. This automatically sets the variables \%1 through \%9 to the arguments,
  13966. and \%0 to the name of the file, in this case:
  13967.  
  13968.   \%0 = /usr/olga/oofa.ksc
  13969.   \%1 = one
  13970.   \%2 = two
  13971.   \%3 = this is three
  13972.   \%4 = four
  13973.  
  13974. and \%5..\%9 are undefined (empty).  Arguments past the ninth are available in
  13975. the \&_[] argument-vector array (Section 7.5).
  13976.  
  13977. The variables are those at the current macro level.  Thus, if the TAKE command
  13978. is executed from within a macro, the macro's arguments are replaced by those
  13979. given on the TAKE command line (but only if at least one argument is given).
  13980. The command shown above is exactly equivalent to:
  13981.  
  13982.   assign \%0 /usr/olga/oofa.ksc
  13983.   assign \%1 one
  13984.   assign \%2 two
  13985.   assign \%3 this is three
  13986.   assign \%4 four
  13987.   assign \%5
  13988.   assign \%6
  13989.   assign \%7
  13990.   assign \%8
  13991.   assign \%9
  13992.   take oofa.ksc
  13993.  
  13994. Remember, the variables \%0..\%9 are on the macro call stack, and command
  13995. files are independent of the macro stack.  Thus, if a command file TAKEs
  13996. another command file and passes arguments to it, the variables are changed
  13997. from that point on for both files, and so forth for all levels of nested
  13998. command files without intervening macro invocations.
  13999.  
  14000. It would have been possible to change C-Kermit to use the overall command
  14001. stack, rather than the macro stack, for arguments -- this would have made
  14002. TAKE work exactly like DO, which is "nicer", but it would also have broken
  14003. countless existing scripts.  However, the new SHIFT command (Section 7.5)
  14004. makes it possible to create an alternative TAKE command that does indeed
  14005. save and restore the argument variables at its own level around execution
  14006. of a command file:
  14007.  
  14008.   define mtake {
  14009.      local \%f
  14010.      assign \%f \fcontents(\%1)
  14011.      shift
  14012.      take \%f
  14013.   }
  14014.  
  14015. C-Kermit 7.0 also supports a new, easier way to pass arguments to scripts
  14016. from the system command line:
  14017.  
  14018.   kermit filename arg1 arg2 arg3 ...
  14019.  
  14020. in which arg1, arg2, arg3 (etc) are arguments for the script (whose filename
  14021. is given), and are assigned to \%1, \%2, ... \%9.  The filename is assigned to
  14022. \%0.  This applies equally to "Kerbang" scripts in UNIX (Section 7.19).
  14023. For example, suppose you have a file called "showargs" containing the
  14024. following lines:
  14025.  
  14026.   #!/usr/local/bin/kermit +
  14027.   echo Hello from \%0
  14028.   show args
  14029.   exit
  14030.  
  14031. (except not indented, since the "#!" line must be on the left margin).  If
  14032. you give this file execute permission:
  14033.  
  14034.   chmod +x showargs
  14035.  
  14036. then you can run it exactly as you would run a UNIX shell script, e.g.:
  14037.  
  14038.   $ showargs one two three
  14039.  
  14040. $ x one two three
  14041. Hello from /usr/olga/showargs
  14042. Top-level arguments (\v(argc) = 4):
  14043.  \&_[0] = /usr/olga/showargs
  14044.  \&_[1] = one
  14045.  \&_[2] = two
  14046.  \&_[3] = three
  14047.  
  14048. Furthermore, the \&_[] array now contains the filename, if one was given as
  14049. the first command line argument, or it is a "Kerbang" script, in element 0.
  14050.  
  14051. Otherwise element 0 is program name, and elements 1 through \v(argc)-1 contain
  14052. the command-line arguments, if any, that appear after "--" or "=", if any.
  14053. This array is saved and restored around macro calls; recall that inside macros
  14054. it contains the macro argument vector (allowing you to access arguments
  14055. programmatically, and to have more than 9 of them).
  14056.  
  14057. At top level, notice the difference between the \&@[] and \&_[] arrays.  The
  14058. former includes C-Kermit options; the latter omits them.
  14059.  
  14060. 7.17. Dialogs with Timed Responses
  14061.  
  14062. The ASK, ASKQ, GETOK, and GETC commands (let's call them the "ASK-class
  14063. commands") let you write scripts that carry on dialogs with the user, asking
  14064. them for text, a Yes/No answer, or a character, respectively.  Prior to
  14065. C-Kermit 7.0, these questions would always wait forever for an answer.  In
  14066. C-Kermit 7.0, you may specify a time limit for them with the new command:
  14067.  
  14068. SET ASK-TIMER number
  14069.   Sets a time-limit on ASK-CLASS commands to the given number of seconds.
  14070.   If the number is 0 or less, there is no time limit and these commands wait
  14071.   forever for a response.  Any timer that is established by this command
  14072.   remains in effect for all future ASK-class commands until another SET
  14073.   ASK-TIMER command is given (e.g. with a value of 0 to disable ASK timeouts).
  14074.  
  14075. An ASK-class command that times out returns a failure status.  You can test
  14076. explicitly for a timeout with:
  14077.  
  14078.   IF ASKTIMEOUT <command>
  14079.  
  14080. 7.18. Increased Flexibility of SWITCH Case Labels
  14081.  
  14082. Prior to C-Kermit 7.0 / K95 1.1.18, the case labels in SWITCH statements
  14083. were string constants.
  14084.  
  14085. Now case labels can be variables, function calls, or any mixture of these
  14086. with each other and/or with regular characters.
  14087.  
  14088. Furthermore, after the case label is evaluated, it is treated not as a string
  14089. constant, but as a pattern against which the SWITCH variable is matched
  14090. (Section 4.9.1).
  14091.  
  14092. This introduces a possible incompatibility with previous releases, since
  14093. the following characters in case labels are no longer taken literally:
  14094.  
  14095.   \ * ? [ {
  14096.  
  14097. Any scripts that previously included any of these characters in case labels
  14098. must now quote them with backslash (\).
  14099.  
  14100. 7.19. "Kerbang" Scripts
  14101.  
  14102. In UNIX only, Kermit scripts can be stored in files and run "directly",
  14103. without starting Kermit first (as noted on page 467 of the manual), just as a
  14104. shell script can be "run" as if it were a program.  This section amplifies on
  14105. that idea a bit, and presents some new aspects of version 7.0 that make it
  14106. easier to write and run Kermit scripts directly.
  14107.  
  14108.   NOTE: On non-UNIX platforms, such as VMS or Windows, Kerbang scripts can
  14109.   be run as "kermit + scriptfilename arg1 arg2 arg3 ...".  Windows 95/98/NT
  14110.   file associations do not allow for the passing of parameters.  In VMS,
  14111.   however, you can achieve the Kerbang effect by defining a symbol, as
  14112.   in this example:
  14113.  
  14114.     $ autotelnet :== "$SYS$TOOLS:KERMIT.EXE + AUTOTELNET.KSC"
  14115.  
  14116.   and then running the script like any other command:
  14117.  
  14118.     $ autotelnet xyzcorp.com myuserid
  14119.  
  14120.   See section 9.3 for an explanation of the "+" symbol.
  14121.  
  14122. UNIX shell scripts can specify which shell should run them by including a
  14123. "shebang" line at the top, e.g.:
  14124.  
  14125.   #!/bin/sh
  14126.  
  14127. (but not indented; the shebang line must be on the left margin).  The term
  14128. "shebang" is a contraction of "shell" and "bang".  "Bang" is a slang word for
  14129. the exclamation mark ("!"); "shebang" itself is an American slang word used in
  14130. in the phrase "the whole shebang".
  14131.  
  14132. We can run Kermit scripts directly too, by including a "shebang" line that
  14133. names Kermit as the "shell"; thus we call these "Kerbang" scripts.  This
  14134. mechanism has been considerably simplified in C-Kermit 7.0 to facilitate
  14135. C-Kermit's use a scripting tool just like any of the UNIX shells or scripting
  14136. languages.  The rules are the same as for shell scripts:
  14137.  
  14138.  a. The first line of the Kermit script must begin with "#!" immediately
  14139.     followed by the full pathname of the program that will execute the
  14140.     script (in this case, C-Kermit rather than a UNIX shell), followed by
  14141.     any Kermit command-line options.  To suppress execution of the C-Kermit
  14142.     initialization file and to make command line arguments available to the
  14143.     script, the final option should be "+":
  14144.  
  14145.     #!/usr/local/bin/kermit +
  14146.  
  14147.     Some users have reported that in some circumstances a space might be
  14148.     necessary after the plus sign; this depends on your shell -- it has
  14149.     nothing to do with Kermit.  In most cases, no space is needed.
  14150.  
  14151.  b. The file must have execute permission (granted via "chmod +x <filename>").
  14152.  
  14153. When C-Kermit is invoked from a Kerbang script (or from the system prompt
  14154. with a "+" command-line argument, which amounts to the same thing), the
  14155. following special rules apply:
  14156.  
  14157.  a. The C-Kermit initialization file is NOT executed automatically.  If you
  14158.     want it to be executed, include a TAKE command for it in the script,
  14159.     e.g.  "take \v(home).kermrc".  (In previous releases, the initialization
  14160.     file was always executed, with no way to prevent it except for the user
  14161.     to include Kermit-specific command line options which had nothing to do
  14162.     with the script).  Many scripts have no need for the standard Kermit
  14163.     initialization file, which is quite lengthy and not only delays startup
  14164.     of the script, but also spews forth numerous messages that are most
  14165.     likely unrelated to the script.
  14166.  
  14167.  b. If the initialization file is not executed, neither is your customization
  14168.     file, since the initialization file is the command file from which the
  14169.     customization file is TAKEn.  Again, you can include a TAKE command for
  14170.     the initialization file if desired, or for the customization file by
  14171.     itself, or for any other file.
  14172.  
  14173.  c. C-Kermit does not process command-line arguments at all.  Instead, it
  14174.     passes all words on the command line after the "+" to the script as \%0
  14175.     (the script name), \%1..\%9 (the first nine arguments), as well as in
  14176.     the argument vector array \&_[].  The variable \v(argc) is set to the
  14177.     total number of "words" (as passed by the shell to Kermit) including the
  14178.     script name.  Quoting and grouping rules are those of the shell.
  14179.  
  14180.  d. At any point where the script terminates, it must include an EXIT
  14181.     command if you want it to exit back to the shell; otherwise C-Kermit
  14182.     enters interactive prompting mode when the script terminates.  The EXIT
  14183.     command can include a numeric status to be returned to the shell (0, 1,
  14184.     etc), plus an optional message.
  14185.  
  14186. Here is a simple Kerbang script that prints its arguments:
  14187.  
  14188.   #/usr/local/bin/kermit +
  14189.   echo Hello from \%0
  14190.   for \%i 0 \v(argc)-1 1 {
  14191.       echo \%i. "\&_[\%i]"
  14192.   }
  14193.   exit 0
  14194.  
  14195. Save this file as (say) "showargs", then give it execute permission and
  14196. run it (the \&_[] array is the same as \%0..\%9, but allows you to refer
  14197. to argument variables programmatically; see Section 7.5).  (Yes, you could
  14198. substitute SHOW ARGUMENTS for the loop.)
  14199.  
  14200.   $ chmod +x showargs
  14201.   $ ./showargs one "this is two" three
  14202.  
  14203. The script displays its arguments:
  14204.  
  14205.   Hello from /usr/olga/showargs
  14206.   0. "/usr/olga/showargs"
  14207.   1. "one"
  14208.   2. "this is two"
  14209.   3. "three"
  14210.   $
  14211.  
  14212. Notice that no banners or greetings are printed and that startup is
  14213. instantaneous, just like a shell script.  Also notice that grouping of
  14214. arguments is determined by *shell* quoting rules, not Kermit ones, since
  14215. the command line is parsed by the shell before Kermit ever sees it.
  14216.  
  14217. Of course you can put any commands at all into a Kerbang script.  It can
  14218. read and write files, make connections, transfer files, anything that Kermit
  14219. can do -- because it *is* Kermit.  And of course, Kerbang scripts can also
  14220. be executed from the Kermit prompt (or from another script) with a TAKE
  14221. command; the Kerbang line is ignored since it starts with "#", which is a
  14222. comment introducer to Kermit just as it is to the UNIX shell.  In VMS and
  14223. other non-UNIX platforms, the Kerbang line has no effect and can be omitted.
  14224.  
  14225. It might be desireable for a script to know whether it has been invoked
  14226. directly from the shell (as a Kerbang script) or by a TAKE command given to
  14227. the Kermit prompt or in a Kermit command file or macro.  This can be done
  14228. as in this example:
  14229.  
  14230.   #!/usr/local/bin/kermit +
  14231.   assign \%m \fbasename(\%0)
  14232.   define usage { exit 1 {usage: \%m <phonenumber> <message>} }
  14233.   define apage { (definition of APAGE...) } ; (See book pp.454-456)
  14234.   xif equal "\%0" "\v(cmdfil)" {
  14235.       if not def \%1 usage
  14236.       if not def \%2 usage
  14237.       apage {\%1} {\%2}
  14238.       exit \v(status)
  14239.   }
  14240.  
  14241. In a Kerbang script, \%0 and \v(cmdfile) are the same; both of them are the
  14242. name of the script.  When a script is invoked by a Kermit TAKE command, \%0 is
  14243. the name of the Kermit program, but \v(cmdfile) is the name of the script.  In
  14244. the example above, a macro called APAGE is defined.  If the script was invoked
  14245. directly, the APAGE macro is also executed.  Otherwise, it is available for
  14246. subsequent and perhaps repeated use later in the Kermit session.
  14247.  
  14248. An especially handy use for Kerbang scripts is to have the initialization file
  14249. itself be one.  Since the standard initialization file is rather long and
  14250. time-consuming to execute, it is often overkill if you want to start Kermit
  14251. just to transfer a file.  Of course there are command-line switches to
  14252. suppress initialization-file execution, etc, but another approach is to "run"
  14253. the initialization file when you want its features (notably the services
  14254. directory), and run C-Kermit directly when you don't.  A setup like this
  14255. requires that (a) the C-Kermit initialization file is configured as a Kerbang
  14256. script (has #!/path.../kermit as first line), has execute permission, and is
  14257. in your PATH; and (b) that you don't have a .kermrc file in your login
  14258. directory.
  14259.  
  14260. 7.20. IF and XIF Statement Syntax
  14261.  
  14262. The IF command has been improved in two significant ways in C-Kermit 7.0,
  14263. described in the following subsections.  All changes are backwards compatible.
  14264.  
  14265. 7.20.1. The IF/XIF Distinction
  14266.  
  14267. The distinction between IF and XIF is no longer important as of C-Kermit 7.0.
  14268. You should be able to use IF in all cases (and of course, also XIF for
  14269. backwards compatibility).  In the past, IF was used for single-command THEN
  14270. parts, followed optionally by a separate ELSE command:
  14271.  
  14272.   IF <condition> <command1>  ; THEN part
  14273.   ELSE <command2>            ; ELSE part
  14274.  
  14275. whereas XIF was required if either part had multiple commands:
  14276.  
  14277.   XIF <condition> { command, command, ... } ELSE { command, command, ... }
  14278.  
  14279. The syntactic differences were primarily that IF / ELSE was two commands on
  14280. two separate lines, whereas XIF was one command on one line, and that XIF
  14281. allowed (and in fact required) braces around its command lists, whereas IF
  14282. did not allow them.
  14283.  
  14284. Furthermore, the chaining or nesting of parts and conditions was inconsistent.
  14285. For example, the IF command could be used like this:
  14286.  
  14287.   IF <condition> <command>
  14288.   ELSE IF <condition> <command>
  14289.   ELSE IF <condition> <command>
  14290.   ELSE IF <condition> <command>
  14291.   ...
  14292.  
  14293. but XIF could not.  C-Kermit 7.0 accepts the old syntax and executes it the
  14294. same as previous versions, but also accepts a new unified and more convenient
  14295. syntax:
  14296.  
  14297.   IF <condition> <command-list> [ ELSE <command-list> ]
  14298.  
  14299. or:
  14300.  
  14301.   IF <condition> <command-list>
  14302.   ELSE <command-list>
  14303.  
  14304. in which the ELSE part is optional, and where <command-list> can be a single
  14305. command (with or without braces around it) or a list of commands enclosed in
  14306. braces.  Examples:
  14307.  
  14308. Example 1:
  14309.  
  14310.   IF <condition> { command1, command2 } ELSE { command3, command4 }
  14311.  
  14312. Example 2 (same as Example 1):
  14313.  
  14314.   IF <condition> {
  14315.      command1
  14316.      command2
  14317.   } ELSE {
  14318.      command3
  14319.      command4
  14320.   }
  14321.  
  14322. Example 3 (same as 1 and 2):
  14323.  
  14324.   IF <condition> {
  14325.      command1
  14326.      command2
  14327.   }
  14328.   ELSE { command3, command4 }
  14329.  
  14330. Example 4 (same as 1-3):
  14331.  
  14332.   IF <condition> {
  14333.      command1
  14334.      command2
  14335.   }
  14336.   ELSE {
  14337.      command3
  14338.      command4
  14339.   }
  14340.  
  14341. Example 5 (ELSE can be followed by another command):
  14342.  
  14343.   IF <condition> {
  14344.      command1
  14345.      command2
  14346.   } ELSE IF <condition> {
  14347.      command3
  14348.      command4
  14349.   } ELSE {
  14350.      command5
  14351.      command6
  14352.   }
  14353.  
  14354. Example 5 suggests other possibilities:
  14355.  
  14356.   IF <condition> {
  14357.      command1
  14358.      command2
  14359.   } ELSE FOR <variable> <initial> <final> <increment> {
  14360.      command3
  14361.      command4
  14362.   }
  14363.  
  14364. And this too is possible, except for some non-obvious quoting considerations:
  14365.  
  14366.   dcl \&a[6] = one two three four five six
  14367.  
  14368.   IF < \%n 3 {
  14369.       echo \\%n is too small: \%n
  14370.   } ELSE FOR \\%i 1 \\%n 1 {
  14371.       echo \\%i. \\&a[\\%i]
  14372.   }
  14373.  
  14374. (The loop variable must be quoted in this context to prevent premature
  14375. evaluation.)
  14376.  
  14377. 7.20.2. Boolean Expressions (The IF/WHILE Condition)
  14378.  
  14379. Prior to C-Kermit 7.0, the IF and WHILE commands accepted only a single
  14380. Boolean ("true or false") assertion, e.g. "if > \%m 0 <command>" or "if exist
  14381. <filename> <command>".  There was no way to form Boolean expressions and, in
  14382. particular, nothing that approached a Boolean OR function (AND could be
  14383. simulated by concatenating IF statements: "if <condition1> if <condition2>..").
  14384.  
  14385. C-Kermit 7.0 (and K95 1.1.18) allow grouping of Boolean assertions using
  14386. parentheses and combining them using AND (or &&) and OR (or ||).  Each of
  14387. these operators -- including the parentheses -- is a field and must be set off
  14388. by spaces.  AND has higher precedence than OR, NOT has higher precedence than
  14389. AND, but parentheses can be used to force any desired order of evaluation.
  14390. The old syntax is still accepted.
  14391.  
  14392. Here are some examples:
  14393.  
  14394.   define \%z 0                          ; Define some variables
  14395.   define \%n 1                          ; for use in the examples.
  14396.  
  14397.   if > \%n \%z echo \%n is greater.     ; Original format - still accepted.
  14398.   if ( > \%n \%z ) echo \%n is greater. ; Parentheses may be used in 7.0.
  14399.   if ( > \%n \%z && not = \%z 0 ) ...   ; Two assertions combined with AND.
  14400.   if ( > \%n \%z and not = \%z 0 ) ...  ; Same as previous ("and" = "&&").
  14401.   if ( > \%n \%z || not = \%z 0 ) ...   ; Two assertions combined with OR.
  14402.   if ( > \%n \%z or not = \%z 0 ) ...   ; Same as previous ("or" = "||").
  14403.   if ( > \%n \%z || != \%z 0 ) ...      ; Ditto ("!=" = "not =").
  14404.   while ( 1 ) { ... }                   ; Just like C.
  14405.  
  14406. Notice the spaces around all operators including the parentheses -- these
  14407. are required.  The following examples show how parentheses can be used to
  14408. alter the precedence of the AND and OR operators:
  14409.  
  14410.   if ( false || false && false || true ) ,..         ; True
  14411.   if ( false || ( false && false ) || true ) ...     ; Same as previous
  14412.   if ( ( false || false ) && ( false || true ) ) ... ; False
  14413.  
  14414. Similarly for NOT:
  14415.  
  14416.   if ( not true && false ) ...          ; False (NOT binds to TRUE only)
  14417.   if ( ( not true ) && false ) ...      ; Same as previous
  14418.   if ( not ( true && false ) ) ...      ; True (NOT binds to (TRUE && FALSE))
  14419.  
  14420. Notes:
  14421.  
  14422.  a. The syntax of the Boolean expression itself has not changed; each
  14423.     expression begins with a keyword or token such as "EXIST", ">", or
  14424.     "=", etc; operators such as "<", "=", and ">" do not go between their
  14425.     operands but precede them as before; this might be called "reverse
  14426.     reverse Polish notation"; it allows deterministic on-the-fly parsing
  14427.     of these expressions at the C-Kermit> prompt as well as in scripts, and
  14428.     allows ?-help to be given for each item when IF or WHILE commands are
  14429.     typed at the prompt.
  14430.  
  14431.  b. Parentheses are required when there is more than one Boolean assertion.
  14432.  
  14433.  c. Parentheses are not required, but are allowed, when there is only one
  14434.     Boolean assertion.
  14435.  
  14436.  d. Evaluation of Boolean assertions occurs left to right, but the resulting
  14437.     Boolean expression is evaluated afterwards according to the rules of
  14438.     precedence.  All Boolean assertions are always evaluated; there is no
  14439.     "early stopping" property and therefore no question about when or if
  14440.     side effects will occur -- if any Boolean assertion has side effects,
  14441.     they will always occur.
  14442.  
  14443. Constructions of arbitrary complexity are possible, within reason.
  14444.  
  14445. Also see Section 7.4 for new IF / WHILE conditions.
  14446.  
  14447. 7.21. Screen Formatting and Cursor Control
  14448.  
  14449. C-Kermit 7.0 adds a simple way to create formatted screens, the SCREEN
  14450. command:
  14451.  
  14452. SCREEN { CLEAR, CLEOL, MOVE-TO row [ column ] }
  14453.   Performs screen-formatting actions.  Correct operation of these commands
  14454.   depends on proper terminal setup on both ends of the connection -- mainly
  14455.   that the host terminal type is set to agree with the kind of terminal or
  14456.   the emulation you are viewing C-Kermit through.  The UNIX version uses
  14457.   terminfo or termcap (not curses); the VMS version uses SMG; K-95 uses its
  14458.   built in screen manager.
  14459.  
  14460. SCREEN CLEAR
  14461.   Moves the cursor to home position and clears the entire screen.
  14462.   Synonyms: CLEAR COMMAND-SCREEN ALL (K-95 only), CLS, CLEAR SCREEN.
  14463.  
  14464. SCREEN CLEOL
  14465.   Clears from the current cursor position to the end of the line.
  14466.   Synonym: CLEAR COMMAND-SCREEN EOL (K-95 only)
  14467.  
  14468. SCREEN MOVE-TO row column
  14469.   Moves the cursor to the indicated row and column.  The row and column
  14470.   numbers are 1-based, so on a 24x80 screen the home position is 1 1 and
  14471.   the lower right corner is 24 80.  If a row or column number is given that
  14472.   too large for what Kermit or the operating system thinks is your screen
  14473.   size, the appropriate number is substituted.
  14474.  
  14475. These escape sequences used by these commands depends on the platform.
  14476. In UNIX, your TERM environment variable is used to query the terminfo/termcap
  14477. database; if the query fails, ANSI/VT100 sequences are used.  In VMS, the
  14478. SMG library is used, which sends sequences based on your VMS terminal type.
  14479. K95 does its own screen control.  On other platforms (such as AOS/VS, VOS,
  14480. etc), screen formatting is not supported, and the SCREEN command does nothing.
  14481.  
  14482. The three SCREEN actions can be used in scripts to produce menus, formatted
  14483. screens, dynamic displays, etc.  Related variables include:
  14484.  
  14485.   \v(terminal)     The type terminal C-Kermit thinks you have.
  14486.   \v(rows)         The number of rows C-Kermit thinks your terminal has.
  14487.   \v(columns)      The number of columns C-Kermit thinks your terminal has.
  14488.  
  14489. And functions:
  14490.  
  14491.   \fscrncurx()     The current X coordinate of the cursor (K-95 only).
  14492.   \fscrncury()     The current Y coordinate of the cursor (K-95 only).
  14493.   \fscrnstr(x,y,n) The string of length n at position (x,y) (K-95 only).
  14494.  
  14495. And commands:
  14496.  
  14497.   ECHO string      Writes string + CRLF at the current cursor position.
  14498.   XECHO string     Writes string at current cursor position; CRLF not supplied.
  14499.   GETC v prompt    Issues prompt, reads one character into variable v, no echo.
  14500.  
  14501. And special characters:
  14502.  
  14503.   Ctrl-L           At the C-Kermit> command prompt, or in a C-Kermit command,
  14504.                    works like Return or Enter, but also clears the screen
  14505.  
  14506. Example 1: A macro that prints a message \%1 at cursor position (\%2,\%3):
  14507.  
  14508.   define MSG {
  14509.       if not def \%3 def \%3 0             ; Default column to 0
  14510.       if > \v(argc) 2 screen move \%2 \%3  ; Move to given row/col (if any)
  14511.       screen cleol                         ; Clear to end of line
  14512.       if def \%1 xecho \fcontents(\%1)     ; Print message (if any)
  14513.   }
  14514.  
  14515. Example 2: A macro put the cursor on the bottom screen line, left margin:
  14516.  
  14517.   define BOT {
  14518.       screen move \v(rows) 0
  14519.   }
  14520.  
  14521. Example 3: A macro to center message \%1 on line \%2.
  14522.  
  14523.   define CENTER {
  14524.       if not def \%2 def \%2 1
  14525.       .\%x ::= (\v(cols)-\flen(\%1))/2
  14526.       msg {\%1} {\%2} {\%x}
  14527.   }
  14528.  
  14529. Example 4: A simple menu (building on Examples 1-3):
  14530.  
  14531.   def \%c 0                             ; Menu choice variable
  14532.   screen clear                          ; Clear the screen
  14533.   center {Welcome to This Menu} 2       ; Display the menu
  14534.   msg {Choices:} 4
  14535.   msg { 1. File} 6
  14536.   msg { 2. Edit} 7
  14537.   msg { 3. Exit} 8
  14538.   while ( != \%c 3 ) {                  ; Read and verify choice
  14539.       while true {                      ; Keep trying till we get a good one
  14540.       screen move 10                ; Move to line 10
  14541.       screen cleol                  ; Clear this line
  14542.       getc \%c {Your choice: }      ; Prompt and get and echo 1 character
  14543.       xecho \%c
  14544.       if ( not numeric \%c ) { msg {Not numeric - "\%c"} 12, continue }
  14545.       if ( >= \%c 1 && <= \%c 3 ) break
  14546.       msg {Out of range - "\%c"} 12
  14547.       }
  14548.       switch \%c {                      ; Valid choice - execute it.
  14549.     :1, msg {Filing... } 12, break
  14550.     :2, msg {Editing...} 12, break
  14551.     :3, msg {Exiting...} 12, break
  14552.       }
  14553.   }
  14554.   echo Bye                              ; Exit chosen - say goodbye.
  14555.   bot                                   ; Leave cursor at screen bottom.
  14556.   exit                                  ; And exit.
  14557.  
  14558. Similar scripts can work over the communication connection; substitute
  14559. INPUT and OUTPUT for GETC and ECHO/XECHO.
  14560.  
  14561.  
  14562. 7.22. Evaluating Arithmetic Expressions
  14563.  
  14564. A new arithmetic operator was added to the list recognized by the EVALUATE
  14565. command, the \feval() function, and which can also be used anywhere else
  14566. arithmetic expressions are accepted (numeric command fields, array subscripts,
  14567. etc):
  14568.  
  14569. Prefix "!"
  14570.   This operator inverts the "truth value" of the number or arithmetic
  14571.   expression that follows.  If the value of the operand is 0, the result is 1.
  14572.   If the value is nonzero, the result is 0.
  14573.  
  14574. Examples:
  14575.  
  14576.   set eval old
  14577.   evaluate 0
  14578.   0
  14579.  
  14580.   evaluate !0
  14581.   1
  14582.  
  14583.   evaluate !3
  14584.   0
  14585.  
  14586.   evaluate !(-3)
  14587.   0
  14588.  
  14589.   .\%a = 1
  14590.   .\%b = 0
  14591.   evaluate !(\%a|\%b)
  14592.   0
  14593.  
  14594.   evaluate !(\%a&\%b)
  14595.   1
  14596.  
  14597.   evaluate !(!(\%a&\%b))
  14598.   0
  14599.  
  14600. Note the distinction between Prefix ! (invert truth value) and Suffix !
  14601. (factorial).  Also the distinction between Prefix ! and Prefix ~ (which
  14602. inverts all the bits in its operand).  Also note that prefix operators
  14603. (!, -, and ~) can not be adjacent unless you use parentheses to separate
  14604. them, as shown in the final example above.
  14605.  
  14606. 7.23. Floating-Point Arithmetic
  14607.  
  14608. C-Kermit 7.0 adds limited support for floating-point numbers (numbers that
  14609. have fractional parts, like 3.141592653).  This support is provided through a
  14610. small repertoire of functions and in Boolean expressions that compare numbers,
  14611. but does not apply to number parsing in general, or to expression evaluation,
  14612. array subscripts, the INCREMENT and DECREMENT commands, or in any context
  14613. other than those listed in this section.
  14614.  
  14615. A floating point number has an optional sign (+ or -), followed by a series of
  14616. decimal digits containing either zero or one period (.) character, which is
  14617. the decimal point.  The use of comma or any other character besides period as
  14618. a decimal point is not supported.  Scientific notation is not supported
  14619. either.  Examples of legal floating-point numbers:
  14620.  
  14621.   0                Integers can be used
  14622.   1                Ditto
  14623.   2.               A decimal point without decimal digits
  14624.   3.0              A decimal point with decimal digits
  14625.   3.141592653      Ditto
  14626.  -4.0              A negative sign can be included
  14627.  +5.0              A positive sign can be included
  14628.  
  14629. Examples of notations that are not accepted:
  14630.  
  14631.   1,000,000        Separators can not be used
  14632.   1.000.000        Ditto (or multiple decimal points)
  14633.   6.022137E23      No scientific notation
  14634.   6.62606868e-34   Ditto
  14635.   12.5+6.25        No "bare" expressions
  14636.  
  14637. You can use IF FLOAT test a string or variable to see if it's in acceptable
  14638. floating-point format.  Example:
  14639.  
  14640.   ask \%f { Type a number: }
  14641.   if not def \%f .\%f = 0.0
  14642.   if not float \%f stop 1 Invalid floating-point number: "\%f"
  14643.  
  14644. C-Kermit's floating-point support, like its support for whole numbers
  14645. (integers), relies on the capabilities of the underlying computer.  Your
  14646. computer has only a limited amount of precision for numbers, depending on its
  14647. architecture.  Thus floating-point numbers that have too many digits will not
  14648. be accurate; adding a very small number to a very large one might have no
  14649. effect at all; and so on.  For details, read a text on numerical analysis.
  14650. Example:
  14651.  
  14652.   .\%a = 11111111111111111111  ; A long number
  14653.   .\%b = 22222222222222222222  ; Another one
  14654.   echo \ffpadd(\%a,\%b)        ; Add them - the result should be all 3's
  14655.   33333333333333330000.0       ; See the result
  14656.  
  14657. In this example, the computer has 16 digits of precision; after that, the
  14658. (low-order) digits are set to 0, since the computer doesn't know what they
  14659. really are.  In fact, the computer returns random digits, but Kermit sets
  14660. all digits beyond the computer's precision to 0.
  14661.  
  14662. C-Kermit's floating-point functions have names of the form "\ffpxxx(args)"
  14663. ("\f" for function, "fp" for floating-point), where "xxx" is replaced by the
  14664. name of the function, such as "sqrt", and "args" is the argument list,
  14665. consisting of one or two floating-point numbers (depending on the function),
  14666. and an optional "d" argument that says now many decimal places should be shown
  14667. in the result.  Example:
  14668.  
  14669.   \ffpdiv(10,3,1) returns "3.3"
  14670.   \ffpdiv(10,3,2) returns "3.33"
  14671.   \ffpdiv(10,3,3) returns "3.333"
  14672.  
  14673. and so on, up to the precision of the computer.  If the decimal-places
  14674. argument is less than zero, the fractional part of the result is truncated:
  14675.  
  14676.   \ffpdiv(10,3,-1) returns "3".
  14677.  
  14678. If the decimal-places argument is 0, or is omitted, C-Kermit returns as many
  14679. decimal places as are meaningful in the computer's floating-point precision,
  14680. truncating any extraneous trailing 0's:
  14681.  
  14682.   \ffpdiv(10,8) returns "1.25".
  14683.   \ffpdiv(10,4) returns "2.5".
  14684.   \ffpdiv(10,2) returns "5.0".
  14685.   \ffpdiv(10,3) returns "3.333333333333333" (for 16-digit precision).
  14686.  
  14687. There is no way to request that a floating-point function return a decimal
  14688. point but no decimal places.  However, this is easy enough to accomplish in
  14689. other ways, for example by supplying it outside the function call:
  14690.  
  14691.   echo \ffpadd(\%a,\%b,-1).
  14692.  
  14693. Kermit's floating-point functions always round the result for the requested
  14694. number of decimal places when the "d" argument is given and has a value
  14695. greater than 0 (see the description of \ffpround() just below).
  14696.  
  14697. Floating-point arguments can be constants in floating-point format or
  14698. variables whose values are floating-point numbers.  If a floating-point
  14699. argument is omitted, or is a variable with no value, 0.0 is supplied
  14700. automatically.  Example:
  14701.  
  14702.   def \%x 999.999
  14703.   undef \%y
  14704.   echo \ffpmin(\%x,\%y)
  14705.   0.0
  14706.  
  14707. Or equivalently:
  14708.  
  14709.   echo \ffpmin(999.999)
  14710.   0.0
  14711.  
  14712. The floating-point functions are:
  14713.  
  14714. \ffpround(f1,d)
  14715.   Returns f1 rounded to d decimal places.  For this function only, d = 0
  14716.   (or d omitted) has a special meaning: return the integer part of f1
  14717.   rounded according to the fractional part.  Examples:
  14718.     \ffpround(2.74653,-1) returns "2" (fraction truncated, no rounding).
  14719.     \ffpround(2.74653,0)  returns "3" (integer part is rounded).
  14720.     \ffpround(2.74653)    returns "3" (d omitted same as d = 0).
  14721.     \ffpround(2.74653,1)  returns "2.7".
  14722.     \ffpround(2.74653,2)  returns "2.75".
  14723.     \ffpround(2.74653,3)  returns "2.747".
  14724.     \ffpround(2.74653,4)  returns "2.7465", etc.
  14725.  
  14726. \ffpadd(f1,f2,d)
  14727.   Returns the sum of f1 and f2.
  14728.  
  14729. \ffpsubtract(f1,f2,d)
  14730.   Subtracts f2 from f1 and returns the result.
  14731.  
  14732. \ffpmultiply(f1,f2,d)
  14733.   Returns the product of f1 and f2.
  14734.  
  14735. \ffpdivide(f1,f2,d)
  14736.   If f2 is not 0, divides f1 by f2 and returns the quotient.
  14737.   If f2 is 0, a DIVIDE_BY_ZERO error occurs.
  14738.  
  14739. \ffpraise(f1,f2,d)
  14740.   If f1 = 0 and f2 <= 0, or if f1 < 0 and f2 has a fractional part,
  14741.   an ARG_OUT_OF_RANGE error occurs; otherwise f1 raised to the f2 power
  14742.   is returned.
  14743.  
  14744. \ffpsqrt(f1,d)
  14745.   If f1 >= 0, returns the square root of f1; otherwise ARG_OUT_OF_RANGE.
  14746.  
  14747. \ffpabsolute(f1,d)
  14748.   Returns the absolute value of f1 (i.e. f1 without a sign).
  14749.   This is the floating-point analog of \fabsolute(n1).
  14750.  
  14751. \ffpint(f1)
  14752.   Returns the integer part of f1.  Equivalent to \ffpround(f1,-1).
  14753.  
  14754. \ffpexp(f1,d)
  14755.   The base of natural logarithms, e (2.718282...), raised to the f1 power.
  14756.  
  14757. \ffplogn(f1,d)
  14758.   The natural logarithm of f1 (the power to which e must be raised to
  14759.   obtain f1).
  14760.  
  14761. \ffplog10(f1,d)
  14762.   The base-10 logarithm of f1 (the power to which 10 must be raised to
  14763.   obtain f1).
  14764.  
  14765. \ffpmodulus(f1,f2,d)
  14766.   If f2 is not 0, the remainder after dividing f1 by f2.
  14767.   If f2 is 0, a DIVIDE_BY_ZERO error occurs.
  14768.   This is the floating-point analog of \fmod(n1,n2).
  14769.  
  14770. \ffpmaximum(f1,f2,d)
  14771.   Returns the maximum of f1 and f2.
  14772.   This is the floating-point analog of \fmax(n1,n2).
  14773.  
  14774. \ffpminimum(f1,f2,d)
  14775.   Returns the minimum of f1 and f2.
  14776.   This is the floating-point analog of \fmin(n1,n2).
  14777.  
  14778. \ffpsine(f1,d)
  14779.   Returns the sine of f1 radians.
  14780.  
  14781. \ffpcosine(f1,d)
  14782.   Returns the cosine of f1 radians.
  14783.  
  14784. \ffptangent(f1,d)
  14785.   Returns the tangent of f1 radians.
  14786.  
  14787. Note that all of these functions can be used with integer arguments.  If you
  14788. want an integer result, specify d = -1 (to truncate) or feed the result to
  14789. \ffpround(xxx,0) (to round).
  14790.  
  14791. Floating-point numbers (or variables or functions that return them) can be
  14792. used in Boolean expressions (see Section 7.20.2) that compare numbers:
  14793.  
  14794.   = x y
  14795.   != x y
  14796.   < x y
  14797.   > x y
  14798.   <= x y
  14799.   >= x y
  14800.  
  14801. In these examples, x and y can be either integers or floating-point numbers
  14802. in any combination.  In an arithmetic comparison of an integer and a
  14803. floating-point number, the integer is converted to floating-point before the
  14804. comparison is made.  Examples:
  14805.  
  14806.   .\%t = 3.000000000
  14807.   .\%f = 3.141592653
  14808.   .\%i = 3
  14809.  
  14810.   if > \%f \%i echo Pi is greater.
  14811.   if = \%t \%i echo "\%i" = "\%t".
  14812.  
  14813. A floating-point number can also be used in:
  14814.  
  14815.   IF <number> <command>
  14816.  
  14817. where the <command> is executed if the <number> is nonzero.  If the number
  14818. is floating-point, the <command> is not executed if the number is 0.0, and
  14819. is executed otherwise.
  14820.  
  14821. Floating-point numbers can be sorted using ARRAY SORT /NUMERIC (see Section
  14822. 7.10.5).
  14823.  
  14824. Two floating-point constants are provided:
  14825.  
  14826.   \v(math_pi) = Pi (3.141592653...)
  14827.   \v(math_e)  = e, the base of natural logarithms (2.71828...)
  14828.  
  14829. These are given to the computer's precision, e.g. 16 digits.  This number
  14830. itself is available in a variable:
  14831.  
  14832.   \v(math_precision) = How many significant digits in a floating-point number.
  14833.  
  14834. 7.24. Tracing Script Execution
  14835.  
  14836. The TRACE command is handy for debugging scripts.
  14837.  
  14838. Syntax: TRACE [ switch ] [ object ]
  14839.  
  14840. TRACE [ { /ON, /OFF } ] [ { ASSIGNMENTS, COMMAND-LEVEL, ALL } ]
  14841.   Selects tracing of the given object.
  14842.  
  14843. Optional switches are /ON and /OFF.  If no switch is given, /ON is implied.
  14844. The trace objects are ASSIGNMENTS, COMMAND-LEVEL, and ALL.  The default object
  14845. is ALL, meaning to select all trace objects (besides ALL).  Thus TRACE by
  14846. itself selects tracing of everything, as does TRACE /ON, and TRACE /OFF turns
  14847. off all tracing.
  14848.  
  14849. When tracing of ASSIGNMENTS is on, every time the value of any user-defined
  14850. variable or macro changes, C-Kermit prints one of the following:
  14851.  
  14852. >>> name: "value"
  14853.   The name of the variable or macro followed by the new value in quotes.
  14854.   This includes implicit macro-parameter assignments during macro invocation.
  14855.  
  14856. >>> name: (undef)
  14857.   This indicates that the variable or macro has been undefined.
  14858.  
  14859. <<< name: "value"
  14860.   For RETURN statements: the name of the macro and the return value.
  14861.  
  14862. <<< name: (null)
  14863.   For RETURN statements that include no value or an empty value.
  14864.  
  14865. When tracing of COMMAND-LEVEL is on, C-Kermit prints:
  14866.  
  14867. [n] +F: "name"
  14868.   Whenever a command file is entered, where "n" is the command level
  14869.   (0 = top); the name of the command file is shown in quotes.
  14870.  
  14871. [n] +M: "name"
  14872.   Whenever a macro is entered; "n" is the command level.  The name of
  14873.   the macro is shown in quotes.
  14874.  
  14875. [n] -F: "name"
  14876.   Whenever a command file is reentered from below, when a macro or
  14877.   command file that it has invoked has returned.
  14878.  
  14879. [n] -M: "name"
  14880.   Whenever a macro is reentered from below.
  14881.  
  14882. For other debugging tools, see SHOW ARGS, SHOW STACK, SET TAKE, SET MACRO, and
  14883. of course, ECHO.
  14884.  
  14885. 7.25. Compact Substring Notation
  14886.  
  14887. It is often desirable to extract a substring from a string which is stored
  14888. in a variable, and for this we have the \fsubstring() function, which is
  14889. used like this:
  14890.  
  14891.   define \%a 1234567890
  14892.   echo \fsubstring(\%a,3,4) ; substring from 3rd character length 4
  14893.   3456
  14894.  
  14895. or like this with macro-named variables:
  14896.  
  14897.   define string 1234567890
  14898.   echo \fsubstring(\m(string),3,4)
  14899.   3456
  14900.  
  14901. C-Kermit 7.0 adds a pair of alternative compact notations:
  14902.  
  14903.   \:(variablename[start:length])  <-- Substring of variable's value
  14904.   \s(macroname[start:length])     <-- Substring of macro's definition
  14905.  
  14906. These are exactly equivalent to using \fsubstring(), except more compact to
  14907. write and also faster since evaluation is in one step instead of two.
  14908.  
  14909. The "\:()" notation can be used with any Kermit variable, that is, almost
  14910. anything that starts with a backslash:
  14911.  
  14912.   \:(\%a[2:6])      <-- equivalent to \fsubstring(\%a,2,6)
  14913.   \:(\&x[1][2:6])   <-- equivalent to \fsubstring(\&x[1],2,6)
  14914.   \:(\m(foo)[2:6])  <-- equivalent to \fsubstring(\m(foo),2,6)
  14915.   \:(\v(time)[2:6]) <-- equivalent to \fsubstring(\v(time),2,6)
  14916.   \:(\$(TERM)[2:6]) <-- equivalent to \fsubstring(\$(TERM),2,6)
  14917.   \:(ABCDEFGH[2:6]) <-- equivalent to \fsubstring(ABCDEFGH,2,6)
  14918.  
  14919. Whatever appears between the left parenthesis and the left bracket is
  14920. evaluated and then the indicated substring of the result is returned.
  14921.  
  14922. The "\s()" notation is the same, except after evaluating the variable,
  14923. the result is treated as a macro name and is looked up in the macro table.
  14924. Then the indicated substring of the macro definition is returned.  Example:
  14925.  
  14926.   define testing abcdefghijklmnopqrstuvwxyz
  14927.   define \%a testing
  14928.  
  14929.   \s(testing[2:6])  -->  bcdefg
  14930.   \:(testing[2:6])  -->  esting
  14931.   \:(\%a[2:6])      -->  esting
  14932.   \s(\%a[2:6])      -->  bcdefg
  14933.  
  14934. Note that the following two examples are equivalent:
  14935.  
  14936.   \:(\m(foo)[2:6])
  14937.   \s(foo[2:6])
  14938.  
  14939. The first number in the brackets is the 1-based starting position.  If it is
  14940. omitted, or less than 1, it is treated as 1.  If it is greater than the length
  14941. of the string, an empty string is returned.
  14942.  
  14943. The second number is the length of the desired substring.  If the second
  14944. number is omitted, is less than 0, or would be past the end of the string,
  14945. then "through the end of the string" is assumed.  If it is 0, the empty string
  14946. is returned.
  14947.  
  14948. If the brackets are empty or omitted, the original string is returned.
  14949.  
  14950. The starting position and length need not be literal numbers; they can also
  14951. be variables, functions, arithmetic expressions, or even other \s() or \:()
  14952. quantities; anything that evaluates to a number, for example:
  14953.  
  14954.   \s(block[1025:\fhex2n(\s(block[\%b:\%n+4]))/2])
  14955.  
  14956. Syntactically, \m(name) and \s(name) differ only in that the sequence [*]
  14957. at the end of the name (where * is any sequence of 0 or more characters) is
  14958. treated as substring notation in \s(name), but is considered part of the name
  14959. in \m(name) (to see why, see Section 7.10.9).
  14960.  
  14961. 7.26. New WAIT Command Options
  14962.  
  14963. The WAIT command has been extended to allow waiting for different kinds of
  14964. things (formerly it only waited for modem signals).  Now it also can wait
  14965. for file events.
  14966.  
  14967. 7.26.1. Waiting for Modem Signals
  14968.  
  14969. The previous syntax:
  14970.  
  14971.   WAIT <time> { CD, DSR, RTS, RI, ... }
  14972.  
  14973. has changed to:
  14974.  
  14975.   WAIT <time> MODEM-SIGNALS { CD, DSR, RTS, RI, ... }
  14976.  
  14977. However, the previous syntax is still accepted.  The behavior is the same
  14978. in either case.
  14979.  
  14980. 7.26.2. Waiting for File Events
  14981.  
  14982. The new WAIT option:
  14983.  
  14984.   WAIT <time> FILE { CREATION, DELETION, MODIFICATION } <filename>
  14985.  
  14986. lets you tell Kermit to wait the given amount of time (or until the given time
  14987. of day) for a file whose name is <filename> to be created, deleted, or
  14988. modified, respectively.  The <filename> may not contain wildcards.  If the
  14989. specified event does not occur within the time limit, or if WAIT CANCELLATION
  14990. is ON and you interrupt from the keyboard before the time is up, the WAIT
  14991. command fails.  If the event is MODIFICATION and the file does not exist, the
  14992. command fails.  Otherwise, if the given event occurs within the time limit,
  14993. the command succeeds.  Examples:
  14994.  
  14995.   WAIT 600 FILE DELETION oofa.tmp
  14996.     Wait up to 10 minutes for file oofa.tmp to disappear.
  14997.  
  14998.   WAIT 23:59:59 FILE MOD orders.db
  14999.     Wait until just before midnight for the orders.db file to be changed.
  15000.  
  15001. Example: Suppose you want to have the current copy of /etc/motd on your
  15002. screen at all times, and you want to hear a bell whenever it changes:
  15003.  
  15004.   def \%f /etc/motd                      ; The file of interest.
  15005.   while 1 {                              ; Loop forever...
  15006.       cls                                ; Clear the screen.
  15007.       echo \%f: \v(date) \v(time)...     ; Print 2-line heading...
  15008.       echo
  15009.       if ( not exist \%f ) {             ; If file doesn't exist,
  15010.           echo \%f does not exist...     ; print message,
  15011.           wait 600 file creat \%f        ; and wait for it to appear.
  15012.           continue
  15013.       }
  15014.       beep                               ; Something new - beep.
  15015.       type /head:\v(rows-2) \%f          ; Display the file
  15016.       if fail exit 1 \%f: \ferrstring()  ; (checking for errors).
  15017.       wait 999 file mod \%f              ; Wait for it to change.
  15018.   }
  15019.  
  15020. This notices when the file is created, deleted, or modified, and acts only
  15021. then (or when you interrupt it with); the time shown in the heading is the
  15022. time of the most recent event (including when the program started).
  15023.  
  15024. See Section 1.10, where the \v(kbchar) variable is explained.  This lets
  15025. you modify a loop like the one above to also accept single-character commands,
  15026. which interrupt the WAIT, and dispatch accordingly.  For example:
  15027.  
  15028.       wait 999 file mod \%f              ; Wait for the file to change.
  15029.       if defined \v(kbchar) {            ; Interrupted from keyboard?
  15030.           switch \v(kbchar) {            ; Handle the keystroke...
  15031.             :q, exit                     ; Q to Quit
  15032.             :h, echo blah blah, break    ; H for Help
  15033.             :default, beep, continue     ; Anything else beep and ignore
  15034.           }
  15035.       }
  15036.  
  15037. This lets you write event-driven applications that wait for up to three
  15038. events at once: a file or modem event, a timeout, and a keystroke.
  15039.  
  15040. 7.27. Relaxed FOR and SWITCH Syntax
  15041.  
  15042. For consistency with the extended IF and WHILE syntax, the FOR and SWITCH
  15043. control lists may (but need not be) enclosed in parentheses:
  15044.  
  15045.   FOR ( \%i 1 \%n 1 ) { command-list... }
  15046.   SWITCH ( \%c ) { command-list... }
  15047.  
  15048. In the FOR command, the increment item can be omitted if the control list is
  15049. enclosed in parentheses, in which case the increment defaults appropriately to
  15050. 1 or -1, depending on the values of the first two variables.
  15051.  
  15052. As with IF, the parentheses around the FOR-command control list must be set
  15053. off by spaces (in the SWITCH command, the spaces are not required since the
  15054. SWITCH expression is a single arithmetic expression).
  15055.  
  15056. Also, outer braces around the command list are supplied automatically if
  15057. you omit them, e.g.:
  15058.  
  15059.   FOR ( \%i 1 %n 1 ) echo \%i
  15060.  
  15061.  
  15062. (8) USING OTHER FILE TRANSFER PROTOCOLS
  15063.  
  15064. In C-Kermit 7.0, alternative protocols can be selected using switches.
  15065. Switches are described in section 1.5; the use of protocol-selection switches
  15066. is described in section 4.7.1.  Example:
  15067.  
  15068.   send /binary /protocol:zmodem x.tar.gz
  15069.  
  15070. Note that file transfer recovery works only with Kermit and Zmodem protocols.
  15071. With Zmodem, recovery can be initiated only by the sender.
  15072.  
  15073. Only pre-1988 versions of the publicly-distributed sz/rz programs use
  15074. Standard I/O; those released later than that do not use Standard I/O and
  15075. therefore do not work with REDIRECT.  However, Omen Technology does offer
  15076. an up-to-date redirectable version called crzsz, which must be licensed
  15077. for use:
  15078.  
  15079.   "Unix Crz and Csz support XMODEM, YMODEM, and ZMODEM transfers
  15080.   when called by dial-out programs such as Kermit and certain
  15081.   versions of cu(1).  They are clients designed for this use.
  15082.  
  15083.   "Crz and Csz are Copyrighted shareware programs.  Use of these
  15084.   programs beyond a brief evaluation period requires registration.
  15085.   Please print the "mailer.rz" file, fill out the form and return
  15086.   same with your registration."
  15087.  
  15088. To use the crzsz programs as your external XYZMODEM programs in C-Kermit,
  15089. follow the instructions in the book, but put a "c" before each command,
  15090. e.g.:
  15091.  
  15092.   set protocol zmodem {csz %s} {csz -a %s} crz crz crz crz
  15093.  
  15094. To use Zmodem protocol over Telnet or other non-transparent connections,
  15095. you might need to add the -e (Escape) option:
  15096.  
  15097.   set protocol zmodem {csz -e %s} {csz -e -a %s} crz crz crz crz
  15098.  
  15099.  
  15100. (9) COMMAND-LINE OPTIONS
  15101.  
  15102. 9.0. Extended-Format Command-Line Options
  15103.  
  15104. Standard UNIX command line options are a single letter.  C-Kermit has run
  15105. out of letters, so new options are in a new extended format:
  15106.  
  15107.  --word[:arg]
  15108.  
  15109. where a keyword (rather than a single letter) specifies the function, and if
  15110. an argument is to be included, it is separated by a colon (or equal sign).
  15111. Most of the new extended-format command-line options are only for use with the
  15112. Internet Kermit Service Daemon; see iksd.txt for details.  However, several
  15113. of them are also general in nature:
  15114.  
  15115. --nointerrupts
  15116.   Disables keyboard interrupts that are normally enabled, which are usually
  15117.   Ctrl-C (to interrupt a command) and Ctrl-Z (UNIX only, to suspend C-Kermit).
  15118.  
  15119. --help
  15120.   Lists the extended command-line options that are available in your version
  15121.   of C-Kermit.  If any options seem to be missing, that is because your
  15122.   copy of C-Kermit was built with compile-time options to deselect them.
  15123.  
  15124. --helpfile:<filename>
  15125.   Specifies the name of a file to be displayed if the user types HELP
  15126.   (not followed by a specific command or topic), in place of the built-in
  15127.   top-level help text.  The file need not fit on one screen; more-prompting
  15128.   is used if the file is more than one screen long if COMMAND MORE-PROMPTING
  15129.   is ON, as it is by default.
  15130.  
  15131. --bannerfile:<filename>
  15132.   The name of a file containing a message to be printed after the user logs
  15133.   in, in place of the normal message (Copyright notice, "Type HELP or ? for
  15134.   help", "Default transfer mode is...", etc).
  15135.  
  15136. --cdmessage:{on,off,0,1,2}
  15137.   For use in the Server-Side Server configuration; whenever the client
  15138.   tells the server to change directory, the server sends the contents of a
  15139.   "read me" file to the client's screen.  This feature is On by default,
  15140.   and operates only in client/server mode when ON or 1.  If set to 2 or
  15141.   higher, it also operates when the CD command is given at the IKSD> prompt.
  15142.   Synonym: --cdmsg.
  15143.  
  15144. --cdfile:<filename> (or list)
  15145.   When cdmessage is on, this is the name of the "read me" file to be sent.
  15146.   Normally you would specify a relative (not absolute) name, since the file
  15147.   is opened using the literal name you specified, after changing to the new
  15148.   directory.  Example:
  15149.  
  15150.     --cdfile:READ.ME
  15151.  
  15152.   You can also give a list of up to 8 filenames by (a) enclosing each
  15153.   filename in braces, and (b) enclosing the entire list in braces.  Example:
  15154.   --cdfile:{{./.readme}{READ.ME}{aaareadme.txt}{README}{read-this-first}}
  15155.   When a list is given, it is searched from left to right and the first
  15156.   file found is displayed.  The default list for UNIX is:
  15157.  
  15158.     {{./.readme}{README.TXT}{READ.ME}}
  15159.  
  15160. 9.1. Command Line Personalities
  15161.  
  15162. Beginning in version 7.0, if the C-Kermit binary is renamed to "telnet"
  15163. (or TELNET.EXE, telnet.pr, etc, depending on the platform), it accepts the
  15164. Telnet command line:
  15165.  
  15166.   telnet [ host [ port ] ]
  15167.  
  15168. In Unix, you can achieve the same effect with a symlink:
  15169.  
  15170.   cd /usr/bin
  15171.   mv telnet oldtelnet
  15172.   ln -ls /usr/local/bin/kermit telnet
  15173.  
  15174. When installed in this manner, C-Kermit always reads its initialization file.
  15175. If no host (and therefore no port) is given, C-Kermit starts in interactive
  15176. prompting mode.  If a host is given as the first command-line argument,
  15177. C-Kermit makes a connection to it.  The host argument can be an IP host name
  15178. or address, or the name of a TCP/IP entry in your C-Kermit network directory.
  15179.  
  15180. If a port is given, it is used.  If a port is not given, then if the hostname
  15181. was found in your network directory and port was also listed there, then that
  15182. port is used.  Otherwise port 23 (the Telnet port) is used.
  15183.  
  15184. When C-Kermit is called "telnet" and it is invoked with a hostname on the
  15185. command line, it exits automatically when the connection is closed.  While
  15186. the connection is open, however, you may escape back and forth as many times
  15187. as you like, transfer files, etc.
  15188.  
  15189. An rlogin personality is also available, but it is less useful, at least
  15190. in UNIX and VMS, where the Rlogin TCP port is privileged.
  15191.  
  15192. The new variable \v(name) indicates the name with which C-Kermit was invoked
  15193. ("kermit", "wermit", "k95", "telnet", etc).
  15194.  
  15195. 9.2. Built-in Help for Command Line Options
  15196.  
  15197. "kermit -h", given from the system prompt, lists as many command-line options
  15198. as will fit on a standard 24x80 screen.  For more comprehensive help, use the
  15199. interactive HELP OPTIONS command that was added in C-Kermit 7.0:
  15200.  
  15201. HELP OPTIONS
  15202.   Explains how command-line options work, their syntax, etc.
  15203.  
  15204. HELP OPTIONS ALL
  15205.   Lists all command-line options and gives brief help about each one.
  15206.  
  15207. HELP OPTION x
  15208.   Gives brief help about option "x".
  15209.  
  15210. HELP EXTENDED-OPTIONS
  15211.   Lists the available extended-format command-line options.
  15212.  
  15213. HELP EXTENDED-OPTION xxx
  15214.   Gives help for the specified extended option.
  15215.  
  15216. 9.3. New Command-Line Options
  15217.  
  15218. Command-line options added since C-Kermit 6.0 are:
  15219.  
  15220. +:  (plus sign by itself): The next argument is the name of a script to
  15221.     execute; all subsequent arguments are ignored by C-Kermit itself, but
  15222.     passed to the script as top-level copies of \%1, \%2, etc; the \&_[] is
  15223.     also set accordingly.  \%0 and \&_[0] become the name of the script file,
  15224.     rather than the pathname of the C-Kermit program, which is its normal
  15225.     value.  Primarily for use in the top line of "Kerbang" scripts in UNIX
  15226.     (see Section 7.19).  Example from UNIX command line:
  15227.  
  15228.       $ kermit [ regular kermit args ] + filename
  15229.  
  15230.     Sample first line of Kerbang script:
  15231.  
  15232.       #!/usr/local/bin/kermit +
  15233.  
  15234. --: (two hyphens surrounded by whitespace)  Equivalent to "=", for
  15235.     compatibility with UNIX getopt(1,3).
  15236.  
  15237. -G: GET (like -g), but send the incoming file to standard output.  Example:
  15238.     "kermit -G oofa.txt | lpr" retrieves a file from your local computer
  15239.     (providing it is running a Kermit program that supports the autodownload
  15240.     feature and has it enabled) and prints it.
  15241.  
  15242. -O: equivalent to -x (start up in server mode), but exits after the first
  15243.     client command has been executed (mnemonic: O = Only One).  This one is
  15244.     handy replacing "kermit -x" in the "automatically-start-Kermit-on-the-
  15245.     other-end" string:
  15246.  
  15247.       set protocol kermit {kermit -ir} {kermit -r} {kermit -x}
  15248.  
  15249.     since -x leaves the remote Kermit in server mode after the transfer,
  15250.     which can be confusing, whereas -O makes it go away automatically
  15251.     after the transfer.
  15252.  
  15253. -L: Recursive, when used in combination with -s (mnemonic: L = Levels).
  15254.     In UNIX or other environments where the shell expands wildcards itself,
  15255.     the -s argument, if it contains wildcards, must be quoted to prevent
  15256.     this, e.g.:
  15257.  
  15258.       kermit -L -s "*.c"
  15259.  
  15260.     In UNIX only, "kermit -L -s ." means to send the current directory tree.
  15261.     See sections 4.10-4.11 about recursive file transfer.
  15262.  
  15263. -V: Equivalent to SET FILE PATTERNS OFF (Section 4.3) and SET TRANSFER MODE
  15264.     MANUAL.  In other words, take the FILE TYPE setting literally.  For
  15265.     example, "kermit -VT oofa.bin" means send the file in Text mode, no matter
  15266.     what its name is and no matter whether a kindred spirit is recognized at
  15267.     the other end of the connection.
  15268.  
  15269. -0: (digit zero) means "be 100% transparent in CONNECT mode".  This is
  15270.     equivalent to the following series of commands: SET PARITY NONE, SET
  15271.     COMMAND BYTESIZE 8, SET TERMINAL BYTESIZE 8, SET FLOW NONE, SET
  15272.     TERM ESCAPE DISABLED, SET TERM CHAR TRANSPARENT, SET TERM AUTODOWNLOAD
  15273.     OFF, SET TERM APC OFF, SET TELOPT KERMIT REFUSE REFUSE.
  15274.  
  15275.  
  15276. (10) C-KERMIT AND G-KERMIT
  15277.  
  15278. Every multifunctioned and long-lived software program grows in complexity
  15279. and size over time to meet the needs and requests of its users and the demands
  15280. of the underlying technology as it changes.
  15281.  
  15282. Eventually users begin to notice how big the application has grown, how much
  15283. disk space it occupies, how long it takes to load, and they start to long for
  15284. the good old days when it was lean and mean.  Not long after that they begin
  15285. asking for a "light" version that only does the basics with no frills.
  15286.  
  15287. And so it is with C-Kermit.  A "light" version of Kermit was released (for
  15288. UNIX only) in December 1999 under the GNU General Public License; thus it is
  15289. called G-Kermit (for GNU Kermit).  All it does is send and receive files,
  15290. period.  You can find it at:
  15291.  
  15292.   http://www.columbia.edu/kermit/gkermit.html
  15293.  
  15294. Where the C-Kermit 7.0 binary might be anywhere from 1 to 3 million bytes in
  15295. size, the G-Kermit binary ranges from 30K to 100K, depending on the underlying
  15296. architecture (RISC vs CISC, etc).
  15297.  
  15298. G-Kermit and C-Kermit may reside side-by-side on the same computer.  G-Kermit
  15299. does not make connections; it does not have a script language; it does not
  15300. translate character sets.  G-Kermit may be used instead of C-Kermit when:
  15301.  
  15302.  . It is on the remote end.
  15303.  . Files are to be transferred in binary mode or in text mode without
  15304.    character-set translation.
  15305.  . File timestamps don't need to be preserved.
  15306.  
  15307. In such cases G-Kermit might be preferred since it generally starts up faster,
  15308. and yet transfers files just as fast on most (but not necessarily all) kinds
  15309. of connections; for example, it supports streaming (Section 4.20).
  15310.  
  15311. G-Kermit is also handy for bootstrapping.  It is easier to load on a new
  15312. computer than C-Kermit -- it fits on a floppy diskette with plenty of room to
  15313. spare.  Thus if you have (say) an old PC running (say) SCO Xenix and no
  15314. network connection, you can download the Xenix version of G-Kermit to (say) a
  15315. DOS or Windows PC, copy it to diskette, read the diskette on Xenix with
  15316. "dosread", and then use G-Kermit to receive C-Kermit (which does not fit on a
  15317. diskette).  If diskettes aren't an option, other bootstrapping methods are
  15318. possible too -- see the G-Kermit web page for details.
  15319.  
  15320.  
  15321. III. APPENDICES
  15322.  
  15323. III.1.  Character Set Tables
  15324.  
  15325. III.1.1. The Hewlett Packard Roman8 Character Set
  15326.  
  15327. dec col/row oct hex  description
  15328. 160  10/00  240  A0  (Undefined)
  15329. 161  10/01  241  A1  A grave
  15330. 162  10/02  242  A2  A circumflex
  15331. 163  10/03  243  A3  E grave
  15332. 164  10/04  244  A4  E circumflex
  15333. 165  10/05  245  A5  E diaeresis
  15334. 166  10/06  246  A6  I circumflex
  15335. 167  10/07  247  A7  I diaeresis
  15336. 168  10/08  250  A8  Acute accent
  15337. 169  10/09  251  A9  Grave accent
  15338. 170  10/10  252  AA  Circumflex accent
  15339. 171  10/11  253  AB  Diaeresis
  15340. 172  10/12  254  AC  Tilde accent
  15341. 173  10/13  255  AD  U grave
  15342. 174  10/14  256  AE  U circumflex
  15343. 175  10/15  257  AF  Lira symbol
  15344. 176  11/00  260  B0  Top bar (macron)
  15345. 177  11/01  261  B1  Y acute
  15346. 178  11/02  262  B2  y acute
  15347. 179  11/03  263  B3  Degree Sign
  15348. 180  11/04  264  B4  C cedilla
  15349. 181  11/05  265  B5  c cedilla
  15350. 182  11/06  266  B6  N tilde
  15351. 183  11/07  267  B7  n tilde
  15352. 184  11/08  270  B8  Inverted exclamation mark
  15353. 185  11/09  271  B9  Inverted question mark
  15354. 186  11/10  272  BA  Currency symbol
  15355. 187  11/11  273  BB  Pound sterling symbol
  15356. 188  11/12  274  BC  Yen symbol
  15357. 189  11/13  275  BD  Paragraph
  15358. 190  11/14  276  BE  Florin (Guilder) symbol
  15359. 191  11/15  277  BF  Cent symbol
  15360. 192  12/00  300  C0  a circumflex
  15361. 193  12/01  301  C1  e circumflex
  15362. 194  12/02  302  C2  o circumflex
  15363. 195  12/03  303  C3  u circumflex
  15364. 196  12/04  304  C4  a acute
  15365. 197  12/05  305  C5  e acute
  15366. 198  12/06  306  C6  o acute
  15367. 199  12/07  307  C7  u acute
  15368. 200  12/08  310  C8  a grave
  15369. 201  12/09  311  C9  e grave
  15370. 202  12/10  312  CA  o grave
  15371. 203  12/11  313  CB  u grave
  15372. 204  12/12  314  CC  a diaeresis
  15373. 205  12/13  315  CD  e diaeresis
  15374. 206  12/14  316  CE  o diaeresis
  15375. 207  12/15  317  CF  u diaeresis
  15376. 208  13/00  320  D0  A ring
  15377. 209  13/01  321  D1  i circumflex
  15378. 210  13/02  322  D2  O with stroke
  15379. 211  13/03  323  D3  AE digraph
  15380. 212  13/04  324  D4  a ring
  15381. 213  13/05  325  D5  i acute
  15382. 214  13/06  326  D6  o with stroke
  15383. 215  13/07  327  D7  ae digraph
  15384. 216  13/08  330  D8  A diaeresis
  15385. 217  13/09  331  D9  i grave
  15386. 218  13/10  332  DA  O diaeresis
  15387. 219  13/11  333  DB  U diaeresis
  15388. 220  13/12  334  DC  E acute
  15389. 221  13/13  335  DD  i diaeresis
  15390. 222  13/14  336  DE  German sharp s
  15391. 223  13/15  337  DF  O circumflex
  15392. 224  14/00  340  E0  A acute
  15393. 225  14/01  341  E1  A tilde
  15394. 226  14/02  342  E2  a tilde
  15395. 227  14/03  343  E3  Icelandic Eth
  15396. 228  14/04  344  E4  Icelandic eth
  15397. 229  14/05  345  E5  I acute
  15398. 230  14/06  346  E6  I grave
  15399. 231  14/07  347  E7  O acute
  15400. 232  14/08  350  E8  O grave
  15401. 233  14/09  351  E9  O tilde
  15402. 234  14/10  352  EA  o tilde
  15403. 235  14/11  353  EB  S caron
  15404. 236  14/12  354  EC  s caron
  15405. 237  14/13  355  ED  U acute
  15406. 238  14/14  356  EE  Y diaeresis
  15407. 239  14/15  357  EF  y diaeresis
  15408. 240  15/00  360  F0  Icelandic Thorn
  15409. 241  15/01  361  F1  Icelandic thorn
  15410. 242  15/02  362  F2  Middle dot
  15411. 243  15/03  363  F3  Greek mu
  15412. 244  15/04  364  F4  Pilcrow sign
  15413. 245  15/05  365  F5  Fraction 3/4
  15414. 246  15/06  366  F6  Long dash, horizontal bar
  15415. 247  15/07  367  F7  Fraction 1/4
  15416. 248  15/08  370  F8  Fraction 1/2
  15417. 249  15/09  371  F9  Feminine ordinal
  15418. 250  15/10  372  FA  Masculine ordinal
  15419. 251  15/11  373  FB  Left guillemot
  15420. 252  15/12  374  FC  Solid box
  15421. 253  15/13  375  FD  Right guillemot
  15422. 254  15/14  376  FE  Plus or minus sign
  15423. 255  15/15  377  FF  (Undefined)
  15424.  
  15425. III.1.2. Greek Character Sets
  15426.  
  15427. III.1.2.1. The ISO 8859-7 Latin / Greek Alphabet = ELOT 928
  15428.  
  15429. dec col/row oct hex  description
  15430. 160  10/00  240  A0  No-break space
  15431. 161  10/01  241  A1  Left single quotation mark
  15432. 162  10/02  242  A2  right single quotation mark
  15433. 163  10/03  243  A3  Pound sign
  15434. 164  10/04  244  A4  (UNUSED)
  15435. 165  10/05  245  A5  (UNUSED)
  15436. 166  10/06  246  A6  Broken bar
  15437. 167  10/07  247  A7  Paragraph sign
  15438. 168  10/08  250  A8  Diaeresis (Dialytika)
  15439. 169  10/09  251  A9  Copyright sign
  15440. 170  10/10  252  AA  (UNUSED)
  15441. 171  10/11  253  AB  Left angle quotation
  15442. 172  10/12  254  AC  Not sign
  15443. 173  10/13  255  AD  Soft hyphen
  15444. 174  10/14  256  AE  (UNUSED)
  15445. 175  10/15  257  AF  Horizontal bar (Parenthetiki pavla)
  15446. 176  11/00  260  B0  Degree sign
  15447. 177  11/01  261  B1  Plus-minus sign
  15448. 178  11/02  262  B2  Superscript two
  15449. 179  11/03  263  B3  Superscript three
  15450. 180  11/04  264  B4  Accent (tonos)
  15451. 181  11/05  265  B5  Diaeresis and accent (Dialytika and Tonos)
  15452. 182  11/06  266  B6  Alpha with accent
  15453. 183  11/07  267  B7  Middle dot (Ano Teleia)
  15454. 184  11/08  270  B8  Epsilon with accent
  15455. 185  11/09  271  B9  Eta with accent
  15456. 186  11/10  272  BA  Iota with accent
  15457. 187  11/11  273  BB  Right angle quotation
  15458. 188  11/12  274  BC  Omicron with accent
  15459. 189  11/13  275  BD  One half
  15460. 190  11/14  276  BE  Upsilon with accent
  15461. 191  11/15  277  BF  Omega with accent
  15462. 192  12/00  300  C0  iota with diaeresis and accent
  15463. 193  12/01  301  C1  Alpha
  15464. 194  12/02  302  C2  Beta
  15465. 195  12/03  303  C3  Gamma
  15466. 196  12/04  304  C4  Delta
  15467. 197  12/05  305  C5  Epsilon
  15468. 198  12/06  306  C6  Zeta
  15469. 199  12/07  307  C7  Eta
  15470. 200  12/08  310  C8  Theta
  15471. 201  12/09  311  C9  Iota
  15472. 202  12/10  312  CA  Kappa
  15473. 203  12/11  313  CB  Lamda
  15474. 204  12/12  314  CC  Mu
  15475. 205  12/13  315  CD  Nu
  15476. 206  12/14  316  CE  Ksi
  15477. 207  12/15  317  CF  Omicron
  15478. 208  13/00  320  D0  Pi
  15479. 209  13/01  321  D1  Rho
  15480. 210  13/02  322  D2  (UNUSED)
  15481. 211  13/03  323  D3  Sigma
  15482. 212  13/04  324  D4  Tau
  15483. 213  13/05  325  D5  Upsilon
  15484. 214  13/06  326  D6  Phi
  15485. 215  13/07  327  D7  Khi
  15486. 216  13/08  330  D8  Psi
  15487. 217  13/09  331  D9  Omega
  15488. 218  13/10  332  DA  Iota with diaeresis
  15489. 219  13/11  333  DB  Upsilon with diaeresis
  15490. 220  13/12  334  DC  alpha with accent
  15491. 221  13/13  335  DD  epsilon with accent
  15492. 222  13/14  336  DE  eta with accent
  15493. 223  13/15  337  DF  iota with accent
  15494. 224  14/00  340  E0  upsilon with diaeresis and accent
  15495. 225  14/01  341  E1  alpha
  15496. 226  14/02  342  E2  beta
  15497. 227  14/03  343  E3  gamma
  15498. 228  14/04  344  E4  delta
  15499. 229  14/05  345  E5  epsilon
  15500. 230  14/06  346  E6  zeta
  15501. 231  14/07  347  E7  eta
  15502. 232  14/08  350  E8  theta
  15503. 233  14/09  351  E9  iota
  15504. 234  14/10  352  EA  kappa
  15505. 235  14/11  353  EB  lamda
  15506. 236  14/12  354  EC  mu
  15507. 237  14/13  355  ED  nu
  15508. 238  14/14  356  EE  ksi
  15509. 239  14/15  357  EF  omicron
  15510. 240  15/00  360  F0  pi
  15511. 241  15/01  361  F1  rho
  15512. 242  15/02  362  F2  terminal sigma
  15513. 243  15/03  363  F3  sigma
  15514. 244  15/04  364  F4  tau
  15515. 245  15/05  365  F5  upsilon
  15516. 246  15/06  366  F6  phi
  15517. 247  15/07  367  F7  khi
  15518. 248  15/08  370  F8  psi
  15519. 249  15/09  371  F9  omega
  15520. 250  15/10  372  FA  iota with diaeresis
  15521. 251  15/11  373  FB  upsilon with diaeresis
  15522. 252  15/12  374  FC  omicron with diaeresis
  15523. 253  15/13  375  FD  upsilon with accent
  15524. 254  15/14  376  FE  omega with accent
  15525. 255  15/15  377  FF  (UNUSED)
  15526.  
  15527. III.1.2.2. The ELOT 927 Character Set
  15528.  
  15529. dec col/row oct hex  description
  15530.  32  02/00   40  20  SPACE
  15531.  33  02/01   41  21  EXCLAMATION MARK
  15532.  34  02/02   42  22  QUOTATION MARK
  15533.  35  02/03   43  23  NUMBER SIGN
  15534.  36  02/04   44  24  DOLLAR SIGN
  15535.  37  02/05   45  25  PERCENT SIGN
  15536.  38  02/06   46  26  AMPERSAND
  15537.  39  02/07   47  27  APOSTROPHE
  15538.  40  02/08   50  28  LEFT PARENTHESIS
  15539.  41  02/09   51  29  RIGHT PARENTHESIS
  15540.  42  02/10   52  2A  ASTERISK
  15541.  43  02/11   53  2B  PLUS SIGN
  15542.  44  02/12   54  2C  COMMA
  15543.  45  02/13   55  2D  HYPHEN, MINUS SIGN
  15544.  46  02/14   56  2E  PERIOD, FULL STOP
  15545.  47  02/15   57  2F  SOLIDUS, SLASH
  15546.  48  03/00   60  30  DIGIT ZERO
  15547.  49  03/01   61  31  DIGIT ONE
  15548.  50  03/02   62  32  DIGIT TWO
  15549.  51  03/03   63  33  DIGIT THREE
  15550.  52  03/04   64  34  DIGIT FOUR
  15551.  53  03/05   65  35  DIGIT FIVE
  15552.  54  03/06   66  36  DIGIT SIX
  15553.  55  03/07   67  37  DIGIT SEVEN
  15554.  56  03/08   70  38  DIGIT EIGHT
  15555.  57  03/09   71  39  DIGIT NINE
  15556.  58  03/10   72  3A  COLON
  15557.  59  03/11   73  3B  SEMICOLON
  15558.  60  03/12   74  3C  LESS-THAN SIGN, LEFT ANGLE BRACKET
  15559.  61  03/13   75  3D  EQUALS SIGN
  15560.  62  03/14   76  3E  GREATER-THAN SIGN, RIGHT ANGLE BRACKET
  15561.  63  03/15   77  3F  QUESTION MARK
  15562.  64  04/00  100  40  COMMERCIAL AT SIGN
  15563.  65  04/01  101  41  CAPITAL LETTER A
  15564.  66  04/02  102  42  CAPITAL LETTER B
  15565.  67  04/03  103  43  CAPITAL LETTER C
  15566.  68  04/04  104  44  CAPITAL LETTER D
  15567.  69  04/05  105  45  CAPITAL LETTER E
  15568.  70  04/06  106  46  CAPITAL LETTER F
  15569.  71  04/07  107  47  CAPITAL LETTER G
  15570.  72  04/08  110  48  CAPITAL LETTER H
  15571.  73  04/09  111  49  CAPITAL LETTER I
  15572.  74  04/10  112  4A  CAPITAL LETTER J
  15573.  75  04/11  113  4B  CAPITAL LETTER K
  15574.  76  04/12  114  4C  CAPITAL LETTER L
  15575.  77  04/13  115  4D  CAPITAL LETTER M
  15576.  78  04/14  116  4E  CAPITAL LETTER N
  15577.  79  04/15  117  4F  CAPITAL LETTER O
  15578.  80  05/00  120  50  CAPITAL LETTER P
  15579.  81  05/01  121  51  CAPITAL LETTER Q
  15580.  82  05/02  122  52  CAPITAL LETTER R
  15581.  83  05/03  123  53  CAPITAL LETTER S
  15582.  84  05/04  124  54  CAPITAL LETTER T
  15583.  85  05/05  125  55  CAPITAL LETTER U
  15584.  86  05/06  126  56  CAPITAL LETTER V
  15585.  87  05/07  127  57  CAPITAL LETTER W
  15586.  88  05/08  130  58  CAPITAL LETTER X
  15587.  89  05/09  131  59  CAPITAL LETTER Y
  15588.  90  05/10  132  5A  CAPITAL LETTER Z
  15589.  91  05/11  133  5B  LEFT SQUARE BRACKET
  15590.  92  05/12  134  5C  REVERSE SOLIDUS, BACKSLASH
  15591.  93  05/13  135  5D  RIGHT SQUARE BRACKET
  15592.  94  05/14  136  5E  CIRCUMFLEX ACCENT
  15593.  95  05/15  137  5F  UNDERSCORE
  15594.  96  06/00  140  60  ACCENT GRAVE
  15595.  97  06/01  141  61  GREEK LETTER ALPHA
  15596.  98  06/02  142  62  GREEK LETTER BETA
  15597.  99  06/03  143  63  GREEK LETTER GAMMA
  15598. 100  06/04  144  64  GREEK LETTER DELTA
  15599. 101  06/05  145  65  GREEK LETTER EPSILON
  15600. 102  06/06  146  66  GREEK LETTER ZETA
  15601. 103  06/07  147  67  GREEK LETTER ETA
  15602. 104  06/08  150  68  GREEK LETTER THETA
  15603. 105  06/09  151  69  GREEK LETTER IOTA
  15604. 106  06/10  152  6A  GREEK LETTER KAPPA
  15605. 107  06/11  153  6B  GREEK LETTER LAMDA
  15606. 108  06/12  154  6C  GREEK LETTER MU
  15607. 109  06/13  155  6D  GREEK LETTER NU
  15608. 110  06/14  156  6E  GREEK LETTER KSI
  15609. 111  06/15  157  6F  GREEK LETTER OMICRON
  15610. 112  07/00  160  70  GREEK LETTER PI
  15611. 113  07/01  161  71  GREEK LETTER RHO
  15612. 114  07/02  162  72  GREEK LETTER SIGMA
  15613. 115  07/03  163  73  GREEK LETTER TAU
  15614. 116  07/04  164  74  GREEK LETTER UPSILON
  15615. 117  07/05  165  75  GREEK LETTER FI
  15616. 118  07/06  166  76  GREEK LETTER XI
  15617. 119  07/07  167  77  GREEK LETTER PSI
  15618. 120  07/08  170  78  GREEK LETTER OMEGA
  15619. 121  07/09  171  79  SPACE
  15620. 122  07/10  172  7A  SPACE
  15621. 123  07/11  173  7B  LEFT CURLY BRACKET, LEFT BRACE
  15622. 124  07/12  174  7C  VERTICAL LINE, VERTICAL BAR
  15623. 125  07/13  175  7D  RIGHT CURLY BRACKET, RIGHT BRACE
  15624. 126  07/14  176  7E  TILDE
  15625. 127  07/15  177  7F  RUBOUT, DELETE
  15626.  
  15627. III.1.2.3. PC Code Page 869
  15628.  
  15629. (to be filled in...)
  15630.  
  15631. III.2. Updated Country Codes
  15632.  
  15633. Date: Mon, 7 Apr 1997 23:23:49 EDT
  15634. From: Dave Leibold <dleibold@else.net>
  15635. Newsgroups: comp.dcom.telecom
  15636. Subject: Ex-USSR Country Codes Profile
  15637. Organization: TELECOM Digest
  15638.  
  15639. Ex-USSR Country Codes Profile
  15640. 4 April 1997
  15641.  
  15642. Below is a summary of the country codes that have formed in the wake
  15643. of the USSR dissolution, along with some updated findings and reports.
  15644. Additional or corrected information on any of these nations would be
  15645. welcome (c/o dleibold@else.net).
  15646.  
  15647. * Kyrgyz Republic country code 996 will take effect, at least in
  15648.   Canada, effective 1 May 1997, according to CRTC Telecom Order 97-464,
  15649.   based on Stentor Tariff Notice 433. There is no indication whether
  15650.   there will be a permissive dialing period involved or for how long
  15651.   such a permissive operation would remain.
  15652.  
  15653. * Country code 992 was reported as a recent assignment for Tajikistan,
  15654.   which will be moving from country code 7 at some unknown time.
  15655.  
  15656. * Uzbekistan has its own country code assignment, but I have no
  15657.   information if this is in service yet or what implementation dates
  15658.   have been set.
  15659.  
  15660. * Kazakstan does not have a known separate country code assignment
  15661.   at present. It remains in country code 7 for the time being.
  15662.  
  15663. * Russia seems destined to keep country code 7.
  15664.  
  15665. * Recent news reports speak of some agreements forming between Russia and
  15666. Belarus. While there is no outright reunification yet, there is expected
  15667. to be much closer ties between the two nations. Whether this will lead to
  15668. a reunification of telephone codes remains to be seen.
  15669.  
  15670. In the table, "Effective" means the date at which the country code
  15671. began service (which could vary according to the nation). "Mandatory"
  15672. means the date at which the country code 7 is invalid for calls to
  15673. that nation. There are a number of question marks since exact
  15674. dates have not been collected in all cases.
  15675.  
  15676. CC  Nation            Effective     Mandatory    Notes
  15677.  
  15678. 370 Lithuania         1993?         ???          Announced Jan 1993
  15679. 371 Latvia            1993?         ???
  15680. 372 Estonia           1 Feb 1993?   March 1993?
  15681. 373 Moldova           1993?         ???          Announced Jan 1993
  15682. 374 Armenia           1 May 1995    1 July 1995  Announced Jan 1995 (ITU)
  15683. 375 Belarus           16 Apr 1995   1997?
  15684. 380 Ukraine           16 Apr 1995   Oct 1995?
  15685. 7   Kazakstan         (no known changes)
  15686. 7   Russia            (presumably not changing)
  15687. 992 Tajikistan        ???           ???          Announced 1996-7?
  15688. 993 Turkmenistan      3 Jan 1997    3 Apr 1997   Canada as of 29 Nov 1996
  15689. 994 Azerbaijan        Sept 1994?    ???          Announced 1992
  15690. 995 Georgia           1994?         ???          ref: Telecom Digest Oct 1994
  15691. 996 Kyrgyz Republic   1 May 1997    ???          ref: Stentor Canada/CRTC
  15692. 998 Uzbekistan        ???           ???          Announced 1996? (ITU)
  15693.  
  15694. Details courtesy Toby Nixon, ITU, Stentor (Canada), CRTC (Canada),
  15695. TELECOM Digest (including information collected for the country code
  15696. listings).
  15697.  
  15698.  
  15699. IV. ERRATA & CORRIGENDA
  15700.  
  15701. The following errors in "Using C-Kermit", Second Edition, first printing,
  15702. have been noted.
  15703.  
  15704. First, some missing acknowledgements for C-Kermit 6.0: JE Jones of Microware
  15705. for help with OS-9, Nigel Roles for his help with Plan 9, Lucas Hart for help
  15706. with VMS and Digital UNIX, Igor Kovalenko for his help with QNX.  And later,
  15707. to Susan Kleinmann for her help with Debian Linux packaging; Patrick
  15708. Volkerding for his help with Slackware Linux packaging; Jim Knoble for his
  15709. help with Red Hat Linux packaging; and to dozens of others for sending
  15710. individual C-Kermit binaries for varied and diverse platforms.
  15711.  
  15712. Thanks to James Spath for both binaries and reporting many of the typos
  15713. noted below.  Also to Dat Thuc Nguyen for spotting several typos.
  15714.  
  15715. PAGE    REMARKS
  15716. COVER   "COS" is a misprint.  There is no COS.  Pretend it says "SCO" or "VOS".
  15717.         (This is fixed in the second printing.)
  15718.  xxi    Second line: Fred Smith's affiliation should be Computrition.
  15719.  83     Change "commands other" to "commands as other" (1st paragraph)
  15720.  87     Change "The the" to "The" (2nd paragraph)
  15721.  92     "set modem-type user-defined supra" should be "set modem type ..."
  15722.  95     Change "VI" to "vi" (1st paragraph)
  15723.  96     Change "it it" to "it is" (1st paragraph)
  15724.  97     Change "advantage a literal" to "advantage of a literal" (2nd
  15725.         paragraph)
  15726. 102     The call-waiting example would be better as SET DIAL PREFIX *70W
  15727.         (rather than "*70,") because the former will not cause an incorrect
  15728.         call to be placed with pulse dialing.
  15729. 123     Third paragraph from bottom: "..otherwise if a your local username.."
  15730.         should be "..otherwise your local username..".
  15731. 160     Delete the "it" between "and" and "to" (2nd paragraph)
  15732. 185     In "When TRANSFER DISPLAY is OFF, C-Kermit skips the display...",
  15733.         "OFF" should be "NONE".
  15734. 187     The last paragraph says the "A command" is ignored, should be "S".
  15735. 194     Change "it known" to "it is known" (4th paragraph).
  15736. 235     In C-Kermit 7.0, the syntax of the GET command changed.  MGET now
  15737.         must be used to get a list of files and there is no more multiline
  15738.         GET command.
  15739. 268     Last paragraph: "effect" should be "affect".
  15740. 275     In the SET PROTOCOL KERMIT description, the following sentence is
  15741.         incorrect and should be removed: 'If you omit the commands, the
  15742.         default ones are restored: "kermit -ir" and "kermit -r" respectively".
  15743.         The correct information is given at the bottom of page 281.
  15744. 279     9th line.  The decimal value of ST is 156, not 155.
  15745. 295     In the stepping stones, skip ahead to Chapter 17 on p. 327.
  15746. 298     Table 16-2, Portuguese entry.  Column 4/00 should show section sign,
  15747.         not acute accent.
  15748. 316     Other languages written in the Hebrew alphabet include Karaim (a Turkic
  15749.         language spoken in Lithuania and Poland), Judeo-Kurdish, and Judeo-
  15750.         Georgian.
  15751. 332     UNDEFINE definition, change "This just" to "This is just".
  15752. 344     It might be necessary to set the modem's pulse generation rate when
  15753.         sending numeric pages; most Hayes compatible modems use the S11
  15754.         register for this.
  15755. 350     Delete "is" from between "It" and "ceases" (4th paragraph)
  15756. 351     Top - both occurrences of "print \%a" should be "echo \%a".
  15757. 364     \v(input) and \v(query) out of alphabetical order.
  15758. 378     In the MYSEND macro, "if not \m(rc) goto bad" should be:
  15759.         "if \m(rc) goto bad" (remove the "not").
  15760. 382-383 It should be stated that the loop control variable must be of the \%a
  15761.         type, or else an array element; macro names can not be used for this.
  15762. 383     In line 3, "\%f[\%i]" should be "\&f[\%i]".
  15763. 383     In the sort example, it should be stated that the array is 1-based.
  15764. 387     Change "You can list" to "You can get a list" (5th paragraph)
  15765. 393     \Fverify() description.  The 3rd sentence could be stated more clearly
  15766.         as "If all characters in string2 are also in string1, 0 is returned."
  15767. 398     Copying \ffiles() results to an array before is not required as of
  15768.         C-Kermit 7.0 (see section 7.3).
  15769. 403     In "(\%a + 3) * (\%b  5)", a minus sign is missing between b and 5.
  15770. 407     C-Kermit 7.0 no longer supports multiline GET.  Change
  15771.         "get, \%1, \%2" to "get {\%1} {\%2}" or "get /as:{\%2} {\%1}".
  15772. 409     READ example while loop should be:
  15773.         while success { echo \m(line), read line }
  15774. 409     "WRITE file" should be "WRITE keyword" (you can't put a filename there)
  15775.         (The same applies to WRITE-LINE / WRITELN).
  15776. 414     \Funhexify() missing from Table 18-3.
  15777. 425     MINPUT definition, change 2nd "text2" to "text3".
  15778. 436     Several lines are missing from the UNIXLOGIN macro listing.
  15779.         After the "xif fail" block, insert:
  15780.  
  15781.       out \%1\13                    ; Send username, carriage return
  15782.       inp 5 Password:               ; Wait 5 sec for this prompt
  15783.       if fail end 1 No password prompt
  15784.       pause                         ; Wait a sec
  15785.       out \%2\13                    ; Send password
  15786.  
  15787. 440     Change "set terminal byteszie" to "set terminal bytesize".
  15788.         Change "input Password:" to "input 10 Password".
  15789. 448     Franchise script: "access line" should be "access \m(line)".
  15790. 453     There are two incorrectly coded IF statements in the DELIVER macro
  15791.         definition.  Replace both occurrences of "if > \%1 \%3 {" with
  15792.         "xif > \%i \%3 {" (replace "if" by "xif" and "\%1" with "\%i").
  15793. 453     "the the" (last paragraph) should be "the".
  15794. 454     EOT (last paragraph) is End of Transmission, not End of Text.
  15795. 457     _DEFINE definition: "name constructed" should be "name is constructed".
  15796. 457     "macro for and" (last paragraph) should be "macro and".
  15797. 459     Should explain that \v(user) is a legal abbreviation of \v(userid).
  15798. 480     Figure II-2 is backwards; the least-significant bit is transmitted
  15799.         first, then up to the highest, and the parity bit last.
  15800. 534     The VMS Appendix section on Odd Record Lengths no longer applies;
  15801.         C-Kermit 7.0 handles odd record lengths as well as even ones.
  15802. 559     Table VIII-3, Portuguese entry.  Column 4/00 should show section sign,
  15803.         not acute accent.
  15804. 560-563 HP-Roman8 missing from Table VII-4; there wasn't room to squeeze it in.
  15805.         It is listed in section II(6).
  15806. 565     "d stroke" in Table VII-5 has the wrong appearance; the stem should
  15807.         be upright.  The letter shown in the table is actually a lowercase
  15808.         Icelandic eth, which has a curved stem.
  15809. 601-604 BeBox, BeOS, Plan 9, and probably others not listed in trademarks.
  15810. 604     The words "SCRIBE TEXT FORMATTER" appear at the end of the last
  15811.         sentence of the first paragraph of the Colophon.  They should have
  15812.         been in the Index.
  15813. Index:  Missing entries: SET { SEND, RECEIVE } PATHNAMES, Call waiting, ...
  15814.     \F()            Page 605, add also 413-414
  15815.     \Fbreak         389
  15816.     \Fcapitalize    390
  15817.     \Fchecksum      414
  15818.     \Fcrc16         414
  15819.     \Fexecute       414
  15820.     \Fhexify        390
  15821.     \Fltrim         391
  15822.         \Frepeat        392
  15823.     \Fspawn         392
  15824.     \Ftod2secs      399
  15825.     \v() built_in   Page 606, add also 361-364
  15826.     \v(_line)       354, 361
  15827.     \v(apcactive)   361
  15828.     \v(charset)     362
  15829.     \v(cpu)         362
  15830.     \v(crc16)       357, 362
  15831.     \v(d$xxx)       add page 362
  15832.     \v(dialnumber)  362
  15833.     \v(dialresult)  362
  15834.     \v(errno)       362
  15835.     \v(errstring)   362
  15836.     \v(exedir)      362
  15837.     \v(inidir)      363
  15838.     \v(ipaddress)   363
  15839.     \v(keyboard)    363
  15840.     \v(macro)       363
  15841.     \v(minput)      363
  15842.     \v(m_xxx)       94, 363
  15843.     \v(password)    364
  15844.     \v(query)       364
  15845.     \v(prompt)      364
  15846.     \v(speed)       356, 364
  15847.     \v(startup)     364
  15848.     \v(status)      364
  15849.     \v(sysid)       364
  15850.     \v(system)      364
  15851.     \v(fsize)       at lower half page 606 should read \v(tfsize)
  15852.     \v(xversion)    364
  15853.         BEEP Command    40
  15854.         SET FLOW        62, 212
  15855.  
  15856. Figure II-5 on page 493.  The pin assignments of the Mini Din-8 connector
  15857. are not described anywhere.  As noted in the text, these tend to vary from
  15858. vendor to vendor.  One common arrangement is:
  15859.  
  15860.   1. HSKout (Handshake out -- definition depends on software)
  15861.   2. HSKin  (Handshake in or external clock)
  15862.   3. TxD-
  15863.   4. Not used
  15864.   5. RxD-
  15865.   6. TxD+
  15866.   7. Not used
  15867.   8. RxD+
  15868.  
  15869. Note the "balanced pairs" for Receive Data (RxD) and Transmit Data (TxD), and
  15870. the utter lack of modem signals.  These connectors follow the RS-423 standard,
  15871. rather than RS-232.  In some arrangements, Pin 1 is used for DTR and Pin 2 for
  15872. CD; in others Pin 1 is RTS and Pin 2 is CTS.
  15873.  
  15874. Please send reports of other errors to the authors, as well as suggestions for
  15875. improvements, additional index entries, and any other comments:
  15876.  
  15877.   kermit@columbia.edu
  15878.  
  15879. APPENDIX V. ADDITIONAL COPYRIGHT NOTICES
  15880.  
  15881. The following copyrights cover some of the source code used in the development
  15882. of C-Kermit, Kermit 95, or Kermit 95 support libraries.
  15883.  
  15884. /*****************************************************************************/
  15885. /*                                                                           */
  15886. /*              Copyright (c) 1995 by Oy Online Solutions Ltd.               */
  15887. /*                                                                           */
  15888. /*   Distribution of this source code is strictly forbbidden. Use of this    */
  15889. /*   source code is granted to the University of Columbia C-Kermit project   */
  15890. /*   to be distributed in binary format only. Please familiarize yourself    */
  15891. /*   with the accompanying LICENSE.P file.                                   */
  15892. /*                                                                           */
  15893. /*****************************************************************************/
  15894.  
  15895. used for Xmodem, Ymodem, and Zmodem protocol in Kermit 95 (p95.dll, p2.dll)
  15896.  
  15897. -----
  15898.  
  15899. Copyright (c) 1997 Stanford University
  15900.  
  15901. The use of this software for revenue-generating purposes may require a
  15902. license from the owners of the underlying intellectual property.
  15903. Specifically, the SRP-3 protocol may not be used for revenue-generating
  15904. purposes without a license.
  15905.  
  15906. Within that constraint, permission to use, copy, modify, and distribute
  15907. this software and its documentation for any purpose is hereby granted
  15908. without fee, provided that the above copyright notices and this permission
  15909. notice appear in all copies of the software and related documentation.
  15910.  
  15911. THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  15912. EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  15913. WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  15914.  
  15915. IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15916. INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  15917. RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
  15918. THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
  15919. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15920.  
  15921. Used for Secure Remote Password (TM) protocol (SRP) in C-Kermit,
  15922. Kermit 95 (k95.exe, k2.exe, k95crypt.dll, k2crypt.dll)
  15923.  
  15924. -----
  15925.  
  15926. Copyright 1990 by the Massachusetts Institute of Technology.
  15927. All Rights Reserved.
  15928.  
  15929. Export of this software from the United States of America may
  15930.   require a specific license from the United States Government.
  15931.   It is the responsibility of any person or organization contemplating
  15932.   export to obtain such a license before exporting.
  15933.  
  15934. WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  15935. distribute this software and its documentation for any purpose and
  15936. without fee is hereby granted, provided that the above copyright
  15937. notice appear in all copies and that both that copyright notice and
  15938. this permission notice appear in supporting documentation, and that
  15939. the name of M.I.T. not be used in advertising or publicity pertaining
  15940. to distribution of the software without specific, written prior
  15941. permission.  M.I.T. makes no representations about the suitability of
  15942. this software for any purpose.  It is provided "as is" without express
  15943. or implied warranty.
  15944.  
  15945.  
  15946. Used for Telnet Authentication Option, Telnet Encryption Option,
  15947. and Kerberos (TM) authentication in C-Kermit, Kermit 95 (k95.exe, k2.exe,
  15948. k95crypt.dll, k2crypt.dll)
  15949.  
  15950. -----
  15951.  
  15952. Copyright (c) 1991, 1993
  15953. The Regents of the University of California.  All rights reserved.
  15954.  
  15955. Redistribution and use in source and binary forms, with or without
  15956. modification, are permitted provided that the following conditions
  15957. are met:
  15958. 1. Redistributions of source code must retain the above copyright
  15959.    notice, this list of conditions and the following disclaimer.
  15960. 2. Redistributions in binary form must reproduce the above copyright
  15961.    notice, this list of conditions and the following disclaimer in the
  15962.    documentation and/or other materials provided with the distribution.
  15963. 3. All advertising materials mentioning features or use of this software
  15964.    must display the following acknowledgement:
  15965. This product includes software developed by the University of
  15966. California, Berkeley and its contributors.
  15967. 4. Neither the name of the University nor the names of its contributors
  15968.    may be used to endorse or promote products derived from this software
  15969.    without specific prior written permission.
  15970.  
  15971. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  15972. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15973. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15974. ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  15975. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15976. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  15977. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  15978. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  15979. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  15980. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15981. SUCH DAMAGE.
  15982.  
  15983. Used for Telnet Authentication Option, Telnet Encryption Option,
  15984. and Kerberos (TM) authentication in C-Kermit, Kermit 95 (k95.exe, k2.exe,
  15985. k95crypt.dll, k2crypt.dll)
  15986.  
  15987. -----
  15988.  
  15989. Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
  15990. All rights reserved.
  15991.  
  15992. This package is an DES implementation written by Eric Young
  15993. (eay@cryptsoft.com).  The implementation was written so as to conform with
  15994. MIT's libdes.
  15995.  
  15996. This library is free for commercial and non-commercial use as long as
  15997. the following conditions are aheared to.  The following conditions
  15998. apply to all code found in this distribution.
  15999.  
  16000. Copyright remains Eric Young's, and as such any Copyright notices in
  16001. the code are not to be removed.
  16002. If this package is used in a product, Eric Young should be given attribution
  16003. as the author of that the SSL library.  This can be in the form of a textual
  16004. message at program startup or in documentation (online or textual) provided
  16005. with the package.
  16006.  
  16007. Redistribution and use in source and binary forms, with or without
  16008. modification, are permitted provided that the following conditions
  16009. are met:
  16010. 1. Redistributions of source code must retain the copyright
  16011.    notice, this list of conditions and the following disclaimer.
  16012. 2. Redistributions in binary form must reproduce the above copyright
  16013.    notice, this list of conditions and the following disclaimer in the
  16014.    documentation and/or other materials provided with the distribution.
  16015. 3. All advertising materials mentioning features or use of this software
  16016.    must display the following acknowledgement:
  16017.    This product includes software developed by Eric Young (eay@cryptsoft.com)
  16018.  
  16019. THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  16020. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16021. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16022. ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  16023. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  16024. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  16025. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  16026. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  16027. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  16028. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16029. SUCH DAMAGE.
  16030.  
  16031. The license and distribution terms for any publically available version or
  16032. derivative of this code cannot be changed.  i.e. this code cannot simply be
  16033. copied and put under another distrubution license
  16034. [including the GNU Public License.]
  16035.  
  16036. The reason behind this being stated in this direct manner is past
  16037. experience in code simply being copied and the attribution removed
  16038. from it and then being distributed as part of other packages. This
  16039. implementation was a non-trivial and unpaid effort.
  16040.  
  16041. Used DES encryption in Kermit 95 (k95crypt.dll, k2crypt.dll)
  16042.  
  16043. ----
  16044.  
  16045.  * This is version 1.1 of CryptoLib
  16046.  *
  16047.  * The authors of this software are Jack Lacy, Don Mitchell and Matt Blaze
  16048.  *              Copyright (c) 1991, 1992, 1993, 1994, 1995 by AT&T.
  16049.  * Permission to use, copy, and modify this software without fee
  16050.  * is hereby granted, provided that this entire notice is included in
  16051.  * all copies of any software which is or includes a copy or
  16052.  * modification of this software and in all copies of the supporting
  16053.  * documentation for such software.
  16054.  *
  16055.  * NOTE:
  16056.  * Some of the algorithms in cryptolib may be covered by patents.
  16057.  * It is the responsibility of the user to ensure that any required
  16058.  * licenses are obtained.
  16059.  *
  16060.  *
  16061.  * SOME PARTS OF CRYPTOLIB MAY BE RESTRICTED UNDER UNITED STATES EXPORT
  16062.  * REGULATIONS.
  16063.  *
  16064.  *
  16065.  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
  16066.  * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
  16067.  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  16068.  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  16069.  
  16070. Used for Big Number library in Kermit 95 (k95crypt.dll, k2crypt.dll).
  16071.  
  16072. ------------------------------
  16073. END OF CKERMIT2.TXT
  16074.