Monday, January 10, 2005

As long as Telnet has been around, I was suprised to find that there is no native way to automate it.

I need a process on a Wintel box to access a TSX system remotely and kick off a process. Manually I can Telnet to the box, provide user/pass and then start the process. But when trying to automate the process I find there is no native way to respond to a password prompt from Telnet.

Enter "Expect". Written for *nix in TCL there is a port that runs on Wintel. The documentation is a bit sketchy, but I got it to work.

You can call Expect with -f and provide an input file. The input file for the whole process looks like this:

The \r is the return control, notice double back-slash for the directory name. The package comes with TCL source and its own version of telnet. The expect "32sys" lines have expect looking for the command line prompt.

Whatever you are calling on the remote side should have limited output, when working with TSX I get a minimum of 2 lines of control characters that look like garbage. Originally the remote process was reporting progress on exporting data... this made for too much information for Expect to ... well, expect.

2 comments:

ouch. been doing rsh, rexec, and telnet encapsulation with vfp for about 6 years now. Did you look at other tools? Even got stuff to work with screen scraping on these controls with vfp. TSX is cool - are you doing anything with TSX-32 ? see http://sandh.com for more info - its a great beastie to use when supporting FPD apps over the internet.

About Me

The onset presented itself as Bulbar, starting in my throat. As a result I am now trached and use a vent (although my lungs are still strong). I have also lost significant muscle in my both hands, arms and shoulders and can no longer walk. My posts here are typed with my eyes starting in 2012.