Re: Acting upon error messages
From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 09/21/04
- Next message: RolandRB: "Re: Acting upon error messages"
- Previous message: Svatoboj: "Acting upon error messages"
- In reply to: Svatoboj: "Acting upon error messages"
- Next in thread: RolandRB: "Re: Acting upon error messages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Sep 2004 12:34:43 GMT
2004-09-21, 00:18(-07), Svatoboj:
> Dear users,
>
> as I didn't write so many shell scripts I wonder how to act upon an
> error message?
> Just for example:
>
> --snip--
>
> if [ -e $dir]; then
if [ -e "$dir" ]; then
but it will fail (won't report existence) if "$dir" is a symlink
to an inaccessible file.
> echo "Directory exists"
or file or named pipe, or symlink...
> else
> mkdir $dir
mkdir -- "$dir" && echo success
> echo "Directory succesfully created"
> fi
>
> --snip--
>
> But what about mkdir returns error for whatever reason? Wrong perms or
> so? I would like to print an error message an exit.
> How to achieve this?
if mkdir -- "$dir"; then
echo "Directory succesfully created"
else
exit 1
fi
No need to check for file existence, mkdir will do that anyway.
-- Stephane
- Next message: RolandRB: "Re: Acting upon error messages"
- Previous message: Svatoboj: "Acting upon error messages"
- In reply to: Svatoboj: "Acting upon error messages"
- Next in thread: RolandRB: "Re: Acting upon error messages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|