Operating System - HP-UX
1757707 Members
2234 Online
108863 Solutions
New Discussion юеВ

Modify 250 user .profiles at once.

 
Doug_85
Regular Advisor

Modify 250 user .profiles at once.

HP-UX 11.0 L2000

We're upgrading from oracle 8i to 9i. I need to modify each user's .profile and softlink it to the appropriate directory where their new .profile is located. I know to use ln -s to create the softlink but does anyone have a script that would automate this process with 5 different .profiles and 250 users. Each user will need to be linked to one of the 5 .profiles.

Thanks,
Doug
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: Modify 250 user .profiles at once.

This is rather easy with sed, Perl, or awk but rather tha doing symbolic links, let me give you a plan B:

Create your 5 different scripts to set and export the environment variables.
e.g.
/usr/local/bin/oraenv1.sh

Now each of your user's .profile won't have a symbolic link but rather will source one of these 5 files using the "." dot operator.
. /usr/local/bin/oraenv1.sh

In the future, all you have to do is make changes to one of these 5 files and nothing else needs to be touched. Also, batch files can source the appropriate file in the same way. Note: These sourced files must mot contain an exit or return statement.
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: Modify 250 user .profiles at once.

Clay's idea is the better way. But if you ever wanted to edit a bunch of files, perl has the "-i" option to edit in place. For instance-

perl -i -p -e 's/oracle8/oracle9/g' /home/*/.profile

would change every occurance of text oracle8 to oracle9 in all the .profile files.

HTH

-- Rod Hills
There be dragons...