Unix Shell - Sed scipt issue

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > May 2007 > Sed scipt issue





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Sed scipt issue
Shell Solution

2007-05-29, 1:22 pm

Dear Team,
I am running a script that automattcally replaces text in a file.

I used the sed -f sedscript gd.xml command,
where sedscript is the scriptfile containing the commands to be
changed and gd.xml is the file to be changed.

After running this script, I get a command stating:
sed: Couldn't open file sedscript.txt

Please help me ideas on this issue.

Regards,

Esoimeme George,

Ed Morton

2007-05-29, 1:22 pm

Shell Solution wrote:
> Dear Team,
> I am running a script that automattcally replaces text in a file.
>
> I used the sed -f sedscript gd.xml command,
> where sedscript is the scriptfile containing the commands to be
> changed and gd.xml is the file to be changed.
>
> After running this script, I get a command stating:
> sed: Couldn't open file sedscript.txt
>
> Please help me ideas on this issue.
>
> Regards,
>
> Esoimeme George,
>


At a guess, you're typing:

sed -f sedscript.txt gd.xml

instead of:

sed -f sedscript gd.xml

If that's not it, run the command again and do a copy/paste of the
command line and output so we can see it. Also tell us which shell
you're using and post the contents of "sedscript" if it's small.

Ed.
Maxwell Lol

2007-05-29, 7:21 pm

Ed Morton <morton@lsupcaemnt.com> writes:

[vbcol=seagreen]
> If that's not it, run the command again and do a copy/paste of the
> command line and output so we can see it. Also tell us which shell
> you're using and post the contents of "sedscript" if it's small.



Also - try using the full pathname to the script in cause it's not in
the current directory.
Shell Solution

2007-05-30, 1:25 pm

Hi,
Please find below the script file, the sedscript.txt file and output
below:

1.script file


TODAY=`date '+%d-%m-%Y'`

cd /root/cs3/report_archive

q=`ls -ltr |tail -10 | grep VS|awk '{print $9}'`

r=`ls -ltr |tail -10 | grep ME|awk '{print
$9}'`

s=`ls -ltr |tail -10 | grep SFD|awk '{print $9}'`

u=`ls -ltr |tail -10 | grep Eez|awk '{print
$9}'`

v=`ls -ltr |tail -10 | grep cs3|awk '{print $9}'`



va=`cat $v | grep unreserved | awk '{print $4}'`



#Used voucher varibles
qa=`cat $q | grep V3| awk '{print $3}'`

qb=`cat $q | grep V4| awk '{print $3}'`
qc=`cat $q | grep V5| awk '{print $3}'`

qd=`cat $q | grep V6| awk '{print $3}'`
qe=`cat $q | grep V10| awk '{print $3}'`


#Me2U varibles
ra=`cat $r | tail -3|head -1|awk '{print
$1}'`
rb=`cat $r | tail -3|head -1|awk '{print $2}'`


#Daily Service Fee Distribution varibles
sa=`cat $s|tail -5| head -1| awk '{print $2}'`
sb=`cat $s|tail -4| head -1| awk '{print $2}'`
sc=`cat $s|tail -3| head -1| awk '{print $2}'`
sd=`cat $s|tail -2| head -1| awk '{print $2}'`

#eeZee varibles
ua=`cat $u| tail -1|awk '{print $1}'`
ub=`cat $u| tail -1|awk '{print $2}'`


#subscription distribution
cd /root/cs3/report_pool
t=`ls total*`




#Subscription Distribution varibles
ma=`cat $t | grep MobiPaid | awk '{print $2}'`
mi=`cat $t | grep MobiPaid | awk '{print $3}'`
mn=`cat $t | grep MobiPaid | awk '{print $4}'`


ea=`cat $t | grep eeZee | awk '{print $2}'`
ei=`cat $t | grep eeZee | awk '{print $3}'`
en=`cat $t | grep eeZee | awk '{print $4}'`


sa=`cat $t | grep Salamat | awk '{print $2}'`
si=`cat $t | grep Salamat | awk '{print $3}'`
sn=`cat $t | grep Salamat | awk '{print $4}'`

za=`cat $t | grep SawaSana | awk '{print $2}'`
zi=`cat $t | grep SawaSana | awk '{print $3}'`
zn=`cat $t | grep SawaSana | awk '{print $4}'`

#Export variables


sed -f sedscript.txt gd.xml

export qa
export qb
export qc
export qd
export qe
export ra
export rb
export sa
export sb
export sc
export sd
export ua
export ub
export t
export ma
export mi
export mn
export ea
export ei
export en
export sa
export si
export sn
export za
export zi
export zn

echo $qa
echo $qb
echo $qc
echo $qd
echo $qe
echo $ra
echo $rb
echo $sa
echo $sb
echo $sc
echo $sd
echo $ua
echo $ub
echo $t
echo $ma
echo $mi
echo $mn
echo $ea
echo $ei
echo $en
echo $sa
echo $si
echo $sn
echo $za
echo $zi
echo $zn

sed -f sedscript.txt gd.xml


2.sedscript.txt file
#!/bin/sed -f
s/'$ma'/$11/g
s/'$mi'/$12/g
s/'$mn'/$13/g
s/'$ea'/$21/g
s/'$ei'/$22/g
s/'$en'/$23/g
s/'$sa'/$31/g
s/'$si'/$32/g
s/'$sn'/$33/g
s/'$za'/$41/g
s/'$zi'/$42/g
s/'$zn'/$43/g
s/'$qa'/$51/g
s/'$qb'/$61/g
s/'$qc'/$71/g
s/'$qd'/$81/g
s/'$qe'/$91/g



3.Output
[root@mobix scripts]# ./dailyReporter.sh
sed: Couldn't open file sedscript.txt
171663
29142
3365
1349
187212
893982
288,419,983.00
88627 115041
20666362.50

14525.00
2007/05/30
1347
total_sdp_active_install_activation_by_s
c_21-05-2007.txt.OLD
total_sdp_active_install_activation_by_s
c_29-05-2007.txt
1505480 2373748
135846 190716
788 715
848987 1532675
163767 554500
4621 4741
88627 115041
26997 27094
0 0
6226 13552
5473 6111
2 0
sed: Couldn't open file sedscript.txt


On May 29, 8:55 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> Shell Solution wrote:
>
>
>
>
>

[vbcol=seagreen]
>
> At a guess, you're typing:
>
> sed -f sedscript.txt gd.xml
>
> instead of:
>
> sed -f sedscript gd.xml
>
> If that's not it, run the command again and do a copy/paste of the
> command line and output so we can see it. Also tell us which shell
> you're using and post the contents of "sedscript" if it's small.
>
> Ed.




Shell Solution

2007-05-30, 1:25 pm

The shell is
/bin/bash

The sedscript is in the same folder as the main script.

On May 30, 12:46 am, Maxwell Lol <nos...@com.invalid> wrote:
> Ed Morton <mor...@lsupcaemnt.com> writes:
>
> Also - try using the full pathname to the script in cause it's not in
> the current directory.



Ed Morton

2007-05-30, 1:25 pm

Shell Solution wrote:

[please don't top-post, fixed below]


> On May 29, 8:55 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
<snip>[vbcol=seagreen]
> Please find below the script file, the sedscript.txt file and output
> below:
>
> 1.script file
>

<snip>
> #subscription distribution
> cd /root/cs3/report_pool

<snip>
> sed -f sedscript.txt gd.xml

<snip>
> sed: Couldn't open file sedscript.txt
>


Is "sedscript.txt" in the directory "/root/cs3/report_pool"? You may
want to use the full path....

Ed.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com