Sponsored Content
Top Forums Shell Programming and Scripting What's the best way to check file permissions before moving files if needed? Post 303036925 by rbatte1 on Wednesday 17th of July 2019 12:52:05 PM
Old 07-17-2019
You might also consider the test options for files (man test for more detail)

Another alternative might be to use stat to get the value you need. Jim is right though, you don't just need to check the files, but the directory permissions too to ensure you can write to them. The update needed will create or remove the ile as part of the move. It can also be a nice way to get around sensitive data input in a particular place that supposedly has been locked down, i.e. the file payroll-input.txt might have RW for the owner, Read for a group you are not in and nothing for the rest, but if you have access to update the directory, you can remove or rename the file then create your own.

Smilie I'm not advocating it, but it is something consider and make everyone panic about simple security Smilie



The output from stat -c '%a %U %G' might give you the basics of what you need and you might parse them to decide if you should continue.



There are, however, lots of probably better suggestions before mine, such as that from MadeInGermany.



Just more options.

Kind regards,
Robin
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Help needed with searching files and moving them to a different directory

I am new to shell scripting. Can someone help me out with this one please? I need to write a script fot the following scenario: I am currently in /parent directory. I have a set of files in /parent/error_files directory My script has to search for a file in /parent/erratic_files... (1 Reply)
Discussion started by: ss3944
1 Replies

3. 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

4. Shell Programming and Scripting

Moving files only by oldest file one at a time

Hi I am want to create a script where the file gets moved from the current folder to a folder transfer based on the oldest first. This script should run one file at a time using a loop. I want it as a loop because I want to do some processing while I have one file. Can anyone guide me on this? (2 Replies)
Discussion started by: chamajid
2 Replies

5. Shell Programming and Scripting

Moving files based on file creation

Hi, I have a directory having so many number of files. Now I want to move the files which are older than one month (lets say) from this directory to another directory (say BKP dir). Simply, if file is olderthan one month move it from source1 dir to BKP1 dir. My file names doesn't have... (7 Replies)
Discussion started by: karumudi7
7 Replies

6. 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

7. 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

8. Shell Programming and Scripting

Moving files based on file name

Hi All, I have multiple files in the folder, I want to move those files into the other folder on based of name File names: Template_server1_01==> Template_server1_02==>To one directory /Server1 Template_server1_03==> Template_server2_01==> Template_server2_02==>To one... (9 Replies)
Discussion started by: sharsour
9 Replies

9. UNIX for Dummies Questions & Answers

Is there a way to check when the permissions for the file got changed in AIX

Is there a way to check when the permissions for the file got changed in AIX IS there some file which logs all these details? Best regards, Vishal (4 Replies)
Discussion started by: Vishal_dba
4 Replies

10. Shell Programming and Scripting

Moving alphanumeric files according to the digit in file name

This is the content of my directory c_g_se1_gb.ph c_g_se1_gb.ph_pl_s.t c_g_se1_gb.ph_pl_tr.t c_g_se3_gb.ph c_g_se3_gb.ph_pl_s.t c_g_se3_gb.ph_pl_tr.t c_g_se2_gb.ph c_g_se2_gb.ph_pl_s.t c_g_se2_gb.ph_pl_tr.t c_g_se4_gb-1.ph c_g_se4_gb-1.ph_pl_s.t c_g_se4_gb-1.ph_pl_tr.t... (9 Replies)
Discussion started by: sammy777888
9 Replies
GRUB-MKRESCUE(1)						   User Commands						  GRUB-MKRESCUE(1)

NAME
grub-mkrescue - make a GRUB rescue image SYNOPSIS
grub-mkrescue [OPTION...] [OPTION] SOURCE... DESCRIPTION
Make GRUB CD-ROM, disk, pendrive and floppy bootable image. --compress=no|xz|gz|lzo compress GRUB files [optional] -d, --directory=DIR use images and modules under DIR [default=/usr/lib/grub/<platform>] --fonts=FONTS install FONTS [default=unicode] --install-modules=MODULES install only MODULES and their dependencies [default=all] -k, --pubkey=FILE embed FILE as public key for signature checking --locale-directory=DIR use translations under DIR [default=/usr/share/locale] --locales=LOCALES install only LOCALES [default=all] --modules=MODULES pre-load specified modules MODULES --themes=THEMES install THEMES [default=starfield] -v, --verbose print verbose messages. --arcs-boot enable ARCS (big-endian mips machines, mostly SGI) boot. Disables HFS+, APM, sparc64 and boot as disk image for i386-pc --core-compress=xz|none|auto choose the compression to use for core image --label-bgcolor=COLOR use COLOR for label background --label-color=COLOR use COLOR for label --label-font=FILE use FILE as font for label -o, --output=FILE save output in FILE [required] --product-name=STRING use STRING as product name --product-version=STRING use STRING as product version --rom-directory=DIR save ROM images in DIR [optional] --sparc-boot enable sparc boot. Disables HFS+, APM, ARCS and boot as disk image for i386-pc --xorriso=FILE use FILE as xorriso [optional] -?, --help give this help list --usage give a short usage message -V, --version print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. Generates a bootable CD/USB/floppy image. Arguments other than options to this program are passed to xorriso, and indicate source files, source directories, or any of the mkisofs options listed by the output of `xorriso -as mkisofs -help'. Option -- switches to native xorriso command mode. Mail xorriso support requests to <bug-xorriso@gnu.org>. REPORTING BUGS
Report bugs to <bug-grub@gnu.org>. SEE ALSO
grub-mkimage(1) The full documentation for grub-mkrescue is maintained as a Texinfo manual. If the info and grub-mkrescue programs are properly installed at your site, the command info grub-mkrescue should give you access to the complete manual. grub-mkrescue (GRUB) 2.02-2ubuntu8.3 July 2018 GRUB-MKRESCUE(1)
All times are GMT -4. The time now is 03:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy