running sed inside script file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers running sed inside script file
# 1  
Old 11-08-2006
running sed inside script file

i am substituting some text in the xml file using sed, on shell directly it works fine, but when i run it inside script file, it say, the function cant be parsed, i think the prob is due to xml file, kindly help
# 2  
Old 11-08-2006
Can you show the script?
# 3  
Old 11-08-2006
script

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="pdosent.xsl"?>
<ENTITLEMENTS>
<HEADER>
<Version>6.0.0.0 (060329a)</Version>
<Date>2006-10-14-09:58:59</Date>
<Server>10.16.12.97</Server>
<Domain>Default</Domain>
<Branches>servers</Branches>
<User>sec_master</User>
<Exclusion>0x00000000 0x00000000 0x00000000</Exclusion>
</HEADER>
<USER>
<Name>tamid</Name>
<DN>cn=pdos user tamid,dc=bsnl,dc=in</DN>
<CN>tamid</CN>
<SN>tamid</SN>
<Desc></Desc>
<GSO>NO</GSO>
<Account>YES</Account>
<Password>NO</Password>
<Group>staff</Group>
<ToD>weekday:anytime:local</ToD>
</USER>
<USER_POLICY>
<Login>
<OBJ></OBJ>
</Login>
<Password>
<OBJ></OBJ>
</Password>
</USER_POLICY>
<Policyspace Name="File">
<OBJ>
<Name>/dev/kazndrv</Name>
<Perm>TR[OSSEAL]rw</Perm>
</OBJ>
<OBJ>
<Name>/dev/rmt0</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/home/ossadmn</Name>
<Perm>TR[OSSEAL]DKNRUdloprwx</Perm>
</OBJ>
<OBJ>
<Name>/home/ossadmn/dummy-passwd</Name>
<Perm>TR[OSSEAL]rw</Perm>
<Attribute>permit:group staff:rw:/usr/bin/vi</Attribute>
</OBJ>
<OBJ>
<Name>/opt/pdos</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdos_pwdrestrict</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdosaudview</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdosdestroy</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdoslpinf</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdoslpmd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdosrefresh</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdosshowmsg</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdossudo</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdostecd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/pdoswhoami</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/rc.lpm</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/rc.pdoslrd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/bin/rc.pdostecd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/etc</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/opt/pdos/etc/lpm.conf</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/etc/pdossudo.conf</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/etc/trace</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/opt/pdos/lib</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/opt/pdos/nls</Name>
<Perm>TR[OSSEAL]DKlrx</Perm>
</OBJ>
<OBJ>
<Name>/tmp/dummy-passwd</Name>
<Perm>TR[OSSEAL]rw</Perm>
<Attribute>permit:group staff:rw:/usr/bin/vi</Attribute>
</OBJ>
<OBJ>
<Name>/usr/bin/ps</Name>
<Perm>TR[OSSEAL]rx</Perm>
</OBJ>
<OBJ>
<Name>/usr/bin/telnet</Name>
<Perm>TR[OSSEAL]rx</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/audit</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/certs</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/cred</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/ffdc</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/hla</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/log</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/login</Name>
<Perm>TR[OSSEAL]Ndlorw</Perm>
<Attribute>permit:any-other:Ndlorw:/opt/pdos/bin/pdos_pwdrestrict /usr/bin/passwd /usr/bin/login /usr/sbin/login /usr/sbin/sshd /opt/ssh/sbin/sshd /usr/lib/ssh/sshd /opt/pdos/bin/pdoslpinf /usr/bin/su /bin/login /usr/local/sbin/sshd /usr/sbin/pure-ftpd /usr/sbin/in.rlogind /usr/sbin/vsftpd /usr/sbin/in.ftpd /usr/lbin/ftpd /usr/lbin/rexecd /usr/sbin/in.rexecd /opt/gnome/bin/gdm /usr/X11R6/bin/xdm /usr/bin/gdm-binary</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/lpm</Name>
<Perm>TR[OSSEAL]Ndlorw</Perm>
<Attribute>permit:any-other:Ndlorw:/opt/pdos/bin/pdos_pwdrestrict /usr/bin/passwd /usr/bin/login /usr/sbin/login /usr/sbin/sshd /opt/ssh/sbin/sshd /usr/lib/ssh/sshd /opt/pdos/bin/pdoslpinf /usr/bin/su /bin/login /usr/local/sbin/sshd /usr/sbin/pure-ftpd /usr/sbin/in.rlogind /usr/sbin/vsftpd /usr/sbin/in.ftpd /usr/lbin/ftpd /usr/lbin/rexecd /usr/sbin/in.rexecd /opt/gnome/bin/gdm /usr/X11R6/bin/xdm /usr/bin/gdm-binary</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/pdosbkup</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/pdoscfg</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/pdoslrd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/pdosteccfg</Name>
<Perm>TR[OSSEAL]r</Perm>
<Attribute>permit:any-other:r:/opt/pdos/bin/pdoswhoami</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/pdostecd</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/tcb</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/tec</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/tracelogs</Name>
<Perm>TR</Perm>
</OBJ>
<OBJ>
<Name>/var/pdos/umsg</Name>
<Perm>TR[OSSEAL]NRdlrw</Perm>
<Attribute>permit:any-other:NRdlrw:/opt/pdos/bin/pdosucfg /opt/pdos/bin/pdoscfg /opt/pdos/bin/pdosctl /opt/pdos/bin/pdoswhoami /opt/pdos/bin/pdoswhois /opt/pdos/bin/pdosshowuser /opt/pdos/bin/pdosrefresh /opt/pdos/bin/pdosdestroy /opt/pdos/bin/pdossudo /opt/pdos/bin/pdosobjsig /opt/pdos/bin/pdosd /opt/pdos/bin/pdoswdd /opt/pdos/bin/pdosauditd /opt/pdos/bin/pdoslpmd /opt/pdos/bin/pdoslrd /opt/pdos/bin/pdoslradm</Attribute>
</OBJ>
<OBJ>
<Name>/var/pdos/uuid</Name>
<Perm>TR</Perm>
</OBJ>
</Policyspace>
<Policyspace Name="NetIncoming">
</Policyspace>
<Policyspace Name="NetOutgoing">
</Policyspace>
<Policyspace Name="Surrogate">
<OBJ>
<Name>/User/ossadmn</Name>
<Perm>TR[OSSEAL]G</Perm>
<Attribute>permit:any-other:G:/opt/pdos/bin/pdossudo</Attribute>
</OBJ>
<OBJ>
<Name>/User/osseal</Name>
<Perm>TR[OSSEAL]G</Perm>
<Attribute>permit:any-other:G:/opt/pdos/bin/pdossudo</Attribute>
</OBJ>
</Policyspace>
<Policyspace Name="Sudo">
<OBJ>
<Name>/kill</Name>
<Attribute>
<Name>Sudo-Command</Name>
<Value>/usr/bin/kill</Value>
</Attribute>
<Attribute>
<Name>Sudo-Invoker-Password</Name>
<Value>"required"</Value>
</Attribute>
<Perm>TR[OSSEAL]x</Perm>
</OBJ>
<OBJ>
<Name>/passwd</Name>
<Attribute>
<Name>Sudo-Command</Name>
<Value>/usr/bin/passwd</Value>
</Attribute>
<Attribute>
<Name>Sudo-Invoker-Password</Name>
<Value>"required"</Value>
</Attribute>
<Perm>TR[OSSEAL]x</Perm>
</OBJ>
</Policyspace>

</ENTITLEMENTS>

this is the xml file i m editing
the sript is
#!/bin/sh
sed 's%<Policyspace Name="File">%/<Policyspace><OBJ><Policy>File</Policy></OBJ>/' pdosent.xml > pdosent1.xml
mv pdosent1.xml pdosent.xml

from shell its working but running it from file is not working
# 4  
Old 11-08-2006
The command in ur script doesn't work even on the command prompt also for me.
Hope you want to substitute all the instances of
<Policyspace Name="File">
with
<Policyspace><OBJ><Policy>File</Policy></OBJ>

The following works for the above ( on command prompt as well as script)

sed 's/Policyspace Name="File"/Policyspace\>\<OBJ\>\<Policy\>File\<\/Policy\>\<\/OBJ/g' pdosent.xml > pdosent1.xml
justsam
# 5  
Old 11-08-2006
sed 's%<Policyspace Name="File">%/<Policyspace><OBJ><Policy>File</Policy></OBJ>%' pdosent.xml > pdosent1.xml
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

sed inside the awk script to replace a string in the array

The requirement is i need to find an array value matching with pattern {5:{ , replace that with 5: and reassign that to same array index and print it. I write something like below and the issue is sed command is not working. If i replace " with "`" the script gives syntax error.how can i... (8 Replies)
Discussion started by: bhagya123
8 Replies

2. Shell Programming and Scripting

Executing sed command inside a bash script

I want to run commands inside a bash script. An example is I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable sed.sh regexp sed.sh "-i \"s/<p>//g\"" then call sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies

3. Shell Programming and Scripting

Using sed to replace inside file

How can I change the comma sign (,) to plus sign (+) with the sed command or any regex? I mean to change only the comma that beteen the quotation marks. From this file: A,B,C A,"B,C",D "A,B",C,D A,B,"C,D" To this file: A,B,C A,"B+C",D "A+B",C,D A,B,"C+D" (6 Replies)
Discussion started by: elior
6 Replies

4. Shell Programming and Scripting

Running a script as root but with different users inside

Hi All, my script.sh has the below lines, and i need to run the script as root or wam. please tell me if this will work #!/bin/bash sudo -t wam /usr/local/wam/stopwam -r ------- this needs run as wam user /usr/local/web/stopweb -a --- this needs to run as... (18 Replies)
Discussion started by: nanz143
18 Replies

5. Shell Programming and Scripting

Running .sh file inside a shell script

Hello, You might help a newbie like me, I am trying to run a .sh inside my shell script. After running that I need to execute below commands. Here's how my scripts looks like. Hope you can help: #!/bin/sh cd $ORACLE_HOME/owb/bin/unix ./OMBPlus.sh ---> goes to OMB+> directory cd... (10 Replies)
Discussion started by: aderamos12
10 Replies

6. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

7. Shell Programming and Scripting

help in running while loop inside a shell script

I have an input file at ./$1.txt with content of seq numbers like : 1234567890 1234589700 . . so on.. I need to take each seq nbr from the input file ,run the query below: select ackname,seqnbr from event where event_text like '%seqnbr( from the input file)' and redirect the... (11 Replies)
Discussion started by: rkrish
11 Replies

8. Shell Programming and Scripting

Running a script from if block inside another script

how do i run a script from if block inside another script? this is what i tried but it doesnt seem to work: if test $a -eq $w then sh /home/scripts/script1.bash fi (3 Replies)
Discussion started by: shishirkotkar
3 Replies

9. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

10. Shell Programming and Scripting

passing variables to sed inside script

I am trying to pass a regular expression variable from a simple script to sed to remove entries from a text file e.g. a='aaaa bbbb cccc ...|...:' then executing sed from the script sed s'/"'$a"'//g <$FILE > $FILE"_"1 my output file is always the same as the input file !! any... (5 Replies)
Discussion started by: Daniel234
5 Replies
Login or Register to Ask a Question