[NTLUG:Discuss] expect

Terry trryhend at gmail.com
Tue Mar 8 15:27:02 CST 2005


I discovered expect last weekend, a very cool little application, IMHO. 

I'll tell you a short story:

I wanted an easy way to share kaddressbook over my home LAN.  I've
been using kaddressbook for some time now, on MY computer, and have a
lot of names, addresses, phone numbers, email addresses, just all
sorts of info [in kaddressbook] and been looking for an easy way of
sharing the data between at least two of my computers.  I did not want
to run multiple copies of it and have to update multiple sets of data
files, and, I'm always looking for different or particularly easier
ways of doing things.
Now this may not be the easiest way to do what I did, and I welcome
anyone that wants to tell me so, but this _is_ what I did.

First, I tried to write a script and failed (the first couple of times
anyway), and so, (being the determined individual I am), I gave up.
Simple task it seemed - secure shell to another computer, switch to
different user, run a GUI application, ... that's it, robably not a
complicated task, [for a programmer maybe] but I just wasn't up to it.
 So I did a little research on the internet and came up with something
about "expect scripts". That looked interesting - sure enough it was. 
I looked at a few "expect scripts"  and realized that there was this
little application called "expect".
       Off to freshmeat.net
I downloaded  and installed expect, read over the man file, didn't see
right off the bat what to do, but then I discovered 'autoexpect'.   
Bingo!
I ran autoexpect, logged into the other computer as different user,
(ssh -l [username]), issued command 'kaddressbook' which brought up my
beloved addressbook with all it's glorious information,  I close it
down again and there I have it, a script that does it all for me. I
put an icon on the desktop and I'm done. The wife can use it, find
numbers, add data to it, (and she never messes with MY computer!).

It's probably not the best example for, or best use for expect, maybe
I could have accomplished the task in a different way, maybe not, but,
heck, it worked and I'm happy.
It looks to be a good learning tool as well, so I plan to study my new
script, edit it, learn from it, and do other similar projects with
expect, so - just another little gold nugget. ;) ...
  
BTW, there's a nice, short, but informative article in Linux Journal
archives about expect written by Vinnie Saladino:
http://www.linuxjournal.com/article/3065 

I'm [now] pretty sure that expect is in yum and apt repositories too, so 
   yum install expect
or 
   apt-get expect 
prolly works too, that is, if you don't already have it.




More information about the Discuss mailing list