Please help!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help!
# 1  
Old 06-23-2008
Question Please help!

Hi All,
I have the file in the following format.I need to change the password "tomcat","admin","mgr" and "testing" in the file with the encrypted passwords.

The encrypted passwords are given to me by another script.

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="admin" roles="role1"/>
<user username="both" password="mgr" roles="tomcat,role1"/>
<user username="admin" password="testing" roles="admin,manager"/>
</tomcat-users>

Following is the script that I had started, But I am stuck with the perl -i command.the perl -i command works like a charm with the string, but not working with the variable. Can anyone please help.


Code:
#!/usr/bin/ksh
passwds=`awk -F"\"" '$3 ~ "password="{print $4}' tomcat-users.xml`
for i in $passwds
do
/opt/coreservices/tomcat-5.5.9/bin/digest.sh -a sha $i >temp
en_passwd=`awk -F ":" '{print $2}' temp`
perl -i.bak -pe's/(password=").*?"/$1$enpasswds"/' tomcat-users.xml

But this command works like a charm!!
Code:
perl -i.bak -pe's/(password=").*?"/$1abcd"/' tomcat-users.xml

Please help!
# 2  
Old 06-23-2008
I am not bumping my question, but just wanted to check , if anyone can help me in my query.

Is there a substitute for the perl -i command , to make changes in the original file itself.

Thanks!
nua7
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question