6 ms·
It's a nice API around pexpect [1] and therefor fills the same niche - spawning and interacting with console applications in a programmable way. [1]: https://p
by gvalkov 9y ago
It's a nice API around pexpect [1] and therefor fills the same niche - spawning and interacting with console applications in a programmable way.
[1]: https://pexpect.readthedocs.io/en/stable/ https://pexpect.readthedocs.io/en/stable/
- falsedan 9y agoI'm familiar with expect, but I don't have any modems anymore which require AT commands to be sent to it with precise timing. It seems like you are describing what it is, not what it should be used for (which is what I can't figure out, based on my knowledge of other tools).
- SwellJoe 9y agoexpect was used for a lot more than modem interactions. Certainly, there are many ways to skin this cat today, but it's not crazy to want something that removes the boilerplate of capturing output from commands and figuring out how to proceed to the next step based on what it gets. To answer your question with specifics, you could use something like this to: - Start services, and then do something (maybe alert, maybe make a change and try again) if it failed. - Make configuration changes across several files and check the results of the changes (i.e. did things continue to work after the change). - Check for updates in version control and then optionally deploy them based on the results (e.g. if there's a new tagged version). - Interact with some API periodically, and do something if results change. - Tons of things I don't do, but somebody else might. It's kind of an IFTTT (If This Then That) for the command line (which is maybe obvious, since I guess IFTTT was an implementation of expect for the web, in the long tradition of "take a UNIX utility and make a version for the web"). It isn't for any one thing; it's for whatever thing you want to programmatically do with stuff that maybe wasn't meant to be programmatically worked with (or maybe just doesn't have a Python API). All of this can be done with any reasonably competent programming language, including Python (I use Perl with some tiny custom libs or bash with boilerplate, usually). This removes a bit of code. Maybe only a little code is removed, maybe a lot. It depends on what you're doing, and how well the commands or APIs you're calling lend themselves to being called from a shell or Python or whatever. Expect was a tool to make working with tools that maybe didn't intend to be called from shell (or Tcl, or C, for that matter) programs work better when called from programs. There have always been many ways to do it. If this doesn't fit the way you think or the tools you use don't need it, there may be better ways for you to accomplish similar tasks. But, it's not a crazy idea.
- zwischenzug 9y agoThanks, and well put. Here's some things I've done (with the entire framework also - the OP is the simplified 'standalone' version): - Developed the 'ShutItFile', eg: https://zwischenzugs.wordpress.com/2017/03/18/clustered-vm-testing-how-to/ https://zwischenzugs.wordpress.com/2017/03/18/clustered-vm-t... see also: https://github.com/ianmiell/shutitfile https://github.com/ianmiell/shutitfile - Built a distro from scratch (using linux from scratch), with eerything automated: https://zwischenzugs.wordpress.com/2015/01/12/make-your-own-bespoke-docker-image/ https://zwischenzugs.wordpress.com/2015/01/12/make-your-own-... also see: https://www.youtube.com/watch?v=UGp16yvSrFE https://www.youtube.com/watch?v=UGp16yvSrFE - Put a 15-year old software stack into a container, saving enormous sums in dev costs: https://www.youtube.com/watch?v=zVUPmmUU3yY&t=16s https://www.youtube.com/watch?v=zVUPmmUU3yY&t=16s - Developed a 'training' tool: https://zwischenzugs.wordpress.com/2016/04/05/linux-scales/ https://zwischenzugs.wordpress.com/2016/04/05/linux-scales/ see also: https://asciinema.org/a/32807?t=70 https://asciinema.org/a/32807?t=70 https://zwischenzugs.wordpress.com/2016/04/24/interactive-git-tutorials-rebase-and-bisect/ https://zwischenzugs.wordpress.com/2016/04/24/interactive-gi... - Automated the testing of the migration of an etcd cluster: https://zwischenzugs.wordpress.com/2017/03/04/migrating-an-openshift-etcd-cluster/ https://zwischenzugs.wordpress.com/2017/03/04/migrating-an-o... - Win at 2048! https://zwischenzugs.wordpress.com/2015/02/01/win-at-2048-with-docker-and-shutit-redux/ https://zwischenzugs.wordpress.com/2015/02/01/win-at-2048-wi...
- falsedan 9y agoI know what expect is (see my grandparent comment). I still don't know what this framework is to be used for: > Start services, and then do something (maybe alert, maybe make a change and try again) if it failed. It's a replacement for upstart/systemd/Launch Control? > Make configuration changes across several files and check the results of the changes (i.e. did things continue to work after the change). Puppet/Chef/Ansible + Sensu/Nagios? > Check for updates in version control and then optionally deploy them based on the results (e.g. if there's a new tagged version). cron? > Interact with some API periodically, and do something if results change. Also cron?
- wybiral 9y ago