- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: SED 4.x broken?
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
Discussions
Discussions
Forums
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
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
тАО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
- 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
- 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
- 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
- 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 :-(