Live data from Hacker News

Expect – Linux tool for automating interactive programs

linux.die.net

21–30 of 92 posts

Re: Expect – Linux tool for automating interactive programs

#21

I just used python pexpect [0] for a fun project. I believe pexpect was inspired by the original Unix expect command. I used it to let aider suggest and run shell commands [1]. This is handy, so aider can offer to run the code it just wrote for you, run migrations, install dependencies, etc. Using pexepect makes it easy for aider to run interactive shell commands and capture their output. This allows aider to fix bug…

wait so if i understand you correctly, 1. aider makes some change 2. aider then tells itself to use pexpect to check what changes it made 3. pexpect runs, opens browser somehow captures error messages if any and feeds that back? i am pretty sure i misunderstood something

There’s a little demo video in the Twitter link that might be worth checking out.

But ya, aider can: code something for you, run it, capture the terminal output with pexpect and iterate further based on that.

Re: Expect – Linux tool for automating interactive programs

#23

As a default, I'd keep everything in one language: https://pypi.org/project/pyexpect/

I don’t think you understand nor used the program expect before Pyexpect is in another class of software. It is a Python testing utility that provides expressive assertions for unit testing. On the other hand, the Unix expect program, and its Python equivalent pexpect, are used for automating interactive applications.

I suppose he/she meant pexpect https://pypi.org/project/pexpect/

Re: Expect – Linux tool for automating interactive programs

#25
post #13

Linux tool? Hate when everything Unix automatically gets categorized as Linux. Have used Expect for many years for many use cases from automating servers to networking use cases as well.

I’ve used Expect on Windows systems. Active State provided commercial distributions of TCL for Windows.

Re: Expect – Linux tool for automating interactive programs

#26

Many years ago I used the Perl version of Expect ( https://metacpan.org/pod/Expect ) to automate several workflows that wanted manual inputs. I thought that it was far better than the TCL Expect because I could also use other CPAN modules and have Perl's regular expressions to parse the system's output. Expect is a great tool to have in your toolkit.

Arguably, Tcl can do GUIs much easily and can integrate C less awkwardly than Perl. Both have their use cases, at any rate, and more people should use Tcl, Perl and any version of Expect. Nowadays it falls into the category of tools that were once somewhat used, but now are obscure, like fold/fmt, nl, comm and pr.

>> Arguably, Tcl can do GUIs much easily and can integrate C less awkwardly than Perl.

We used Perl/Tk for GUIs on that old system. It brimgs the ease of Tk GUIs to Perl:

https://metacpan.org/dist/Tk/view/pod/UserGuide.pod

>> Nowadays it falls into the category of tools that were once somewhat used, but now are obscure

To be sure, but a lot of it still works without changes!

Re: Expect – Linux tool for automating interactive programs

#27
post #13

Linux tool? Hate when everything Unix automatically gets categorized as Linux. Have used Expect for many years for many use cases from automating servers to networking use cases as well.

I used Tcl and Expect on Solaris at a job in 1995
Post reply on HN