From owner-freebsd-hackers Wed Apr 30 19:38:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id TAA00125 for hackers-outgoing; Wed, 30 Apr 1997 19:38:39 -0700 (PDT) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id TAA00107 for ; Wed, 30 Apr 1997 19:38:35 -0700 (PDT) Received: from aries.bb.cc.wa.us (root@[208.8.136.11]) by who.cdrom.com (8.8.5/8.6.11) with ESMTP id SAA09197 for ; Wed, 30 Apr 1997 18:14:24 -0700 (PDT) Received: from localhost (chris@localhost) by aries.bb.cc.wa.us (8.8.3/8.6.9) with SMTP id SAA01920; Wed, 30 Apr 1997 18:08:15 -0700 (PDT) Date: Wed, 30 Apr 1997 18:08:15 -0700 (PDT) From: Chris Coleman To: Kevin Eliuk cc: hackers@freebsd.org, Annelise Anderson Subject: Re: Re: "learn" unix tool In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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. #!/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 ' Find information on someone. 'ls' List files and directories. 'cd ' Change to \"directory\". 'cd ~' Change back to home directory. 'more ' 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 ' Edit Text Documents.\n" } elsif( -e "/usr/local/bin/emacs "){ print"'emacs 'Edit Text Documents.\n" } elsif( -e "/bin/vi"){ print"'vi ' Edit Text Documents.\n" } if (-e "/usr/local/bin/ytalk"){ print"'ytalk ' Talk to a person.\n" } elsif( -e "/usr/bin/talk "){ print"'talk ' 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 ' 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"; } ########################################################################### 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.