![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file permissions | ranj@chn | Shell Programming and Scripting | 7 | 06-11-2008 08:37 AM |
| To give the "unzip" permissions & "create" file permissions | Mike1234 | HP-UX | 3 | 03-02-2008 02:34 PM |
| help with file permissions | bbbngowc | Security | 3 | 12-21-2007 10:34 AM |
| File permissions | beginner1 | UNIX for Dummies Questions & Answers | 5 | 04-12-2006 09:56 AM |
| File and Dir permissions | thomas.jones | UNIX for Dummies Questions & Answers | 11 | 04-19-2002 06:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
file permissions
Hi!
Is there any shell parameter that I can use in my script to check the file-permissions I have in the currect directory!? The history behind is: My script tries to create some log files in the folder and I want to see whether I have enough permissions to do that. And exit in case I dont have. currently I create a temp file using touch command, and check the return code ($?) of that command, and exit if it is non-zero, and remove the temp file if zero. This is a unwanted process!! Thanks in advance, Mohan. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
You could use
Code:
stat -c=%a logfile =600 which is equivalent to -rw------- Vino |
|
#3
|
||||
|
||||
|
instead of creating a temp file --- create the logfile instead, check for it and exit your script if you can't create the logfile ...
echo > $logfile [ ! -f $logfile ] && exit |
|
#4
|
||||
|
||||
|
Code:
$ mkdir tmpdir $ ls -ld tmpdir drwxr-xr-x 2 bozo bozogroup 0 May 31 23:02 tmpdir $ [ -w "./tmpdir" ] && echo "Yes I can write..." Yes I can write... $ chmod 500 tmpdir $ ls -ld tmpdir dr-x------ 2 bozo bozogroup 0 May 31 23:02 tmpdir $ [ -w "./tmpdir" ] && echo "Yes I can write..." $ ZB |
|
#5
|
||||
|
||||
|
[ -w "./tmpdir" ] && echo "Yes I can write..."
Perfect ! --Ripeness of experience seeks brevity of expression-- Vino |
||||
| Google The UNIX and Linux Forums |