Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- PASSWDFILE=/etc/passwd
- print_help()
- {
- echo "$0: Usage: $0 [options] | [ login | ps-root ]"
- cat << "END"
- Outputs some information, depending on the options.
- If no options are specified, the help is printed.
- Commands: [ login | ps-root ]
- login: the /etc/passwd line corresponding to the calling user is printed
- ps-root the lines of the command `ps-root` containing "root" are printed
- Options: [h]
- -h, --help outputs this text
- END
- }
- error()
- {
- echo $1 >&2
- print_help >&2
- }
- if [ $# -eq 0 ];then
- print_help
- elif [ $# -eq 1 ];then
- if [ "x$1" = "xlogin" ];then
- echo $(cat $PASSWDFILE | egrep "$USER")
- elif [ "x$1" = "xps-root" ];then
- ps -ef | sed -e "root"
- elif [ "x$1" = "x-h" ];then
- print_help
- elif [ "x$1" = "x--help" ];then
- print_help
- else
- error "unknown paremeter"
- exit 1
- fi
- else
- error "wrong paremeter count"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement