ws


Ever wanted to know which of your friends are online, or what they're doing? This page offers two scripts (a shell script or a perl script) that will let you do so with one command. The scripts are for the most part equivalent; pick one or the other.

This is what the output looks like:

06:14  up 8 days, 44 mins,  57 users,  load average: 0.23, 0.17, 0.16
cluser   pts/4      some.host.name   23:54     5:18      4        bash
mbfriend pts/24     ani.pad.dre.ss   06:09        1               pico .plan

The shell script was written by Mike Crowley. The perl script was written by me.


Shell script installation instructions:

This is (without customization) the text of the shell script:

#!/bin/sh
uptime
w | sed -n "
/^username1/p
/^username2/p
/^username3/p
/^username4/p
/^username5/p
/^username6/p
/^^H$/p
/$1/p
/^^H$/p
/$2/p
/^^H$/p
/$3/p
/^^H$/p
/$4/p
/^^H$/p
/$5/p
/^^H$/p
/$6/p
/^^H$/p
/$7/p
/^^H$/p
/$8/p
/^^H$/p
/$9/p
"

Here's how you install the script. First you want to make a new 'bin' directory in your home directory ('bin' is the traditional location for executables in a Unix system). Don't type the '%'; it's meant to represent the shell prompt.

% cd
% mkdir bin
% cd bin

Now you're in your bin directory. To get the script there, you can either save this file to your local computer and upload it again, or you can execute this little command:

% cp ~lbmelton/world/fun/geek/ws ./

That copies the script from my webspace to your bin directory. Now you want to edit it and substitute the usernames of your friends where I've put 'username1' etc. (The script can also take up to 9 command-line arguments.)

% pico ws

Now make it executable:

% chmod +x ws

And there you go! You can now execute the script just by typing ws at the prompt.

Credit for the script goes to Mike Crowley.


Perl script installation instructions:

Somewhat the same as for the shell script. The script is located here. For more detailed explanation of what the following commands mean, look just above; I'm not going to go through it all again two inches later.

% cd
% mkdir bin
% cd bin
% cp ~lbmelton/world/fun/geek/ws.pl ./

By default, the script will display all the login sessions of the users you want to snoop on. If you want to see only the one with the shortest idle time (beware, this function might not work properly - I'd appreciate bug reports), edit the file

% pico ws.pl

and change "$filter = 0;" to "$filter = 1;". Now make it executable:

% chmod +x ws.pl

The last step is a config file with the usernames you want to snoop on, one per line.

% vi ~/.wsrc

Run the script by typing ws.pl at the prompt.


This page created and maintained by Laurabelle (send WebMail).
Best viewed with Internet Explorer or Netscape 6.

[Valid HTML 4.01!] [Valid CSS!]

----------------------------------------

Last modified on August 21, 2002.