Servers Enterprise Unix Roundup: Is Amiga Ready for the Enterprise? Page 2

Enterprise Unix Roundup: Is Amiga Ready for the Enterprise? Page 2

Page 1     Page 2
Main     Security Roundup
In Other News     Tips of the Trade

Security Roundup

Tips of the Trade

If you’ve ever needed to automate an application that requires some sort of user input (like telnet or ftp), you know exactly how difficult it is to do so. Shell scripts don’t quite cut it, which is where Expect comes in handy.

Expect is based on the Tcl programming language, which is perhaps less well-known now than it was a few years ago, when many introductory guides to assorted “freenixes” included a bit of information about Tcl, and its X Window counterpart Tk, as a way to get users started creating Unix GUIs. Regardless of Tcl’s current popularity, Expect can still handle many of the tasks that need user input that you don’t care to provide on your own. This includes fairly mundane things like generating a password and assigning it to a given user, or changing a password across multiple hosts on which you might have accounts. Its most common use is probably automating password entry (which makes it a bit of a menace unless users are well familiar with Unix permissions and know how to keep prying eyes from simply reading all of their Expect scripts).

Although it does help to know Tcl, Expect has a pretty simple-to-understand syntax. Here, for example, is a script that automates logging in to a bulletin board system:

#!/usr/bin/expect -f
spawn telnet
expect "User: "
send "joeblowr"
expect "Password:"
send "mypasswordr"
expect "Are you on an ANSI color terminal? (Y/N) ->"
send "y"

Line 2 uses “spawn” to launch the telnet program, the “expect” commands on lines three, five, and seven all tell Expect to await specific prompts. Lines four and six send output (followed by r, which is the same as tapping the return key). The last line, “interact,” simply tells Expect to hand over control to the program session until it’s exited.

Autoexpect, which is part of the Expect package, acts as something of a macro recorder: It watches an interactive session and composes a working Expect script from what it observes. So even if the idea of learning yet another language makes you twitch, you might be able to get away without learning too much to take advantage of this powerful tool.

>> To Main
>> To Other News

Latest Posts

How to Convert a Physical Computer to a Virtual Machine

Many organizations are implementing virtualization technology into their networks to convert physical computers to virtual machines (VM). This helps reduce overall physical hardware costs,...

HPE ProLiant DL380 Gen10: Rack Server Overview and Insight

The HPE ProLiant DL380 series has consistently been a market leader in the server space. The Gen10 released in 2017 further increased HPE's market...

Best Server Management Software & Tools 2021

Finding the best server management software tools for your organization can have a major impact on the success of your business operations. Manually handling...

IBM AS/400: Lasting the Test of Time

Some server operating systems (OS) were built to survive the test of time – the IBM AS/400 is one such system.  The AS/400 (Application System/400)...

What is Disaster Recovery?

The modern organization's heavy dependence on using data to drive their business has made having a Disaster Recovery (DR) plan in place a necessity....

Related Stories