Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.26 KB | None | 0 0
  1. #! /bin/csh
  2. unset Names
  3. unset pass
  4. unset comp
  5. @ comp = 0
  6. if($#argv > 2) then
  7. exit 1
  8. endif
  9.  
  10. if($#argv == 0) then
  11.                          set pass = ("`cut -d '"':'"' -f1,4,5 /etc/passwd.2001 | cut -d '"','"' -f1 | tr '"':'"' '"' '"'`")
  12.  
  13.                          set pass1 = ( "`cut -d '"':'"' -f1,4 /etc/passwd.2001 | tr '"':'"' '"' '"'  | cut -d '"' '"' -f1`" )
  14.  
  15.                         @ passnum = `cut -d ":" -f1 /etc/passwd.2001 | wc -w`
  16.                         @ p = 1
  17.                          set Names = ("`last | cut -d '"' '"' -f1`")
  18.                          @ Namesnum = `last | cut -d " " -f1 | wc -w`
  19.             @ nam = $Namesnum
  20.                          @ pass1num = `echo $pass1 | wc -w`
  21.                          while ($p <= $pass1num)
  22.                 set comp
  23.     #            echo $pass1[$p]
  24.             set comp = ( "`last | cut -d '"' '"' -f1 | grep -w $pass1[$p] | cut -d '"' '"' -f1`" )
  25.                 set comp = `echo $comp | cut -d " " -f1`
  26.         #        echo $comp
  27.                 set pr
  28.                 if("$comp" != "$pass1[$p]" ) then
  29.                 set pr = `echo $pass[$p]`
  30.                 endif
  31.                 if($#pr > 1) then
  32.                                 echo "Output: '$pr'"
  33.                 endif
  34.                          @ p++
  35.                          end
  36.                          exit 0
  37. else
  38.  
  39. while($#argv > 0)
  40.     switch("$argv[1]")
  41.         case -g:
  42.              if ($#argv != 1) then
  43.              set pass = ("`cut -d '"':'"' -f1,4,5 /etc/passwd.2001 | cut -d '"','"' -f1 | grep -w $argv[2] | tr '"':'"' '"' '"'`")
  44.  
  45.              set pass1 =("`cut -d '"':'"' -f1,4 /etc/passwd.2001 | grep -w $argv[2] | cut -d '"':'"' -f1`")
  46.             else
  47.             exit 1
  48.             endif
  49.             @ passnum = `cut -d ":" -f1,4,5 /etc/passwd.2001 | cut -d "," -f1 | grep -w $argv[2] | tr ":" " " | wc -w` / 4
  50.             @ p = $passnum
  51.              set Names = ("`last | cut -d '"' '"' -f1`")
  52.              @ Namesnum = `last | cut -d " " -f1 | wc -w`
  53.              @ pass1num = $passnum
  54.              while ($pass1num>0)
  55.                 while  ($Namesnum>0)
  56.                     if ("$pass1[$pass1num]" == "$Names[$Namesnum]") then
  57.                         @ comp = 1
  58.                     endif
  59.                 @ Namesnum--
  60.                 end
  61.  
  62.  
  63.               if ($comp == 0) then
  64. #                while($p>0)
  65.                 set pr
  66.                    set pr = `echo $pass[$pass1num]`
  67.                 if($#pr > 1 ) then
  68.                 echo "Output: '$pr'"
  69.                 set pr
  70.                 endif
  71. #                @ p--
  72. #                end
  73.                 endif
  74.              @ p = $passnum
  75.              @ pass1num--
  76.              @ Namesnum = `last | cut -d " " -f1 | wc -w`
  77.              @ comp = 0
  78.              end
  79.              exit 0
  80.              breaksw
  81.  
  82.         case -h:
  83.              echo "pripravne1.csh (C) Filip T"
  84.              echo "Usage: pripravne1.csh -h -g number"
  85.              echo "-h: help"
  86.               echo "-g number: vypise ludi ktory boli za posledne obdobie prihlaseny,"
  87.              echo "v tvare :  '<login_name> <group> <full_name>'"
  88.              exit 0
  89.         case -*:
  90.  
  91.             exit 1
  92.         default:
  93.  
  94.             echo "spustene"
  95.             exit 1
  96.     endsw
  97.  
  98. end
  99. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement