- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed nightmare
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 09:41 AM
03-06-2002 09:41 AM
+ echo
+ 1>> /etc/opt/config/UserConfig.properties
+ set -x
+ sed -e s|^ocmp.config.file.start.*|ocmp.config.file.start=Configitious.xml| /etc/opt/config/UserConfig.properties
+ 1> /tmp/tmp4487
+ echo return code=0 : tempfile=tmp4487 : UserConfig=/etc/opt/config/UserConfig.properties
return code=0 : tempfile=tmp4487 : UserConfig=/etc/opt/config/UserConfig.properties
+ mv /tmp/tmp4487 /etc/opt/config/UserConfig.properties
+ echo return code=0 : tempfile=tmp4487 : UserConfig=/etc/opt/config/UserConfig.properties
return code=0 : tempfile=tmp4487 : UserConfig=/etc/opt/config/UserConfig.properties
+ chown ocmpadm:ocadmin /etc/opt/config/UserConfig.properties
+ chmod 766 /etc/opt/config/UserConfig.properties
script:
echo " " >> $USERPROP
set -x
sed -e "s|^ocmp.config.file.start.*|ocmp.config.file.start=${NEWCONFIG}|" ${USERPROP} > /tmp/tmp$$
echo "return code=$? : tempfile=tmp$$ : UserConfig=$USERPROP"
mv /tmp/tmp$$ $USERPROP
echo "return code=$? : tempfile=tmp$$ : UserConfig=$USERPROP"
Later,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 09:53 AM
03-06-2002 09:53 AM
Re: sed nightmare
Try using the absolute path to sed, /usr/bin/sed.
you can also put the shell in the first line and try,
#!/usr/bin/sh
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:10 AM
03-06-2002 10:10 AM
Re: sed nightmare
the destination file is empty and the tmp$$ file is not created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:12 AM
03-06-2002 10:12 AM
Re: sed nightmare
In scripts always put the full path to ANY command that you call - set , sed , mv ,cp , chown ,chmod etc.
9 time out of 10 it will work ok without this, but err on the safe side.
As Sanjay has said it is also best to define your shell as the first line.
#!/bin/sh
# Script from here down.
Bla bla bla
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:18 AM
03-06-2002 10:18 AM
Re: sed nightmare
only diffrence I saw is, that in the Script you have some variables, which you expanded in your direct call. In this case the type of quotes you use may have impact.
The output seems somewhat disformatted.
Could you attach it ?
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:23 AM
03-06-2002 10:23 AM
Re: sed nightmare
Bill
Just an idea have a look in the root dir or the dir you are running from for the tempfile,
as the echo of the tmpfile is not showing a path
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:27 AM
03-06-2002 10:27 AM
Re: sed nightmare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:27 AM
03-06-2002 10:27 AM
Re: sed nightmare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:39 AM
03-06-2002 10:39 AM
Re: sed nightmare
Your line :-
sed -e "s|^ocmp.config.file.start.*|ocmp.config.file.start=Configitious.xml|" $USERPROP > /tmp/tmp$$
try it with the full path to sed:-
/usr/bin/sed -e "s|^ocmp.config.file.start.*|ocmp.config.file.start=Configitious.xml|" $USERPROP > /tmp/tmp$$
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:46 AM
03-06-2002 10:46 AM
Re: sed nightmare
Have you tried it?
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:50 AM
03-06-2002 10:50 AM
Re: sed nightmare
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:51 AM
03-06-2002 10:51 AM
Re: sed nightmare
Have you tried:-
1. Put your sh as #!/bin/ksh
2. Run ksh -x <scriptname>
It might give an little more info.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:54 AM
03-06-2002 10:54 AM
Solution# cat bastel.txt
#User defined default and start config
#Thu Feb 07 12:02:28 CET 2002
ocmp.config.file.start=7.intro.xml
# cat script
#!/usr/bin/ksh
set -x
export USERPROP=bastel.txt
sed -e "s|^ocmp.config.file.start.*|ocmp.config.file.start=Configitious.xml|" $USERPROP > out$$
mv out$$ weg
# ./script
+ export USERPROP=bastel.txt
+ sed -e s|^ocmp.config.file.start.*|ocmp.config.file.start=Configitious.xml| bastel.txt
+ 1> out12026
+ mv out12026 weg
# cat weg
#User defined default and start config
#Thu Feb 07 12:02:28 CET 2002
ocmp.config.file.start=Configitious.xml
#
Replace OK, rest of file untouched !
????
Any corrupt chars inside the script or the config file, that do not show up with cat ?
Like ^M when transfered from WIN ?
Sorry, no idea, looks OK !
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 10:55 AM
03-06-2002 10:55 AM
Re: sed nightmare
Looks like the sed is working. You don't see the tmp$$ file because it has been moved to $USERPROP
The original $USERPROP has
#User defined default and start config
#Thu Feb 07 12:02:28 CET 2002
ocmp.config.file.start=7.intro.xml
The modified $USERPROP has,
User defined default and start config
#Thu Feb 07 12:02:28 CET 2002
ocmp.config.file.start=Configitious.xml
You have moved the tmp$$ file to $USERPROP over here,
mv /tmp/tmp$$ $USERPROP
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 11:06 AM
03-06-2002 11:06 AM
Re: sed nightmare
Perhaps I am being dense. In the section you
Then you send a single echo into the file, which is why sed doesn't complain that it can't find the file.
So, you run the sed command against a basically empty file and generate a new basically empty file. Unles I'm missing something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 11:14 AM
03-06-2002 11:14 AM
Re: sed nightmare
Very good job Alan.
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 11:20 AM
03-06-2002 11:20 AM
Re: sed nightmare
yea, that was a backup and restore function!
heh!
I changed it to cp... after which!!
Thanks!
Later,
Bill