SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group
USA

November 2002


Lynx on OS/2: Straight Answers and Keen Tricks

Part 2 - Using Lynx More Effectively

by Dallas E. Legan

Once you've gotten Lynx up and running on OS/2 (see Part 1), you may encounter a few operational quirks you'd like to deal with differently. That's what this installment is all about.


How can I move up or down on the page in Lynx in less than a full screen?

  • Ctrl+P or Ctrl+N will move up or down two lines at a time. This is borrowed from the EMACS editor, and very common in UNIX derived tools.
  • Space, +, or Ctrl+F will move a screen forward.
  • - or Ctrl+B will move back a screen.
  • Ctrl+A goes to the top of the page.
  • Ctrl+E goes to the end of the page.
  • Or you can use the page up/down, home/end keys to move around.

You may start using the vi or emacs editor emulation modes, which will give a lot of ways of navigating a page. If you don't like either of these, you might want to go into your lynx.cfg file and modify the keymaps to fit some editor, shell or other program you feel comfortable with. The commands and the binding are fairly simple to understand.


I've recieved as much of the page as I want, how can I stop downloading the rest of it?

Type:

   z


How can I download a file off the Internet with Lynx?

Type:

   lynx -source
then, for example (on the same line):
   FTP://hobbes.nmsu.edu/directory/remotefile.zip > localfile.zip
where remotefile.zip is a file you want at Hobbes, and localfile.zip is what you are calling it once it's downloaded.


I'm having problems accessing FTP with Lynx.

If you are behind a firewall, you may need to edit your lynx.cfg file to set FTP to use "passive mode." Passive mode means that the FTP server is passive about opening up the data channel to you (also discussed in my article Poor Man's WGet). Your FTP program, Lynx in this case, is actively opening up the data channel that passes through your firewall from the inside. When a session is using "active mode," the server will try to open up the data channel - and this is indistinguishable by most firewalls from an attempt by a hacker or malbot to break into your local network. Hence, the need to use passive mode.

With an editor, search for the word 'passive' in the Lynx.cfg file. Keep in mind that all of the lines starting with '#' are comments, usually indicating the default behavior. Just copy the line and modify it to indicate 'PASSIVE' mode. Like so:

  .h2 FTP_PASSIVE
  # Set FTP_PASSIVE to TRUE if you want to use passive mode ftp transfers.
  # You might have to do this if you're behind a restrictive firewall.
  # FTP_PASSIVE:FALSE
  FTP_PASSIVE:TRUE


How can I send email from the command line with Lynx?

   lynx mailto:dallas@scoug.com

If your configuration of Lynx does not specify a preferred editor, you can then type in your message, ending it with a period in column 1 to end the message. Otherwise, you can use your editor to compose the message. Lynx doesn't have built-in capability to read mail, but it works fine with web-based mail systems, especially if you have a broadband connection. If you are running a local web server, you might also experiment with forwarding your mail to a local wiki (a web site that allows you to edit and add to it from your browser) with an email gateway, to read, or use some webmail CGI software locally.


How can I get rid of all the image links?
* will toggle the treatment of image links.
[ will toggle the treatment of image links with no ALT specified.


Is Lynx really the fastest browser?

  
   lynx -traversal -crawl http://www.scoug.com

Lynx seems to be faster than even other text browsers, at least in part because it doesn't make multiple rendering passes on the html, trying to figure out if there are frames to handle.


I've got all the settings in lynx.cfg set, but the mouse doesn't seem to be working.

This might be a terminal type problem. I found most of the 'ansi...' terminal types seem to work fine with the mouse, even in full screen mode.

Note: You'll find a bit of discussion about this in Part 1, specifically in regard to the question "What things might I have to adjust to get Lynx to work on OS/2?"


The dang html form doesn't seem to have a submit button. What can I do?

One possible approach is to open another window and run something like:

  lynx -base -source http://www.domain.com/#$Ctrl+$!@##@#$/javascriptform.html
                           >  localform.html
Then:
  • Close that session and go back to your original session.
  • Type 'g', and when prompted, enter the as much of the path and name of 'localform.html' as you need to.
  • Enter return and that file comes up (and looks the same as what you were just looking at).
  • But now if you hit 'e', your preferred editor will be brought up and you will have a view of the html source in raw, unrendered form.
  • Locate a line that contains '<FORM...>' and following this enter a line

    <INPUT TYPE=SUBMIT>

  • Leave your editor.
  • Fill out your form and submit as desired.
  • Save this html file if you think you will need it in the future.

Some people will claim you evilly "stole" the html source, but I prefer to think that you are caching the page locally. Rather than using a fancy caching proxy server like Squid, you are doing it by hand, and then correcting their mistake of depending on you to run their Javascript (not to be confused with Java) to validate the input data. They should never depend on the web client to validate input data. You merely submitted their form with your input (but someone else might have tried sneaking commands onto their computer). (For reference, see Programming PHP with Security in Mind in the October 2002 issue of the Linux Journal.)


Moving through the forms is a pain. Is there an easier way?

Either use the '-tna' switch at the command line, or inside lynx.cfg, turn on the 'Text fields need activation' feature. Lynx will now treat form fields like other links, and will need you to enter return for them to accept data. This extra step to enter data into them is more than made up for with the easier movement through the page.

While you're at it, go to options (or edit lynx.cfg) to set up the advanced mode that numbers links and form fields. Then you'll be able to move very quickly simply by entering the numbers that preceed each link in brackets.

  • The number alone will activate a link
  • Number followed by 'g' witll just go to the link or field
  • The number followed by 'p' will go to the screen 'page' of the web page. (Don't let the changing meanings of 'page' confuse you.)


I'd like to use my favorite editor to compose what's in the form text field.

If you've defined an editor in options or elsewhere, then Ctrl+X e (Control-X followed by e) will kick in your preferred editor if the text field is 'active' (ready for input, see the previous answer). There are some other text field commands using Ctrl+X, but I think this is the most important one.


What do I do with this stupid blank screen?

A blank screen means there's something there that Lynx won't recognize. Most likely, the web page depends on you running Javascript to generate an address for your browser to go to.

Kick into souce view of the page by entering '\', and look for things that look like path/filenames. Now type 'G' to go to an URL, which will show the current address as a default, and use Delete, Cntl-H, Backspace or whatever to delete as appropriate. Then try splicing the path/filename you found onto the domain name and see where it takes you! This frequently works with 'Javascript:(...)' URLS as well - why they can't just put a simple link on these things I can only speculate. (In addition, 'g', lowercase, will bring up a blank field for URL entry, and 'E' will allow you to edit the current link for where to go.)


What is the zip file in the bin directory when I unzip Lynx?

It contains configuration files for a tool called SR/2, probably "Screen Reader/2." I don't know much about it; the documents from a cursory web search seemed to be in German, but it appears to be a text-to-voice screen reading tool for the visually impaired. I'm not too knowledgable about this subject, but I understand some blind people use these tools with text browsers to do their web surfing (as discussed in Building a Barrier-Free Web by Susan Kuchinskas in the Dec. 2002 issue of New Architect). It might even be useful for people who can see, but whose sight isn't what it used to be, or for those who like to use voice commands rather than typing. Explore and let the rest of us know what you find out. Or let me know, and I'll see if I can dig deeper on the subject.


I like the tabbed pages or multiple windows on other browsers. Does Lynx have anything equivalent?

By default, Lynx caches the last 10 pages, rendered in memory. Use the 'V' command to bring up the history list, and pick the page you'd like to quickly revisit.


What are some funky things I can do with Lynx?

You can ping:

lynx -source http://www.csu.net/cgi-bin/ping?www.scoug.com
or
lynx -dump http://network-tools.com/default.asp?prog=ping&host=www.scoug.com

And you can nslookup:

lynx -source http://www.csu.net/cgi-bin/nslookup?www.scoug.com
or
lynx -dump http://www.netdoor.com/cgi-bin/public/nph-nslookup?www.scoug.com

There are other servers you can do these tests with, but CSU.net is the one I have used the most. Unfortunately, it has been problematic of late, so you may not be able to access it. These are particularly useful if you are behind a firewall and don't want to allow ICMP (Internet Control Message Protocol) or UDP (User Datagram Protocol) packages through. Instead you can use a ping or nslookup server via WWW, which probably is allowed through your firewall.

Need a pager? Lynx wasn't intended to be used as pager like the W3M text mode browser, but you can use

<pipeline process> | url2link -r | txt2html -s | lynx -stdin

in a pinch as an advanced replacement for 'MORE' or other paging programs.

Some specific examples are:

type lynx.cfg | url2link -r | txt2html -s | lynx -stdin
type config.sys | sort | url2link -r | txt2html -s | lynx -stdin
This is somewhat slow, and ungainly to type in at the command line prompt as presented, but the basic idea might be usefull in some contexts.


Is there a way to script Lynx?

In OS/2, as far as I know, there is no equivalent to the pseudo-terminals of UNIX systems for use by tools like C-Kermit, Expect, etc. But this doesn't leave you completely helpless. You might try experimenting with the -cmd_log/-cmd_script switches which provide some limited scripting capability. If you have anything like an "inetd" (general internet service demon) running on one of your OS/2 machines, you can install Lynx as one of the "servers," on a dedicated TCP port, and telnet into it with Kermit/2 or ZOC (as was described in Part 1). You might try running a local telnet daemon, where you could connect with a programmable telnet client.

If the target is to navigate through a web page form, and the form uses the "GET" method (check the '<FORM...' statement in the html source), frequently you can bookmark the document once after logging in, and the bookmark will show the URL with all the GET Method data that you really need to fly past the form. You can just click on the link, and get the effect of filling out the form. (See the previous question.) I've occasionally encountered forms that started out GET and later found out that they had officially changed to POST method without my knowing, but they still seemed to accept data with the GET method.

Also, there are tricks to be done with crawl mode (the "-crawl" command line switch) combined with the -get and -post switches. With careful presetting of the files logging the session history, the "cat" can be herded! There are probably other techniques I haven't thought to list here, but the main thing is not give up! Try some originality. Study the program's capabilities.

For instance, you can look at a Regina Rexx script I've run on Linux in the past to 'herd the cat'. While it's really specific to the setup I had at one time, it ought to give you ideas for using Lynx to dump a web site.


To be continued... Part 3 brings graphics into the picture, showing how you can use a REXX script with an image viewer to look at pictures with Lynx.

If you missed it, Part 1 of this series gets you started using the Lynx browser.


The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 2002 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.