Main script command
dbchange.sh
This script runs but do not replace the string. Can someone tell me what i am missing here. My local system os is linux and remote system is solaris.
I'm not sure what that syntax is, but I think this may be closer to what you want:
Assumptions - ProejctTarget is a directory on the remote node and the shell script has to live on that node to work. Either that or you have to nfs mount your remote directory on let a local copy of dbchange.sh see it as local.
#!/bin/bash
# Script for execution on the Solarix box
for file in find /devl/bfx/ecif/etl/$ProjectTarget/parameterfiles/ -exec grep -l CNTCT{} \;
do ls -l $file
sed -e 's/CNTCT/CNTCTST/' $file > $file.tmp
mv $file.tmp $file
done
for file in find /devl/bfx/ecif/etl/$ProjectTarget/parameterfiles/ -exec grep -l DBCIBNR{} \;
do ls -l $file
sed 's/DBCIBNR/DBCIBC4/g' $file > $file.tmp
mv $file.tmp $file
done
Strongly advise that you copy the script to the remote server and test it thoroughly there from the Solaris command prompt (without the bash shebang unless you have bash on the Solaris box) but with the shebang to match your Solaris account (e.g. /bin/ksh). The script contains numerous syntax errors and fundamental errors and it needs serious debugging. When debugged I would recommend that you execute the remote script from ssh.
As far as I can see the script actually does nothing useful - mainly because the "find" statements never execute. Unless this is a mispaste, the script should be giving syntax errors on the "for" and "do" lines.
My usual comment. With faulty code we need a written description of what the script should do complete with sample input and sample output.
My guess for some corrections (assuming that you run the script on the Solaris box). Totally untested and without warranty and intended as an exercise in correcting Shell syntax:
Notice the subtle addition of space characters on the "grep" lines.
Because the script now has the potential to change live parameter files, please test on a test system having backed-up the original files.
A script of this nature should backup the original files before making changes. It's good working practice and it creates an Audit Trail.
Last edited by methyl; 03-13-2012 at 07:25 PM..
Reason: remove as many syntax errors as possible. spacing on the grep line. layout and indentation. quoting paranoia! correct sed
I copied the script to the remote server and tested and it worked fine code is
when i tried the same from local i could not get the desired output.
main Code
dbchange.sh
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 .
1) Bumping up posts or double posting is not permitted in these forums.
2) You say you did mot get desired output, fine, what did you get then?
3) Why are you mixing scripts written in bash and ksh? knowing that linux will not understand by default ksh and solaris bash...
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)