Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/csh
- unset Names
- unset pass
- unset comp
- @ comp = 0
- if($#argv > 2) then
- exit 1
- endif
- if($#argv == 0) then
- set pass = ("`cut -d '"':'"' -f1,4,5 /etc/passwd.2001 | cut -d '"','"' -f1 | tr '"':'"' '"' '"'`")
- set pass1 = ( "`cut -d '"':'"' -f1,4 /etc/passwd.2001 | tr '"':'"' '"' '"' | cut -d '"' '"' -f1`" )
- @ passnum = `cut -d ":" -f1 /etc/passwd.2001 | wc -w`
- @ p = 1
- set Names = ("`last | cut -d '"' '"' -f1`")
- @ Namesnum = `last | cut -d " " -f1 | wc -w`
- @ nam = $Namesnum
- @ pass1num = `echo $pass1 | wc -w`
- while ($p <= $pass1num)
- set comp
- # echo $pass1[$p]
- set comp = ( "`last | cut -d '"' '"' -f1 | grep -w $pass1[$p] | cut -d '"' '"' -f1`" )
- set comp = `echo $comp | cut -d " " -f1`
- # echo $comp
- set pr
- if("$comp" != "$pass1[$p]" ) then
- set pr = `echo $pass[$p]`
- endif
- if($#pr > 1) then
- echo "Output: '$pr'"
- endif
- @ p++
- end
- exit 0
- else
- while($#argv > 0)
- switch("$argv[1]")
- case -g:
- if ($#argv != 1) then
- set pass = ("`cut -d '"':'"' -f1,4,5 /etc/passwd.2001 | cut -d '"','"' -f1 | grep -w $argv[2] | tr '"':'"' '"' '"'`")
- set pass1 =("`cut -d '"':'"' -f1,4 /etc/passwd.2001 | grep -w $argv[2] | cut -d '"':'"' -f1`")
- else
- exit 1
- endif
- @ passnum = `cut -d ":" -f1,4,5 /etc/passwd.2001 | cut -d "," -f1 | grep -w $argv[2] | tr ":" " " | wc -w` / 4
- @ p = $passnum
- set Names = ("`last | cut -d '"' '"' -f1`")
- @ Namesnum = `last | cut -d " " -f1 | wc -w`
- @ pass1num = $passnum
- while ($pass1num>0)
- while ($Namesnum>0)
- if ("$pass1[$pass1num]" == "$Names[$Namesnum]") then
- @ comp = 1
- endif
- @ Namesnum--
- end
- if ($comp == 0) then
- # while($p>0)
- set pr
- set pr = `echo $pass[$pass1num]`
- if($#pr > 1 ) then
- echo "Output: '$pr'"
- set pr
- endif
- # @ p--
- # end
- endif
- @ p = $passnum
- @ pass1num--
- @ Namesnum = `last | cut -d " " -f1 | wc -w`
- @ comp = 0
- end
- exit 0
- breaksw
- case -h:
- echo "pripravne1.csh (C) Filip T"
- echo "Usage: pripravne1.csh -h -g number"
- echo "-h: help"
- echo "-g number: vypise ludi ktory boli za posledne obdobie prihlaseny,"
- echo "v tvare : '<login_name> <group> <full_name>'"
- exit 0
- case -*:
- exit 1
- default:
- echo "spustene"
- exit 1
- endsw
- end
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement