Operating System - HP-UX
1832095 Members
3075 Online
110038 Solutions
New Discussion

Need to change permistions dynamically in shell script

 
SOLVED
Go to solution
Srinivas Palukuru
New Member

Need to change permistions dynamically in shell script

Hi,

I need a solution. My shell script generates text files on server with permition -rw-r-----. after generating the files and completion of process, i need to move these files to some other folder. please help how to change these permitions in shell script with chmod.

Regards,
Srinivas
4 REPLIES 4
Peter Godron
Honored Contributor
Solution

Re: Need to change permistions dynamically in shell script

Hi,
see "man umask"
Set the default permission for when you create the files.

Also:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
RAC_1
Honored Contributor

Re: Need to change permistions dynamically in shell script

You can control the perms with which a file is created. you can have umask setting for that. umask won;t get you execute perm though.
There is no substitute to HARDWORK
spex
Honored Contributor

Re: Need to change permistions dynamically in shell script

Srinivas,

'umask' is better, but...

#!/usr/bin/sh
$SRCDIR=/path/to/src
$DSTDIR=/path/to/dst
$PERM=644 #rw-r--r--
for file in $(ls ${SRCDIR})
do
mv ${SRCDIR}/${file} ${DSTDIR}/${file}
chmod ${PERM} ${DSTDIR}/${file}
done
exit

PCS
Srinivas Palukuru
New Member

Re: Need to change permistions dynamically in shell script

Thanks everybody.