This document describes the AppleScript support in BetterTelnet 2.0b1 and later. To use it, you must first have AppleScript, which comes with System 7.5 and later. If you have System 7.0.x or 7.1.x, please download AppleScript free from www.applescript.apple.com.

If you are a Frontier user, BetterTelnet should probably work with Frontier right now. I will be putting up a page soon with Frontier scripting directions; in the meantime, try to "translate" the AppleScript intructions below.

BetterTelnet (and NCSA Telnet) supports the required suite of functions, which should allow you to tell BetterTelnet to open a set file or quit. Not very glamorous, but the Finder needs these events too. I'm sure you know how to use these functions if you need them; just take a look at BetterTelnet's dictionary.

More useful is the "geturl" command, actually implemented since NCSA Telnet 2.7b5. The syntax with an example URL is as follows:

What's new in 2.0b1 is the BetterTelnet suite. This will be expanded in the future, but it is already usable for scripting logins and limited automation. The first command you need to know is "connect": (items in [square brackets] are optional)

A bit of explanation is in order here. The first parameter, right after "connect", is required. It specifies the Favorites entry to use for the connection's settings. Use "<Default>" for the default favorite. The second parameter indicates a host name (and optional port number) for the connection; leave it out to connect to the host name in the Favorite. The "suspended" parameter should be given the string "yes" if you want the connection to be suspended when it opens so it can receive no data until unsuspended, or left out altogether otherwise. The "waiting" parameter, if present, directs BetterTelnet to suspend the AppleScript until the connection opens.

Now come "send text" and "send cr":

The "send text" command simply sends a string to the remote host - quite useful, actually. Its companion, "send cr", sends the appropriate carriage return for the CR mode (normal CR LF or BSD-style CR NULL) in use. If you have the standard "String Commands" scripting addition installed, you can also send a control character with the "send text" command:

To ask the user which data should be sent, use the Display Dialog scripting addition:

Finally, in order to put this all together for simple login scripting, we bring you "wait for text":

Here is a sample login script:

Oh yes, that "unsuspend" command: the host is opened suspended to prevent quick-moving data from escaping the wait command, and it is automatically unsuspended while waiting, but it must be manually unsuspended at the end. As you may guess, there is also a "suspend" command. You can also use the Suspend Session item of the Session menu to manually suspend and unsuspend the network connection of a session.

One last thing if you are unfamiliar with AppleScript: you must use a tell statement to direct events to BetterTelnet. See the example above.

In future versions, there will be a command allowing AppleScripts to get data from the connection, there will be commands integrating AppleScript with One-Time Passwords (OTP and S/Key), and there will be object model support for manipulating multiple windows.

Warning about login script applications: Automatically scripting logins does not protect you from password sniffing over the network; only a robust one-time password system like OTP/OPIE or S/Key or an encryption system such as Kerberos or SSH can do that. Also, make sure you don't store your password in cleartext on a system which others could use; better to prompt for it and enter it each time.