- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- SED 4.x broken?
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
10-07-2004 02:14 AM
10-07-2004 02:14 AM
SED 4.x broken?
My SLES8 box runs sed 3.02.80.
My SLES9 box runs sed 4.0.9.
My script tries to identify what the config file for snmp is by checking the cmdline for it in the proc filesystem. The line is this:
SNMP_PID=`cat /var/run/snmpd.pid`
SNMP_CONFIG=`sed -e 's/^.*-c//' -e 's/-r.*$//' /proc/$SNMP_PID/cmdline`
However, use of the ^ & $ don't do anything in SLES9, but in SLES8, it'll strip out everthing before the -c and strip out everything after -r leaving me with the config file for snmp.
Does anyone else have this problem with sed on their systems? Are you all able to use ^ & $? I've tried the sed statement with single and double quotes with no difference...
I'm lost!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-07-2004 07:38 PM
10-07-2004 07:38 PM
Re: SED 4.x broken?
sorry i'm not very good with sed but i have tried your cmdline and it doesn't work on my fedora core 2 (sed 4.0.8).
but i have a workaround for you (i hope you can read it, it's not very nice without tabs):
TEMP_PAR_FILE="/tmp/GetSnmpConfigFile.$$"
NEXT="false"
SNMP_PID='/var/run/snmpd.pid'
rm -f $TEMP_PAR_FILE
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30; do
awk -F '\00' {" print \$$i "} /proc/$SNMP_PID/cmdline >> $TEMP_PAR_FILE
done
for i in `cat $TEMP_PAR_FILE` do
if [ $NEXT == 'true' ]; then
SNMP_CONFIG="$i"
NEXT="false"
fi
if [ $i == '-c' ]; then
NEXT="true"
fi
done
rm -f $TEMP_PAR_FILE
echo $SNMP_CONFIG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-07-2004 07:48 PM
10-07-2004 07:48 PM
Re: SED 4.x broken?
Thank you very much for your suggestion of a work-around!
Unfortunately while sed isn't working with the ^ & $, perl does, so I have a workaround already with perl:
perl -p -e "s/^.*-c//; s/-r.*$//" cmdline
I just want to see if this is a sed issue or a SuSE issue. I see that as you have the same problem, I'm guessing the programmers have intentionally removed this functionality...
But why?!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-11-2004 05:02 AM
10-11-2004 05:02 AM
Re: SED 4.x broken?
4.x is interpreting them as metacharacters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-14-2004 02:46 AM
10-14-2004 02:46 AM
Re: SED 4.x broken?
Only that didn't work either :-(
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP