Find and replace a string on remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and replace a string on remote server
# 8  
Old 03-19-2012
1. My browser had a issue and i could not realize its going to be double post.
2. Script ran without replacing the string mentioned in dbchange.sh script
3. Bash script will run on Linux server and Ksh will run on Solaris this was suggested in previous post.
Thanks
# 9  
Old 03-23-2012
Quote:
Here i m trying to copy file from Server1 Dir-1 to Server1 Dir-2 from Server2 and finding and replacing some string in parameter dir-2 of server1 .
Sorry, but the above sentence makes absolutely no sense in English. Please re-phrase the statement.



Not clear which process takes place on which computer or why you do not copy the script to the remote computer first, then execute that script on the remote computer.
# 10  
Old 03-23-2012
i m trying to find and replace a string on remote server (SOLARIS) from Local server (Linux).
dbchange.sh is the script which gets executed on Solaris server to find and replace "String" it has a variable $ProjectTarget .
I am not suppose to keep script on Remote server.

Last edited by nitinmathur18; 03-23-2012 at 12:20 PM..
# 11  
Old 03-23-2012
Some of the files you are copying from Server1 to Server2 appear to be the same files that you wish to edit on Server2.

If ALL the files which need editing exist on Server1 and will be copied to Server2, why not edit them (to temporary names) locally and then copy the edited versions to Server2 ?


Addendum: It would be much easier to run the whole process from Server2.

Last edited by methyl; 03-23-2012 at 02:02 PM..
# 12  
Old 03-23-2012
Thats correct Methyl but server1 is a production server , we should not be editing anything on that server. The ID which is used here doesn't have write access to those files.
I wish this could have been easy.. Can you guide me on how we can do this from remote. Thanks
# 13  
Old 03-23-2012
The Development server only needs read access to the Live server files. I would suggest running the whole process on the Development server and copying the files from the Live server to the Development server and then correcting the parameters.
# 14  
Old 03-28-2012
I have written the code just waiting for testing
Code:
scp -r  ecifetls@boom.nwie.net:/vol/ecif/etl/$ProjectTarget/parameterfiles/*.* /bfx/$ProjectTarget/parameterfiles/
	find /bfx/$ProjectTarget/parameterfiles/ -type f -exec sed -i 's/CNTCT/CNTCTST/' {} \;
	find /bfx/$ProjectTarget/parameterfiles/ -type f -exec sed -i 's/DBCIBNR/DBCIBC4/g'{} \;
	scp -r  /bfx/$ProjectTarget/parameterfiles/*.* ecifetls@boom.nwie.net:/devl/bfx/ecif/etl/$ProjectTarget/parameterfiles/

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. UNIX for Dummies Questions & Answers

Find and Replace string in UNIX

Hi All, Greetings. I have a .dat file which somewhere in its content contains symbol ""^ I want to replace it with "^ I tried with SED command but could not achieve what i wanted sed -e "s/'""^'/'"^'/ig" filename.dat (5 Replies)
Discussion started by: MaddyS
5 Replies

3. Shell Programming and Scripting

Find the remote server status.

Hi All, I would like to connect from "Instance A" to "Instance B" with the help of sftp. Where as Instance B is having clustered servers ( 2 servers pointing same instance ). Now, my question is before connecting to "Instance B" from "Instance A" how do know whether server is running or not.... (3 Replies)
Discussion started by: Girish19
3 Replies

4. Solaris

How to find and replace a string?

Dear All I need to find and replace a string in a set of files. I try as : #find / -name "*"|xargs grep "Tektra"|grep -v "Tektra GSM BTS" But it doesn't work. It just finds the string in the files. I need to find and replace it.Can you please let me know how to correct it? Thank you (2 Replies)
Discussion started by: hadimotamedi
2 Replies

5. Shell Programming and Scripting

HPUX find string in directory and filetype and replace string

Hi, Here's my dilemma. I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories Is this possible? Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below I have... (13 Replies)
Discussion started by: pure_jax
13 Replies

6. Shell Programming and Scripting

find string and replace with string in other file

Dear all, I need your help, I have file like this: file1:23456 01910964830098775635 34567 01942809546554654323 67589 26546854368698023653 09778 58716868568576876878 08675 86178546154065406546 08573 54165843543054354305 . .file2: 23456 25 34567 26 67589 27 (2 Replies)
Discussion started by: attila
2 Replies

7. Shell Programming and Scripting

Find the position of a string and replace with another string

Hi, I have a file named "Test_2008_01_21" The file contains a string "manual" that occurs many times in the file How can i find the positions of the string "manual" in the file Ex: if the string " manual " occurs three times in the file. i want to replace the second occurance of string... (6 Replies)
Discussion started by: bab123
6 Replies

8. UNIX for Dummies Questions & Answers

Find and replace character in a string

Hi all, My problem is the following: I've a script that must list all files in a directory and write this information in a text file. I've tried to get the list through ls command and then write it using msgecho msgecho "`ls $PATH_APS_JOB_ORA`" This works good but the created string... (7 Replies)
Discussion started by: callimaco0082
7 Replies

9. Shell Programming and Scripting

Find files not accessed on a remote server and delete - Help!

Hi Guys, I am currently working on a script to find all the files that have not been accessed for the past 2 years. This, i guess has been discussed n number of times in this forum. Now, my requirement is to find all the files in the remote windows server. I have it mounted in unix. I was... (1 Reply)
Discussion started by: bond_bhai
1 Replies

10. Programming

how to find and replace string

hi I wanted to find this char " ^M " in my file and replace it with blank space. I am using Unix system. If i give command " :%s/^M//gc " it wont work so can anyone tell what is command to find and replace thankx (3 Replies)
Discussion started by: mridula
3 Replies
Login or Register to Ask a Question