Sponsored Content
Top Forums Shell Programming and Scripting check if user has read permissions Post 302256849 by cfajohnson on Monday 10th of November 2008 05:56:55 PM
Old 11-10-2008
Code:
if [ -r "$FILE" ]
then
  echo You have read permission
else
  echo You do not have read permission
fi

 

10 More Discussions You Might Find Interesting

1. Programming

read permissions by VC++

do you know how to read file permissions (such as lrwxrwxrwx) by VC++ on Windows OS (ftp connection)? I use a windows program (coreftp) to download and upload files for my host, this program displays permissions of files, so file permissions can be read by VC++, but I don't know how. any help... (1 Reply)
Discussion started by: hello20009876
1 Replies

2. UNIX for Dummies Questions & Answers

Default read/write/execute permissions

I am perplexed that my script execution is not always consistent in creating new files. Specifically, my group read/write/execute permissions. For instance, take a look at the following: -rw-rw---- 1 jg dp 18648 Aug 22 10:06 nx081508.txt -rw-rw---- 1 jg dp 22422 Aug 22 10:06... (1 Reply)
Discussion started by: joeyg
1 Replies

3. Shell Programming and Scripting

Using grep - check the permissions of the file searched

What I need to do is: I need to use the grep command to search for pattern in directory and sub-directories. And also I need to show the permission of file been seached by the grep command. Could any one please suggest me? ----------------- $> cat file1.txt A -----------------... (8 Replies)
Discussion started by: Johny001
8 Replies

4. Shell Programming and Scripting

How to check the mail permissions

Hi - I am trying to send email from unix box but none were delivered. I have tried multiple commands like mailx, mail or sendmail. But none of them worked. can you please let me know how to check if I have the right permissions to send the mail or not? (1 Reply)
Discussion started by: ahmedwaseem2000
1 Replies

5. Shell Programming and Scripting

How to check file permissions from a script.

hello, I have to write a script to run the other script inside it.So iam planning to write like this? first check the perimissions of the file. Alogorthim ---------- if(!filepermissions == execute) then echo" Permissions denined" else execute the script. file name is : load_mf.sh... (1 Reply)
Discussion started by: rajkumar_g
1 Replies

6. Solaris

add a ftp user with read and write permissions on a directory

hi all how I can create an ftp user in solaris 10 and have read and write permission on a directory. Thanks. (1 Reply)
Discussion started by: luisfja
1 Replies

7. Shell Programming and Scripting

Check the permissions linux user

i have some question for example: suppose we have the Public folder as follows: https://www.unix.com/attachment.php?attachmentid=2759&stc=1&d=1334070669 If the user enter: -Kenshin or /home/kenshin/Public output: abc: kenshin: rw my shell: echo "Enter User:" read user ... (3 Replies)
Discussion started by: kingkner
3 Replies

8. Homework & Coursework Questions

Check the permissions user

i have some question for example: suppose we have the Public folder as follows: https://www.unix.com/attachments/shell-programming-scripting/2759d1334070669-check-permissions-linux-user-capture.png If user enter: -Kenshin or /home/kenshin/Public output: abc: kenshin: rw my shell:... (1 Reply)
Discussion started by: kingkner
1 Replies

9. Programming

To check the file permissions using python scripting

Hi, For a particular set of files, am trying to check if they are writable. i.e., checking whether they are having permissions greater than 755. Am able to check this using the statement: "if (os.path.isfile(FILE_PATH) and (os.stat(FILE_PATH).st_mode & 0777) == 0777):" But the problem here... (0 Replies)
Discussion started by: arjun_arippa
0 Replies

10. Shell Programming and Scripting

To check the file permissions using python scripting

Hi, For a particular set of files, am trying to check if they are writable. i.e., checking whether they are having permissions greater than 755. Am able to check this using the statement: "if (os.path.isfile(FILE_PATH) and (os.stat(FILE_PATH).st_mode & 0777) == 0777):" But the problem... (1 Reply)
Discussion started by: arjun_arippa
1 Replies
umask(1)						      General Commands Manual							  umask(1)

NAME
umask - set or display the file mode creation mask SYNOPSIS
Set Mask Display Mask DESCRIPTION
The command sets the value of the file mode creation mask or displays the current one. The mask affects the initial value of the file mode (permission) bits for subsequently created files. Setting the File Mode Creation Mask The command sets a new file mode creation mask for the current shell execution environment. mask can be a symbolic or numeric (obsoles- cent) value. A symbolic mask provides a flexible way of modifying the mask permission bits individually or as a group. A numeric mask specifies all the permission bits at one time. When a mask is specified, no output is written to standard output. A symbolic mask replaces or modifies the current file mode creation mask. It is specified as a comma-separated list of operations in the following format. Whitespace is not permitted. [who][operator][permissions][, ...] The fields can have the following values: who One or more of the following letters: Modify permissions for user (owner). Modify permissions for group. Modify permissions for others. Or: Modify permissions for all = operator One of the following symbols: Add permissions to the existing mask for who. Delete permissions from the existing mask for who. Replace the existing mask for who with permissions. permissions One or more of the following letters: The read permission. The write permission. The execute/search permission. If one or two of the fields are omitted, the following table applies: | Format Entered Effect | Input Equals ---------------------------------------------------------+---------------- who Delete current permissions for who | operator No action | (none) permissions Equal to: | Delete current permissions for who | No action | (none) No action | (none) whopermissions Equal to: | operatorpermissions Equal to: | A numeric mask replaces the current file mode creation mask. It is specified as an unsigned octal integer, constructed from the logical OR (sum) of the following mode bits (leading zeros can be omitted): Displaying the Current Mask Value To display the current file mode creation mask value, use one of the commands: Print the current file mode creation mask in a symbolic format: The characters (read), (write), and (execute/search) represent the bits that are clear in the mask for (user/owner), (group), and (other). All other bits are set. Print the current file mode creation mask as an octal value. The zero bits in the numeric value correspond to the displayed and permission characters in the symbolic value. The one bits in the numeric value correspond to the missing permission characters in the symbolic value. Depending on implementation, the display consists of one to four octal digits; the first digit is always zero (see DEPENDENCIES). The rightmost three digits (leading zeros implied as needed) represent the bits that are set or clear in the mask. Both forms produce output that can be used as the mask argument to set the mask in a subsequent command. General Operation When a new file is created (see creat(2)), each bit that is set in the file mode creation mask causes the corresponding permission bit in the the file mode to be cleared (disabled). Conversely, bits that are clear in the mask allow the corresponding file mode bits to be enabled in newly created files. For example, the mask (octal disables group and other write permissions. As a result, files normally created with a file mode shown by the command as (octal become mode (octal while files created with file mode (octal become mode (octal Note that the file creation mode mask does not affect the set-user-id, set-group-id, or "sticky" bits. The file creation mode mask is also used by the command (see chmod(1)). Since affects the current shell execution environment, it is generally provided as a shell regular built-in (see DEPENDENCIES). If is called in a subshell or separate utility execution environment, such as one of the following: it does not affect the file mode creation mask of the calling environment. The default mask is (octal RETURN VALUE
exits with one of the following values: The file mode creation mask was successfully changed or no mask operand was supplied. An error occurred. EXAMPLES
In these examples, each line show an alternate way of accomplishing the same task. Set the value to produce read and write permissions for the file's owner and read permissions for all others displays on newly created files): Set the value to produce read, and write permissions for the file's owner, read-only for others users in the same group, and no access to others Set the value to deny read, write, and execute permissions to everyone Add the write permission to the current mask for everyone (there is no equivalent numeric mode): WARNINGS
If you set a mask that prevents read or write access for the user (owner), many programs, such as editors, that create temporary files will fail because they cannot access the file data. DEPENDENCIES
The command is implemented both as a separate executable file and as built-in shell commands. POSIX Shell and Separate File All features are supported (see sh-posix(1)). The numeric mask display uses a minimum of two digits. Korn Shell The option is not supported in the Korn shell built-in command (see ksh(1)). The numeric mask display uses a minimum of two digits. C Shell The option and symbolic mask values are not supported in the C shell built-in command (see csh(1)). The numeric mask display uses a mini- mum of one digit. SEE ALSO
chmod(1), csh(1), ksh(1), sh-posix(1), sh(1), chmod(2), creat(2), umask(2). STANDARDS CONFORMANCE
umask(1)
All times are GMT -4. The time now is 05:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy