- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed commands not working on HP-UX. Need help.
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
04-15-2010 02:34 AM
04-15-2010 02:34 AM
sed commands not working on HP-UX. Need help.
As part of script to strip off the absolute paths attached to the system commands(like rm, cp, grep etc), i used sed to do the job.
The sed commands i used, which are working fine on Linux, aren't working on HP-UX.
1)
sed -e 's#/usr.[^ ]*/\|/sbin.[^ ]*/\|/bin.[^ ]*/##g' $DEST_DIR/$1 > $DEST_DIR/new_$1
mv $DEST_DIR/new_$1 $DEST_DIR/$1
2)
sed -e "1i'$top'" $DEST_DIR/$1 > $DEST_DIR/new_$1
mv $DEST_DIR/new_$1 $DEST_DIR/$1
3)
sed -e '2i\export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/' $DEST_DIR/$1 > $DEST_DIR/new_$1
mv $DEST_DIR/new_$1 $DEST_DIR/$1
when the script is run, 1) is not returning any error but simply not doing the job. but 2) and 3) are returning errors as below.
error for 2)
sed: Function 1i'#!/usr/bin/ksh' cannot be parsed.
error for 3)
sed: Function 2i\export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ cannot be parsed.
Please let me know where i am doing it wrong.
Any help is appreciated.
FYI : the actual script is attached.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 05:08 AM
04-15-2010 05:08 AM
Re: sed commands not working on HP-UX. Need help.
without having looked at your script,
don't you think you could avoid the sed stuff
by simply making use of the shell's parameter substitution like e.g.?
$ (elog=/var/opt/resmon/log/event.log;echo ${elog##*/})
event.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 05:14 AM
04-15-2010 05:14 AM
Re: sed commands not working on HP-UX. Need help.
Thanks for your reply.
I am not very good in programming. The initial script i wrote worked fine in Linux. But when it comes to HP-UX the issues started.
I am searching all over google and other forums for a workaround on this. But no luck.
Your help is appreciated.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 06:29 AM
04-15-2010 06:29 AM
Re: sed commands not working on HP-UX. Need help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 08:17 AM
04-15-2010 08:17 AM
Re: sed commands not working on HP-UX. Need help.
I think to understand what you want to achieve.
It looks as though you want to strip all paths from any executables and instead populate the PATH environment and call them just by their names.
Looks like some sort of porting between Unices with executables with deviating paths.
I have to admit that I'm not quite into sed's syntax (pampered too much by PCREs).
So I could only tell you what a Perl regex could remotely look like to strip the paths.
e.g.
perl -npe 's#/(?:usr|bin|sbin)\S*/##g' $DEST_DIR/$1
Sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 08:27 AM
04-15-2010 08:27 AM
Re: sed commands not working on HP-UX. Need help.
You interpreted the script quite right. That is exactly what the script demands.
Fortunately with the help of James, i managed to acheive the results.
Please check this post,
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1421985
Many THnx for your idea in perl, will note it down for future usage. :)
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2010 10:36 AM
04-15-2010 10:36 AM
Re: sed commands not working on HP-UX. Need help.
> http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1421985
> Please check this post,
> http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1421985
So, when I mention it, it's worthless, but
when you suggest it, it's a good idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2010 12:13 AM
04-16-2010 12:13 AM
Re: sed commands not working on HP-UX. Need help.
I am new to the Forums.
If i offended you in some way, then I am ready to offer an unconditional apology.
My intention was never to mark your reply as "Worthless".
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2010 12:32 AM
04-16-2010 12:32 AM