The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Search and replace entire line insania Shell Programming and Scripting 1 05-22-2008 03:45 PM
Perl: Global Search and replace epi8 Shell Programming and Scripting 3 05-06-2008 12:18 PM
Search and replace in Perl jyoung Shell Programming and Scripting 2 04-22-2008 10:05 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 06:24 AM
perl search and replace pairs umen Shell Programming and Scripting 1 07-30-2006 08:37 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2008
Registered User
 

Join Date: Dec 2007
Posts: 5
Smile search & replace password perl script

I wanted a perl script to be done for Password search & replace in two files.

For Example:

Example 1)--i am having a file such as
cat /opt/customer/Ariba/UAT/ariba/app/buyer/Server/config/Parameters.table

Example 2)--and i am having a other file in other location such as cat /opt/customer/home/username/CMStaging/UAT-20080304/AR/ServerFiles/opt/customer/Ariba/UAT/ariba/app/buyer/Server/config/Parameters.table

the example 1 file contains the string as **REPLACE**
the example 2 file contains the live password to be replaced.

i want is it should take the live password from the example 2 file & replace that (**REPLACE**)string with the example 1 file.

can anyone help me out for some code in detailed for the same on a urgent basis..

Thanks
Samir
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-24-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,108
Searching for a string in file and replacing it could be done very easily with "sed", look at the forum base for various examples. Why you want this in perl ? You're gonna have to open the file, search / grep for string, then replace and close the file - uncecessary long.
Reply With Quote
  #3 (permalink)  
Old 03-24-2008
Registered User
 

Join Date: Jan 2008
Posts: 294
Perl can do this just like sed using perls inplace editor.

How do you find the "live password" in the second file?
Reply With Quote
  #4 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Dec 2007
Posts: 5
Smile search & replace script in shell or perl

actually i have 2 files
example

first file contains the live password in it & the second file contains **REPLACE** string

after running the script it should automatically take the password from the live file & replace that string of **REPLACE** in the second file

the same should be done for Multiple strings..

Please help...

Thanks
Samir
Reply With Quote
  #5 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Jan 2008
Posts: 294
You need to answer my question above and provide more details. The generic answer is get the password from the file it's in, search the other file for the pattern and replace it with the password:

s/\Q**REPLACE**\E/$password/;
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0