Live data from Hacker News

Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

blog.robertelder.org

61–70 of 106 posts

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#61

Expect is cool, I have used it in the past as well as the expect perl module, but in my opinion is always a suboptimal way to automate things. It's always better and more robust to have a proper interface to script things instead of relying on matching brittle text/regex responses and timers and such. Of course sometimes it's not possible, so expect comes in handy.

Yes, expect is really cool. I haven't used it heavily, but had used it some earlier, to automate small command-line tasks to good effect.

Also:

1. I had read much of Don Libes' Expect book. He had a unique style of writing in that book. Hard to describe, partly since it was some years ago, and partly because I can't find the words for it. But I think anyone reading the book would notice the style after reading a few pages. It was not a bad style by any means, just ... something different.

2. I've read that expect was (maybe still is) used heavily in the electronics/EDA industry, though I am either not sure or don't remember how exactly they use it, or rather, for what. And also maybe it was used heavily by GNU software for testing. Maybe someone here can confirm.

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#62

Don Libes' daughter went to my high school, and I was working as the "webmaster" for the high school newspaper's website at the time. He would ruthlessly criticize via email the product our self-taught and earnest 2010-era PHP web development. I am not a fan of Don Libes. For those interested, the website was/is: http://theblackandwhite.net/

He just had high ... expectations, that's all.

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#64
I'm calling expect dynamically out of CGIT (the git repo serving CGI program). The expect script runs Vim in pseudo-terminal, to load a source file and syntax-colorize it via :TOHtml. That HTML is then integrated into the file view generated by CGIT.

This is not done for every file type; a master shell script dispatches different coloring strategies based on suffix.

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#65
post #7

Earlier quoted context omitted.

I 100% agree. If I can use paramiko/fabric or something similar, I prefer it way more than expect. If you have a slave device over RS232, expect is probably your only option. But if that remote item is running sshd, you are way better off without expect.

I've used paramiko + expect to automate distributed benchmarking + results gathering. I can say that while it ultimately worked, Curse That Thing In Particular. It was so so so fiddly to get everything working, and very fragile + output-dependent. https://github.com/ip2k/Mad-Science?files=1 I wrote this a long time ago and it's ugly. It totally worked and let our company find more optimal hosting configs.

What does the `?files=1` bit do?

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#67

This tool keeps the command line interpreter (CLI) alive. Sysadmins everywhere can glue hundred different systems from a hundred different vendors together if they have CLI and the sysadmin has access to a machine that runs expect(1). There are many stories of complex infrastructure being taken down by new firmware on routers or switches that change the order of parameters in a command :-)

Rather, this tool keeps alive systems that do not have easily scriptable command interfaces, and must be driven at the character-level through their interactive visual interfaces.

If the system has a CLI, you write a script in that CLI; you don't write an expect script.

Sometimes systems have CLI, but only behind a remote access wall (telnet, serial, ...); then you might use expect---because there is no way to upload a script and dispatch it.

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#68
post #50
post #44

Speaking of surprisingly unappreciated unix tools, I recently started reading the documentation of the gnu info package, and I must say, that is really impressive. if you didn't already, I highly recommend you type 'info info' in your terminal and spend half an hour learning how to use it. Plus, if you are an emacs user, the emacs manual is bundled with emacs in info format, and you can obviously read info documents…

`info` also contains a lot of historical notes, i.e. $ info Groff | awk '$2 == "History"{f = 4};f && f--' RS= ORS='\n\n' 1.2 History =========== 'troff' can trace its origins back to a formatting program called 'RUNOFF', written by Jerry Saltzer, which ran on the CTSS (_Compatible Time Sharing System_, a project of MIT, the Massachusetts Institute of Technology) in the mid-sixties.(1) (*note History-Footnote-1::) The…

I'm well familiar with Awk RS="" paragraph mode and all, but I'm scratching my head why f = 4 to fetch three paragraphs.

[Edit]: Indeed, I ran your command verbatim and obtained one more paragraph: When they needed are more flexible language [...].

You sneaky devil!

Re: Don Libes' Expect: A Surprisingly Underappreciated Unix Automation Tool

#70

I'm calling expect dynamically out of CGIT (the git repo serving CGI program). The expect script runs Vim in pseudo-terminal, to load a source file and syntax-colorize it via :TOHtml. That HTML is then integrated into the file view generated by CGIT. This is not done for every file type; a master shell script dispatches different coloring strategies based on suffix.

You know, cgit does come with two example syntax highlighting scripts... :)
Post reply on HN