- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to change permissions of incoming files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 12:38 AM
11-08-2012 12:38 AM
Hi All
I have a system that receives files via ftp from another system and these files arrive at a certain directory, but these files are arriving with
-rw-r--r--
permissions, but to further process them they need to be change to:
-rwxrwxrwx
So, I use the following command in the crontab to do the job, but, if the files arrive in large numbers, the permissions do not change:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/chmod 777 $(ls -l /moneta_polled01/sgsn/ | awk '$0 !~ /rwxrwxrwx/ && /^-/{print $9}')
I even try to shorten the time that entry runns, but no sucess.
Please can you help on this?
FR
Solved! Go to Solution.
- Tags:
- chmod
- Permission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 02:31 AM - edited 11-08-2012 09:10 PM
11-08-2012 02:31 AM - edited 11-08-2012 09:10 PM
Re: script to change permissions of incoming files
>to further process them they need to be change to: -rwxrwxrwx
Since these files are not scripts you should NOT add execute permission.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/chmod 777 $(ls -l /moneta_polled01/sgsn/ | awk '$0 !~ /rwxrwxrwx/ && /^-/{print $9}')
Instead of putting this all in your crontab entry, you may want to create a script where you can easily make changes.
But your immediate problem is that your ls(1) doesn't provide your directory path.
... cd /moneta_polled01/sgsn; chmod a+rw $(ll | awk '$0 !~ /rwxrwxrwx/ && /^-/ {print $9}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 03:41 AM
11-08-2012 03:41 AM
Re: script to change permissions of incomming files
Hi,
an additional problem may be, that you change the permissions of all files in one big command. Ther is a limit fo files that you can provide to one single chmod command.
You better would execute:
cd /moneta_polled01/sgsn
for file in `ls -l /moneta_polled01/sgsn/ | awk '$0 !~ /rwxrwxrwx/ && /^-/{print $9}'`
do
/usr/bin/chmod 777 ${file}
done
You can put this in a one-liner, if you want.
In addition, as Dennis said, reduce the permission as far as possible, probably changing the groupownership to get rid of those ugly permissions for everybody.
Bye
Ralf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 03:56 AM
11-08-2012 03:56 AM
Re: script to change permissions of incomming files
Hi
I wrote a little script but does not seem to be working:
mkdir -p /tmp/tmpdir #find . -exec ls -l {} \; |grep -v rwxrwxrwx |awk '{print $9}' > /tmp/tmpdir/filelist find /moneta_polled01/sgsn/ -exec ls -l {} \; |grep -v rwxrwxrwx |awk '{print $9}' > /tmp/tmpdir/filelist cd /tmp/tmpdir /usr/bin/split -l 1000 fileslist for i in `ls x*` do for j in cat $i do chmod 777 /moneta_polled01/sgsn/$j done done rm -rf /tmp/tmpdir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 10:26 AM - edited 11-08-2012 09:10 PM
11-08-2012 10:26 AM - edited 11-08-2012 09:10 PM
Solution>but does not seem to be working
There is no need to do a split. And your evil cat has the wrong syntax:
for file in $(< fileslist); do
chmod a+rw /moneta_polled01/sgsn/$file
done
cd - # so can remove tmpdir
rm -rf /tmp/tmpdir
And it would probably better to use xargs vs your for-loop combination.
Or better yet, only use find:
find /moneta_polled01/sgsn -type f ! -perm a+rw -exec chmod a+rw {} +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2012 11:56 PM
11-08-2012 11:56 PM
Re: script to change permissions of incoming files
Hi
I have used the find command, on cron, and it looks like is working fine.