Re: Automating programs
From: wd10 (nospam_at_nospam.invalid)
Date: Mon, 14 Nov 2005 00:44:22 -1000
On Mon, 26 Sep 2005 20:26:29 +0000, Robert Newson wrote:
> wd10 wrote:
>> What is the best way to automate programs in Linux?
>> I use Lynx to extract text from web sites and save to a file and then I
>> want to rename the output files and do things for them. I know there must
>> be a way to avoid all the typing.
>> Is is possible to automate programs, for example:
>> * start Firefox
>> * go to my web page
>> * save my web page, or take a screenshot
> $ man wget
> wget(1) wget(1)
> wget - a utility to retrieve files from the World Wide Web
> wget [options] [URL-list]
> Wget is a utility designed for retrieving binary documents
> across the Web, through the use of HTTP (Hyper Text Trans-
> fer Protocol) and FTP (File Transfer Protocol), and saving
> them to disk. Wget is non-interactive, which means it can
> work in the background, while the user is not logged in,
> unlike most of web browsers (thus you may start the pro-
> gram and log off, letting it do its work). Analysing
> server responses, it distinguishes between correctly and
> incorrectly retrieved documents...
> Try using wget to download the web page(s) you are interested in. Further
> processing programs would depend upon what you want to do with the web page(s).
>> * save file and maybe manipulate it, shrink, output as jpg, or whatever --
>> append to HTML file and FTP it to a remote server?
>> The previous example is just a random idea... the
>> purpose is to learn how to automate my programs.
>> What should I learn to do this? Should I figure out how to do it in Perl,
>> or is there another way?
I'm actually looking for a way to automate my programs. I've used wget
and like it. I also figured out this today which works better for me than
wget because often all I want is the text and not any HTML:
lynx -crawl -traverse "http://mysite.com" >myfile.txt
But that saves in .dat files and I want them to be in .txt files so I can
use them on my Windows partition if necessary (probably not necessary, but
I want to learn how to do it anyway).
So another example of an automated task I would like to be able to do
run the following command:
lynx -crawl -traverse "$my-command-line-URL-argument" (but somehow send
this into a specific directory with the same name as the URL)
switch to this directory:
then something like this:
rename 's/*\.dat/$HTML-page-title\.txt/' *.dat
And maybe process it some more. I just don't know how to string it all
together... I'm not sure what I am looking for. I've been using Linux for
a while but not the advanced side of it yet.
There must also be a way to automatically control programs like Firefox,
take screenshots, manipulate images, etc.