"Fossies" - the Fresh Open Source Software Archive

Member "passwd_exp-1.2.11/mod/_shell.reader" (21 Nov 2005, 1751 Bytes) of package /linux/privat/old/passwd_exp-1.2.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /usr/bin/perl
    2 # PROGRAM   : _shell.reader (passwd_exp 1.x helper)
    3 # PURPOSE   : shell file reader
    4 # AUTHOR    : Samuel Behan <samkob@gmail.com> (c) 2000-2006
    5 # HOMEPAGE  : http://devel.dob.sk/passwd_exp
    6 # LICENSE   : GNU GPL v2, NO WARRANTY VOID (see file LICENSE)
    7 ################################################################################
    8 #requirements
    9 #pragmas
   10 #use strict;
   11 use integer;
   12 use vars qw($VERSION $AUTHOR $AUTHOR_EMAIL $SCRIPT);
   13 
   14 #script info
   15 $AUTHOR     = 'Samuel Behan';
   16 $AUTHOR_EMAIL   = 'samkob@gmail.com';
   17 $VERSION    = '0.2.0';
   18 $SCRIPT     = '_shell.reader';
   19 
   20 #print info
   21 sub cmd_print_info(;$)
   22 {   
   23     print STDERR <<__EOT__
   24 usage: $SCRIPT [command] [options] <filename> <key0> <key1> ... <keyN>
   25       -- $SCRIPT (passwd_exp helper) $VERSION by $AUTHOR
   26 [params]
   27     filename        file to read
   28 [command]
   29     -info           print module info
   30 [RESULT FORMAT]
   31   Script prints shells defined in shell file, one per line.
   32 __EOT__
   33 ;
   34     exit(defined($_[0]));
   35 }
   36 
   37 ################
   38 # MAIN PROGRAM #
   39 ################
   40 my ($file, $line, @SHELLS);
   41 
   42 #parse command line
   43 foreach $cmd (@ARGV)
   44 {
   45     cmd_print_info() if($cmd eq '-info' || $cmd eq '--info' || $cmd eq '-h' ||
   46                 $cmd eq '-help' || $cmd eq '--help' || $file ne '');
   47     $file = $cmd;
   48 }
   49 
   50 #check if file is defined
   51 die("$SCRIPT: missing filename to read, try '-info' param\n")
   52     if(!defined($file) || $file eq '');
   53 
   54 #open file
   55 die("$SCRIPT: failed to open '$file'\n")
   56     if(!open(SHELL, $file));
   57 
   58 #read file
   59 while(defined(($line = <SHELL>)))
   60 {
   61     chomp($line);
   62 
   63     #check for comment and empty lines
   64     next if($line =~ /^#/o || $line eq '' || $line =~ /^\s+$/o);
   65 
   66     #add shell
   67     push(@SHELLS, $line);
   68 }
   69 close(SHELL);
   70 
   71 #print resuls
   72 foreach $cmd (@SHELLS)
   73 {
   74     print $cmd."\n";
   75 }
   76 
   77 #EOF (c) by UN*X 1970-$EOD (End of Days) [ EOD (c) by God ]