Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Apr 1997 18:08:15 -0700 (PDT)
From:      Chris Coleman <chris@bb.cc.wa.us>
To:        Kevin Eliuk <kevin_eliuk@sunshine.net>
Cc:        hackers@freebsd.org, Annelise Anderson <andrsn@andrsn.stanford.edu>
Subject:   Re: Re: "learn" unix tool
Message-ID:  <Pine.NEB.3.94.970430180430.1875B-100000@aries.bb.cc.wa.us>
In-Reply-To: <Pine.BSF.3.95q.970430104726.168A-100000@kevin.sunshine.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Ok, i have written a little 'help' script in perl.  It probably needs
work, but I just hacked it out overnight.  I am posting it here for public
approval prior to asking for it to be committed.  I designed it to be one
screenful of information that every new user needs to know. (IMHO)

Anyway, take a look at it and tell me what you think.

<CUT>

#!/usr/bin/perl
########################## Variables #################################
sub get_variables{
#($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwent;
$name = getlogin || (getpwuid($<))[0];
($hostname)=split(//,getnetent,1);
chop($hosttype = `uname`);
chop($version = `uname -r`);
$email="$name\@$hostname";
$name =~ /(^[a-z])(.*)/;
$firstletter=$1;
$firstletter =~ tr/[a-z]/[A-Z]/;
$name= "$firstletter$2";
$shell = $ENV{'SHELL'};
$term = $ENV{'TERM'}||"dialup";
$home = $ENV{'HOME'}||"You are Homeless";
$pwd = $ENV{'PWD'}||"Lost on the System";
$remotehost = $ENV{'REMOTEHOST'}||"Somewhere";
}
########################## Main Functions #################################
do get_variables();
do play_greeting();
do pwd_check();
do shell_check();
do commands();
do found_commands();
do show_help();

########################## Greeting Subs #################################
sub play_greeting{
system(clear);
print "	$name, Welcome to $hosttype $version on $hostname!\n\n";
print "Your email address is:	 \"$email\".\n";
print "Command Shell:		 \"$shell\"\n";
}
########################## Commands Subs #################################
sub commands{
print"\nSome Useful Commands:
'w'		  Displays what people are doing.
'who'		  Shows Who is on-line.
'finger <login>'  Find information on someone.
'ls'		  List files and directories.
'cd <directory>'  Change to \"directory\".
'cd ~'		  Change back to home directory.
'more <filename>' Display the contents of \"filename\".
'passwd'	  Change your password. \n";
}
########################## Command Finding Subs ################################
sub found_commands{
#Check for easiest e-mail program,
if (-e "/usr/local/bin/pine"){
print"'pine'		  Access your e-mail.\n" 
} elsif( -e "/usr/local/bin/elm"){ 
print"'elm'		  Edit Text Documents.\n"
} elsif( -e "/usr/local/bin/mutt"){ 
print"'mutt'		  Edit Text Documents.\n"
} elsif( -e "/usr/local/bin/mh"){ 
print"'mh'		  Edit Text Documents.\n"
} elsif( -e "/bin/mail"){ 
print"'You Only have 'mail' installed, get your system manager to install 'pine'.\n"
}
#Check for easiest text editor 
if (-e "/usr/local/bin/pico"){
print"'pico <filename>' Edit Text Documents.\n"
} elsif( -e "/usr/local/bin/emacs <filename>"){ 
print"'emacs <filename>'Edit Text Documents.\n"
} elsif( -e "/bin/vi"){ 
print"'vi <filename>'   Edit Text Documents.\n"
}
if (-e "/usr/local/bin/ytalk"){
print"'ytalk <login>'   Talk to a person.\n"
} elsif( -e "/usr/bin/talk <filename>"){ 
print"'talk <login>'    Talk to a person.\n"
}
}
########################## shell checking Subs #################################
sub shell_check{
#check and give shell information
if($term eq "dialup"){
print "Your terminal type is set to \"dialup\", you might need to change it by typing 'set term = vt100'\n";
}
print"Terminal Type: 		 \"$term\""; 
print" You are at a Server Terminal.\n" if $term eq "cons25";
print" Remote Connection from: $remotehost.\n" if $term eq "vt100";
print" You are dialed in.\n" if $term eq "dialup";
}
########################## shell checking Subs #################################
sub pwd_check{
#check and give Present working Directory information
print"Current Directory:	 \"$pwd\"\n";
if ($pwd eq $home){ 
print "			 You are in your home directory.\n";
} else {
print "Home Directory:		 \"$home\".\n";
}
}
########################## shell checking Subs #################################
sub show_help{
print"Ways to Get Help:
'man <command>'	  Give more info on \"Command\".";
print"
'learn'		  Learn about Unix\n" if -e "/usr/bin/learn";
print"
'info'		  Info about Unix\n" if -e "/usr/bin/info";

}
###########################################################################


</CUT>

Christopher J. Coleman (chris@aries.bb.cc.wa.us)
Computer Support Technician I  (509)-766-8873
Big Bend Community College  Internet Instructor
FreeBSD Book Project:  http://vinyl.quickweb.com/~chrisc/book.html
Disclaimer: Even Though it has My Name on it, Doesn't mean I said it.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.94.970430180430.1875B-100000>