lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev Re: LYNX: how to GENERATE a url?


From: Michael Warner
Subject: lynx-dev Re: LYNX: how to GENERATE a url?
Date: Thu, 15 Jul 1999 22:26:35 -0700

On or about 14 Jul, 1999, David Combs
<address@hidden> wrote:

        [...]

> If you could add some more explanation and hand-holding,

        [...]

I'll give it a shot, but with my constant disclaimer:

"It worked for me, but I don't really know what I'm doing, so
caveat scriptor".

> On Wed, Jul 14, 1999 at 06:34:37PM -0700, Michael Warner wrote:
> > On or about 14 Jul, 1999, address@hidden
> > <address@hidden> wrote:

        [...]

> > > (Answering out of context) How about:
> > > 
> > >     lynx `date +http://www.csmonitor.com/durable/%Y/%m/%d/index.html`
> > 
> > ...and for just a little more convenience, put that line in
> > a shell script,

This one-liner shell script is a text file you will create.  Call
it what you will - I called it lxdate.sh.  The first line *will*
be:

#! /absolute_path/to/preferred_shell

ie #! /usr/bin/sh or #!/usr/local/bin/csh or whatever.  Be
forewarned that real programmers will make retching sounds
if they find out you're using a csh-like shell for a script
(cf. "C Shell Programming Considered Harmful"), but we don't
care.  We're rebels.

That first line isn't negotiable - it tells the system what
interpreter to use to execute the command(s) in the script.

The next line(s) is going to be a comment reminding us what this
script is:

# lxdate.sh calls lynx on a URL constructed from a template
# combined with the (formatted) current date, yadda yadda

Finally, the point of the exercise - uncommented lines in the
script are executed line by line as though they were entered
from the command line.  Don't word-wrap - when the shell sees
the newline, it'll be like hitting "enter" in the middle of the
command.

lynx <command-line options> `date +http://.../%Y/%m/%d/...`

"date +foo%X%Y%Zbar" returns "foo<whatever's indicated by
the %'s>bar", and the backticks say substitute that returned
string into the enclosing command.

To summarize:

#!/usr/bin/sh
# Comment
lynx -blink -nopause `date 
+http://www.csmonitor.com/durable/%Y/%m/%d/index.html`

Stick the file somewhere convenient - I use ~/bin/scripts/.

Make it executable - "chmod 700 ~/bin/scripts/lxdate.sh",
say.

> > stick an
> >
> > EXTERNAL:todayscs:${HOME}/bin/scripts/lxdate.sh %s:TRUE
> > 
> > line in your lynx.cfg, and a

Pick a unique "pseudo-protocol" (todayscs, here) for your
"pseudo-URL", because you only want EXTERN to kick off this
script on a very specific link.  You can only have one
EXTERNAL per identifier, and if you use "http", you'll get
this script every time you hit '.' on an http:// URL.
That's OK, I guess, if you only have the one EXTERNAL
defined, but it seems kind of sloppy.

The next field (${HOME}/bin/...) is the location of your script.
If the directory is in your $PATH, I guess you could just use
the file name, but why take chances?  Since we're not passing
anything to the script, you should be able to leave out the "%s".
If used, it would pass the URL as an argument to the script.
This stuff is covered in the lynx.cfg comments.

> > <a href="todayscs://foo/">CSMonitor for today</a>
> > 
> > line in a bookmark file.  

Just a dummy URL (todayscs://foo/) to tell lynx to use the
"todayscs" EXTERNAL definition, when you...

> > Hit '.' . Starts (spawns?) a new lynx (in a sub-shell?) on
> > the desired page.  When you quit the new lynx, you're back
> > where you started.

You could accomplish the same thing by just aliasing "lxcsm"
(or whatever) to the command from your shell script, and using
the alias from the command line (after shelling out of lynx, if
that's where you were), but this is a little more convenient
(after a little set-up), and jolly good practice besides, eh wot?

Better?

HTH,

-- 
Michael Warner
<address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]