I have never gotten expect to work as advertised. For this sort of thing I would use one of these two tools, depending on the larger environment around languages and libraries.
Python Mechanize + Beautiful Soup http://swizec.com/blog/scraping-with-mechanize-and-beautifulsoup/swizec/5039 Selenium WebDriver http://docs.seleniumhq.org/docs/03_webdriver.jsp Cheers, Richard On Thursday, April 30, 2015 03:38:49 Dan Egli wrote: > Anyone able to recommend a good book for Expect? Or perhaps a better method > of accomplishing the sequence below (and books on learning that method)? > > > > What I'm trying to automate is a specific sequence of events like this: > > An event is triggered on box1. Box1 in turn runs a script (exepct or other) > that will call a specific web page, update information on that page, exit > and open a text file in an editor (nano used in the example below, but any > editor will be okay), change values in that file, save and exit, rebuild an > index for that file used by a separate program, and then log out. > > > > The session would resemble something like this (assuming the script call is > event.expect <param1> <param2>): > > elinks www.mydomain.tld > > click on link 1 > > click on link 4 > > enter username and password to login to the site correctly > > click on link 2 > > change field 2 value to <param1> > > change field 4 value to <param2> > > click submit > > click link3 > > exit elinks > > nano /var/special/basefile.txt > > change field 2 on line 3 to <param1> > > change field 2 on line 4 to <param1> > > change field 2 on line 6 to <param1> > > change field 2 on line 7 to <param2> > > change field 3 on line 9 to <param2> > > [save and exit] > > newindex basefile.txt basefile.index > > logout > > > > I'm not particularly attached to elinks or nano, but that was the easiest > way (combined with expect/autoexpect) I could think of to automate this > sequence. If there's a better/easier way using another program, I'm all > ears. Just don't say I should use wget or curl because they don't handle > POSTs very well and this will be a POST site that is being connected to. > And, last I looked, curl and wget could only handle generic http auth (i.e. > .htpasswd logins), not any kind of custom login sequence. That won't be the > case here. > > > > Either way, recommendations on the method and a book to learn this method > are most welcome. > > > > Thanks all! > --- Dan > > /* > PLUG: http://plug.org, #utah on irc.freenode.net > Unsubscribe: http://plug.org/mailman/options/plug > Don't fear the penguin. > */ /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
