1833764 Members
2960 Online
110063 Solutions
New Discussion

edit on .profile

 
SOLVED
Go to solution
Jim Lewis_8
Advisor

edit on .profile

Is there a way to make a change on a one line entry in each of the user's .profile removing the umask entry all together. I have over 600 users to make this simple change on their corresponding ".profile" and I'm not that experienced in HP-UX 10.20 programming.

Thank you....
Just a "Rookie"
11 REPLIES 11
Hai Nguyen_1
Honored Contributor

Re: edit on .profile

You can run the following script to remove the umask line in all users' .profile

---- script starts -----
#!/bin/sh

find /home -type f -name '.profile' | while read FILE
do
if [ `grep umask $FILE` -eq 0 ]
then
grep -v umask > $FILE.new
cp $FILE.new $FILE
rm $FILE.new
fi
done
----- script ends ------
Hai
Jim Lewis_8
Advisor

Re: edit on .profile

I created a file called rmumask.com and it failed due to a parameter problem...any suggestions?

Error:

./rmumask.com[5]: test: Specify a parameter with this command.

Thank You....
Just a "Rookie"
Christopher McCray_1
Honored Contributor

Re: edit on .profile

Show us your file so we can see anything possibly out of the ordinary.

Thanks

Chris
It wasn't me!!!!
Jim Lewis_8
Advisor

Re: edit on .profile

I cut/pasted the suggestion from Hai exactly where the start and end points were (not including that text) and made it executable. It's the same file word for word with the same lines.

Thanks!
Just a "Rookie"
Hai Nguyen_1
Honored Contributor

Re: edit on .profile

Jim,

Can you post the file?

Also in case you do not know, you need to make the file executable as follows:

# chmod 755 rmumask.com

By the way, I believe that there is no error in my script.

Hai
Jim Lewis_8
Advisor

Re: edit on .profile

Posting of file, permissions set to 755...

< ca_tok1 > /tmp #more rmumask.com
#!/bin/sh

find /home -type f -name '.profile' | while read FILE
do
if [ `grep umask $FILE` -eq 0 ]
then
grep -v umask > $FILE.new
cp $FILE.new $FILE
rm $FILE.new
fi
done
Just a "Rookie"
Hai Nguyen_1
Honored Contributor

Re: edit on .profile

Jim,

Actually, there is a logical missing in my script. It should have been as follows:

---- script starts -----
#!/bin/sh

find /home -type f -name '.profile' | while read FILE
do
grep umask $FILE >/dev/null
if [ `echo $?` -eq 0 ]
then
grep -v umask > $FILE.new
cp $FILE.new $FILE
rm $FILE.new
fi
done
----- script ends ------

Sorry. It must work this time.

Hai
Hai Nguyen_1
Honored Contributor
Solution

Re: edit on .profile

Jim,

I spotted another missing parameter. This is the final one:

---- script starts -----
#!/bin/sh

find /home -type f -name '.profile' | while read FILE
do
grep umask $FILE >/dev/null
if [ `echo $?` -eq 0 ]
then
grep -v umask $FILE > $FILE.new
cp $FILE.new $FILE
rm $FILE.new
fi
done
----- script ends ------

Hai
Jim Lewis_8
Advisor

Re: edit on .profile

Bingo! The script ran flawlessly. Thank you for your help. Sorry it took so long to work out the details, but you saved me lots of time through it all!
Just a "Rookie"
Hai Nguyen_1
Honored Contributor

Re: edit on .profile

Jim,

I'm glad that I could help.

Hai
Charles Akonnor
Advisor

Re: edit on .profile

#gets all home directories from /etc/passwd

cat /etc/passwd|awk -F: '{print $6}'|while read i
do
#safe a copy of each .profile to .profile.org
cp ${i}/.profile ${i}/.profile.org

#removes the line with umask in profile.new
cat ${i}/.profile |grep -v umask > ${i}/profile.new

#moves new profile to .profile
mv ${i}/profile.new ${i}/.profile
done
Never give up.