The Mangy Yak

Tuesday, July 04, 2006

From Tcl/Tk to Python



The whitespace madness with my Expect Tcl/Tk script was getting unbearable. Oh, wait, you don't know what the whitespace madness was. Basically, it is very difficult to propagate parameters containing whitespaces to a remote program that is called from SSH when you already call SSH from another script. You have to get the script to 'double quote' the arguments, and I was just not being able to do this with Expect Tcl/Tk. It kept adding curly braces {} to my quoted arguments, making them unusable.

Admittedly this was due to sheer incompetence since I'm not very acquainted with Expect nor Tcl/Tk, but I had to get things working somehow.
After scavenging poorly-organized documentation and reading articles for half a day, I decided to put an end to this - I don't have the time to become a skilled Expect Tcl/Tk programmer right now.

So I tried Pexpect, a simplified Expect for Python. Well, it worked great! In fact, Python is great.

Took me a while to get my code working, though, since my Python is kind of rusty. You can feel sorry for me by taking a look at the code I wrote. It's there for everyone to see, in my CVS.

See ya!

2 Comments:

At 7:51 PM, Blogger Daniel Cordeiro said...

Have you tryed the pxssh class?

 
At 12:52 PM, Blogger Giuliano said...

Hey dude.

I actually tried that out, but if I use pxssh then I'm back with dealing with command prompt patterns and all the bizarre ways that command prompts can be mangled by interference output. Let alone the shell hell.

If there's one thing I learned by trying to build a remote process controller over SSH is that you cannot rely on being able to detect the command prompt in order to make progress.

But thanks anyhow. :-)

 

Post a Comment

<< Home