NAME

webrowse - browse the given input in a local web browser, with markup

SYNOPSIS

webrowse [ -N | -M ] [ -s | -mq | -u | -c ] [ -k minutes ] [ -p | -a ] [ -i id ] [ -w | -t ] [ -rnvo ] [ -h ] [ file ]

DESCRIPTION

Webrowse can be used for convenient file or URL loading remote control of Netscape, Mozilla or Mosaic browsers, for textual reference HTML markup, and, for example, for interfacing a browser to news and mail readers as a hypertextual external viewer for mail messages or news articles containing HTML or containing text with embedded URLs, mail addresses and other references. See the EXAMPLES section below.

Simply given a file argument, webrowse will direct a browser already running on the user's display to load the given file. With Netscape or Mozilla, the browser may be automatically deiconified and raised as well. The browser must be running on the same (network) filesystem. If the -m option is supplied, webrowse will interpret the file as text and create and load a temporary copy of the file containing HTML markup to hyperlink the URLs, FTP locations, mail addresses, header newsgroups, news article IDs, and filesystem pathnames in the text to their references. A temporary file is used to hold and load the standard input if no file argument is given. By default, the temporary files are deleted 10 minutes after they've been first loaded by the browser. This delay can be set or disabled with the -k option or WB_KEEP environment variable. If a -u or -c option is supplied, webrowse will interpret the command line argument, or the standard input if there isn't one, as a URL to browse or as a Netscape/Mozilla remote control command to run, respectively.

OPTIONS

-N
Use a Netscape or Mozilla browser. This is the default unless the WB_BROWSER environment variable is set to mosaic. The WB_NETSCAPE environment variable can be set to select which browser command to use.
-M
Use a Mosaic browser. This is the default only if the WB_BROWSER environment variable is set to mosaic.
-s
Tag and treat the standard input as HTML instead of text.
-m
Markup and load a text copy of the input (whether a file or the standard input) with heuristically identified hyperlinks to Web, FTP, mail, news and file references.
-q
Markup and load a text copy of the input (whether a file or the standard input) with quoted mail/news message lines in italic or bold, alternating by depth of nesting.
-u
Take the command line argument, or the standard input if there isn't one, as a URL to browse, instead of as a file.
-c
Take the command line argument, or the standard input if there isn't one, as a remote control command to run, instead of as a file. This works with Netscape or Mozilla only.
-k minutes
Keep (ie, don't delete) any temporary files for the given integer number of minutes. If the minutes is the string forever, then the temporary files aren't ever deleted by webrowse, under the assumption they will be cleaned up later by some other means. Once temporary files are deleted, the browser will not be able to reload or re-enter them. The default is the value of the WB_KEEP environment variable, or 10 minutes if it isn't set.
-p
Use a sleeping background shell process to delete any kept temporary files. This will fail to complete should the process be killed while sleeping, and is only recommended for short temporary file lifetimes. This method is the default unless the WB_SLEEP environment variable is set to at.
-a
Use an at(1) job to delete any kept temporary files. This method is the default only if the WB_SLEEP environment variable is set to at.
-i id
The window ID (with Netscape/Mozilla) or process ID (with Mosaic) of an existing browser to use for loading. The default is any value of the WB_ID environment variable (see for more details).
-w
Open a new browser window, off of an already running browser, for loading the input. By default, any running browser window may be used.
-t
Open a new browser tab, inside an already running browser window, for loading the input. This works with newer versions of Netscape/Mozilla only.
-r
Don't deiconify/raise the browser window. The default for Netscape/Mozilla is to raise the window, while Mosaic will never raise the window.
-n
Don't actually use the browser at all. This is useful if only what is printed is of interest.
-v
Prints the shell command to run for remote control of the browser. This works with Netscape/Mozilla only.
-o
Prints the input (whether a file or the standard input, or whether marked up or not), perhaps in addition to loading it into the browser. This can be used to capture the marked up version of the input for other uses.
-h
Prints a helpful usage message.

ENVIRONMENT VARIABLES

WB_BROWSER
The default browser to use, Netscape/Mozilla by default, unless set to mosaic. This may be overridden by the -N or -M options.
WB_NETSCAPE
The Netscape or Mozilla browser command name to use, netscape by default. mozilla could be a common setting.
WB_TMP
The directory in which to create any temporary files for use with either browser. The default depends on the browser in use. This may be overridden by the WB_NSTMP or WB_MSTMP environment variables.
WB_NSTMP
The directory in which to create any temporary files for use with Netscape/Mozilla, $HOME/.mozilla, $HOME/.netscape, $HOME/tmp or /tmp (the first which exists) by default. This overrides WB_TMP.
WB_MSTMP
The directory in which to create any temporary files for use with Mosaic, $HOME/tmp or /tmp (the first which exists) by default. This overrides WB_TMP.
WB_UMASK
webrowse uses a umask of 077 when creating temporary files, unless overriden with this.
WB_KEEP
The number of minutes to wait before deleting any temporary files, or the string forever if they're not ever to be deleted. 10 minutes is the default. This may be overridden by the -k option.
WB_SLEEP
The default method to use to delete kept temporary files, sleep by default, unless set to at. This may be overridden by the -p or -a options.
WB_ID
With Netscape/Mozilla, this can be set to the window ID of an existing browser window to specify the use of that window for loading, instead of just the first one found on the display. For example, under X Windows, xwininfo(1) or xlswins(1) can identify window IDs. xwinid(1) is a supplementary script to webrowse to conveniently interface these programs, so one can simply use the output of, eg, xwinid -i $WB_NETSCAPE to set this value. With Mosaic, this can be set to the process ID of a running browser to specify the use of that browser for loading, instead of the one associated with the process ID listed in the file $HOME/.mosaicpid. This variable may be overridden by the -i option.
WB_PWD
The command to run to determine the current working directory, instead of the configured default command (usually pwd(1)).

EXAMPLES

Besides its usage directly from the command line, webrowse can be useful as a tool within other scripts and, creatively, as an interface between a web browser and other applications. Most usages fall into two categories. One, based on webrowse -s, is useful for sending HTML that is found outside a web context into a browser so it may be viewed properly. The other, based on webrowse -m, is useful for sending text that contains URLs, mail addresses, filesystem pathnames, etc into a browser with these items conveniently hyperlinked.

The following vi(1) macros, for your .exrc file, may be used to view the currently editted text in a browser with markup (and perhaps in a new window), or to (re)load the currently editted file into a browser from vi. The latter can facilitate HTML development with vi using a browser for WYSIWYG-like viewing of the developing HTML source. (Control characters are shown in carat-notation.)

     map _wb :w !webrowse -m
     map _wm :w !webrowse -mw^M^M
     map _ws :w !webrowse -sw^M^M
     map _wn :!webrowse -w %^M^M
     map _wl :!webrowse %^M^M
     map _ww :!webrowse -c reload^M^M

The following vim(1) one-line macro, for your .vimrc file, may be used to (re)set the editor's WB_ID environment variable to a selected Netscape/Mozilla browsing window. It requires xwinid(1) to be installed and WB_NETSCAPE to be defined.

     noremap _wi mp:r!xwinid -i $WB_NETSCAPE<CR>0"iy$u`p
     :let $WB_ID=@i<Bar>ec $WB_ID<CR>

If you receive a mail message in HTML with mailx(1), the following configuration in your .mailrc file will allow you to view the message in your browser via mailx's pipe command.

     set cmd='webrowse -sw'

If you receive a news article containing URLs with nn(1), the following configuration in your .nn/init file will allow you to view the article with markup in your browser via nn's I command.

     map both I (
             save-full "|webrowse -mqw"
     )

Webrowse may also come in handy as part of a browser startup command. For example, the following Bourne-shell command in a shell alias, windowing system initialization file or window manager configuration file will allow you to create a new Netscape/Mozilla window by spawning one off an already running Netscape/Mozilla browser, if there is one. If not, it starts a new Netscape/Mozilla entirely. WWW_HOME is assumed to be set to your starting URL.

     case "`webrowse -uw $WWW_HOME 2>&1`" in
     *[Nn]o*running*)   exec ${WB_NETSCAPE-netscape} &;;
     esac

