Download jnet 2.0 / Mail me, jyelon@uiuc.edu / Back to my Software Page


The JNet collection of UNIX Scripting Tools

Jnet is a collection of UNIX commands useful for writing scripts. It performs a large number of tasks that are normally inconvenient to perform in a shell-script. JNet can be installed as a single program which performs many functions, or it can be installed as multiple programs. If it is installed as a single program, the first argument determines the function it will perform. The available functions are listed below.




Usage: jnet claim-lockfile file

Creates the specified file. If the file is already present, jnet waits until the file is gone before creating it. This allows for a primitive type of locking. It is useful for insuring atomicity within shell-scripts.

Usage: jnet fetch-url -u URL [-d datafile] [-h headerfile] [-l linkfile]

jnet fetch-url is intended to help write scripts that traverse the web. jnet fetch-url downloads the specified web-page. The contents of the web-page are stored in the datafile, if the -d option is specified. The http headers are stored in the headerfile, if the -h option is specified. All the links are extracted from the document and stored in the linkfile if the -l option is specified.

Any one of the three filenames can be the dash character (-). This causes the specified results to be sent to standard output. Currently, fetch-url only understands http URLs.

Usage: jnet for low high [prefix] [suffix]

Prints out the integers in the range low-high inclusive. If the prefix and suffix are specified, it prints the prefix before each integer and the suffix after each integer. For example,

    jnet for 1 20 sparc .cs.uiuc.edu
prints out the names of the first 20 sparcs in our sparc lab: sparc1.cs.uiuc.edu, sparc2.cs.uiuc.edu, and so forth.

Usage: jnet getpass prompt Prints out the prompt, then reads in a password without echo. Prints the password on standard output.

Usage: jnet ip host

Prints out the IP address of the specified host.

Usage: jnet local-ip

Prints out the IP address of the computer you're on.

Usage: jnet net-connect host:port

Much like telnet, in that it makes a tcp/ip connection on the specified port on the specified host, then relays characters back and forth. However, it is 8-bit clean, unlike telnet, making it possible to move binary data in this fashion. Also useful for testing networking software.

Usage: jnet net-server port

Useful for testing networking software. Waits for a tcp/ip connection (e.g., telnet connection) on the specified port, then relays characters back and forth.

Usage: jnet net-repeater [--once] localport remhost remport

Starts a local repeater daemon. The demon relays all connections to the local machine on the specified local port through to the specified remote machine on the specified remote port. To all appearances, connecting to the local machine on the specified local port will be indistinguishable from connecting to the remote machine on the specified remote port.

Usage: jnet net-check-server host port timeout

Attempt to connect to the specified server. If connection is successful, it is immediately dropped, and a status code of 0 is returned. Otherwise, if connection cannot be made in the specified amount of time, a status code of 1 is returned.

Usage: jnet older-days days file

Returns true if the specified file is older than the specified number of days, based on the file's last-modification date.

Usage: jnet older-seconds seconds file

Returns true if the specified file is older than the specified number of seconds, based on the file's last-modification date.

Usage: jnet older-than file1 file2

Usage: jnet path-relative-to VARNAME path

VARNAME must be the name of an environment variable (leave out the dollar sign). Converts path into a path relative to the specified environment variable. If conversion is not possible, prints out the absolute version of path. Example:

    % echo $HOME
    /home/jyelon
    % jnet path-relative-to HOME /home/jyelon/sys/jnet.c
    $HOME/sys/jnet.c
    % jnet path-relative-to HOME /usr/bin/ls
    /usr/bin/ls

Caution: this is not the same thing as a substring test. jnet path-relative-to will relativize succesfully if the path is a subdirectory of the given base path in VARNAME, even if the value of VARNAME is not a substring of path. (This can happen, because of symbolic links and mount points).

Usage: jnet random-hex numdigits

Prints out a sequence of random hex digits. Useful for creating a magic-cookie in an X startup file. The random number generator is the regular UNIX random, so beware. We'll fix this eventually.

Usage: jnet random-decimal numdigits

Prints out a sequence of random decimal digits. The random number generator is the regular UNIX random, so beware. We'll fix this eventually.

Usage: jnet random-line filename

Prints out a randomly-selected line from the specified file. Will always choose a non-blank line. Selects from all possible lines with equal probability.

Usage: jnet random-pick val1 val2 val3 ...

Randomly selects one of the specified values and prints it out.

Usage: jnet random-sort < infile > outfile

Reads in a file, and reorders the lines in a random fashion.

Returns true if file1 is older than file2 (comparison made on the basis of last-modification dates).

Usage: jnet search-path command1 command2 command3...

jnet search-path is much like which: it searches your path for a program, and prints out the path. It fixes two attributes of which that make it inconvenient for scripting: which fails entirely if your cshrc prints anything, and it produces an unparseable readout if the command is aliased.

In addition, jnet search-path is useful for selecting the best-available program from a list, using a sequence much like one of these:

    setenv SHELL=`jnet search-path tcsh csh bash sh`
    setenv WINMGR=`jnet search-path mwm twm gwm olwm`
The result will be the full path of the first available program from the list.

Usage: jnet strip-ctrl-chars < input > output

Strips all control characters except tab and newline from the data.

Usage: jnet wait-file filename

Waits for the specified file to be modified, created, or deleted. Exits when the status of the file changes in any of these ways.


Download jnet 2.0 / Mail me: jyelon@uiuc.edu / Back to: My Software Page














































.