|
CHK can be used to check a file if it is invoked as
chk -f filepath
or to check a user if it is invoked as
chk -u user
if filepath exists,output
. what it is: file, directory, symbolic link or other
. what combination or read,write and execute access right your program has for the data. Note that this is dependent on who runs your program: you cannot easily determine this by looking at the file's permission as output by ls -l
if the filepath doesn't exist or is inaccessible, your program should report this instead in a informative error message.
if the user exits on the system,report
.the path ot he user's home directory
.when the user last logged in OR if the user is currently loggedin
if the user doesn't exist, report his as an error.
下到有个以运行的例子:
bash$ chk -f chk
'chk' is a regular file
It is readable, writable, executable.
bash$
bash$ chk -f .
'.' is a directory
It is readable, writable, executable.
bash$
bash$ chk -f /dev/null
'/dev/null' is not a known file type
It is readable, writable, not executable.
bash$
bash$
bash$ chk -f xxxx
chk:ERROR: 'xxxx' does not exist
bash$
bash$ echo $?
1
bash$
bash$ chk -u gboyd
'gboyd's home directory is /users/gboyd
Currently logged in
bash$ echo $?
0
bash$ chk -u foobar6
chk:ERROR: user 'foobar6' cannot be found on the system
bash$ echo $?
1
bash$ chk -d
chk:ERROR: must have exactly two arguments
chk: USAGE: chk { -f filepath | -u user } |
|