FILES

$HOME/{.mozilla,.netscape,tmp}/webrowse*, /tmp/webrowse*
Possible temporary files for markup and loading. The defaults with Netscape/Mozilla unless the directory is changed via WB_NSTMP or WB_TMP.
$HOME/tmp/webrowse*, /tmp/webrowse*
Possible temporary files for markup and loading. The defaults with Mosaic unless the directory is changed via WB_MSTMP or WB_TMP.
$HOME/.mosaicpid
Used to determine the process ID of a Mosaic browser. Created by Mosaic.
/tmp/Mosaic.*
Created, used and kept to communicate loading information to Mosaic.

CAVEATS

The textual pattern matching used to identify URLs, FTP locations, mail addresses, header newsgroups, news article IDs, and filesystem pathnames is completely heuristic and can easily misidentify items. In practice, it's quite accurate, but occasionally text is identified as an FTP location (eg, hostname:path) or a filesystem pathname when it really isn't. Webrowse is designed to err on the side of overidentifying such references, to make it most useful when browsing temporary markup. Also, if the input text is exceptionally large, the pattern matching can become prohibitively expensive to compute. In such cases as these, a different program may be used to perform the markup, with its output piped into webrowse.

Not all Netscape remote control features may work with Mozilla, too, since Mozilla's support for Netscape-style remote control is still under development. See the URLs in the SEE ALSO section below for current details.

VERSION

1.6.3

AUTHOR

Steve Kinzler, kinzler@cs.indiana.edu, May 96/Jan 98

URL

http://www.cs.indiana.edu/~kinzler/webrowse/
http://www.cs.duke.edu/~des/webrowse.html

SEE ALSO

netscape(1), mozilla(1), Mosaic(1), umask(1), sleep(1), at(1), xwinid(1), xwininfo(1), xlswins(1), pwd(1), kill(1), vi(1), mailx(1), nn(1), http://home.netscape.com/newsref/std/x-remote.html, http://www.mozilla.org/unix/remote.html