RE: [CentOS] parsing /proc/cmdline
On Fri, 2008-03-07 at 11:59 -0500, Ross S. W. Walker wrote: Ross S. W. Walker wrote: Jerry Geis wrote: Hi - I am not an expert at shell script writing. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. Try: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\/.*/\1/'` This will find an IP in between /.../ Actually shorter sed line: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\/.*/\1/'` And shorter still: sed 's/.*\/\(\([0-9]\+\.\)\{3,\}[0-9]\+\).*/\1/' which uses \{3,\} to specify the 3 occurrences of [0-9]\+\. However, I would simply go for something like: sed 's,.*http://\(.*\)/ks/.*,\1,' Jim ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
RE: [CentOS] parsing /proc/cmdline
On Mon, 10 Mar 2008, Jim Wight wrote: On Fri, 2008-03-07 at 11:59 -0500, Ross S. W. Walker wrote: Ross S. W. Walker wrote: Jerry Geis wrote: Hi - I am not an expert at shell script writing. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. Try: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\/.*/\1/'` This will find an IP in between /.../ Actually shorter sed line: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\/.*/\1/'` And shorter still: sed 's/.*\/\(\([0-9]\+\.\)\{3,\}[0-9]\+\).*/\1/' which uses \{3,\} to specify the 3 occurrences of [0-9]\+\. However, I would simply go for something like: sed 's,.*http://\(.*\)/ks/.*,\1,' How about: sed 's|.*\bks=\w\+://\([^/]\+\)/.*|\1|' that would work with nfs, ftp or https as well and would not falsly match another URL in the cmdline. Plus it does not require the hostname to be an IP address. -- -- dag wieers, [EMAIL PROTECTED], http://dag.wieers.com/ -- [Any errors in spelling, tact or fact are transmission errors] ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] parsing /proc/cmdline
It's Saturday A.M, so please forgive me. On Fri, 2008-03-07 at 10:54 -0500, Filipe Brandenburger wrote: On Fri, Mar 7, 2008 at 10:35 AM, Jerry Geis [EMAIL PROTECTED] wrote: If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. A 12 gage shotgun ought to get the job done! Cryptic but does the job: snip Seriously, by the time I got to this thread, answers had flowed like river water, so that left only my perverse sense of humor in play. -- Bill ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] parsing /proc/cmdline
On Fri, Mar 7, 2008 at 10:35 AM, Jerry Geis [EMAIL PROTECTED] wrote: If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. Cryptic but does the job: $ cat /tmp/cmdline option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... $ perl -lane 'm#^ks=.*//((\d+\.){3}\d+)/#print($1)exit [EMAIL PROTECTED]' /tmp/cmdline 192.168.1.8 $ Obviously, you should use /proc/cmdline instead of the file in /tmp as I used. Filipe ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] parsing /proc/cmdline
Hi - I am not an expert at shell script writing. Me neither, Perl is my thing, and with regular expressions this would be trivial. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. This is probably not the best approach, but it should work: awk -F ks= /proc/cmdline '{print $2}' | awk -F / '{print $3}' On the other hand, if I can call awk, I could also call Perl... Alfred ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] parsing /proc/cmdline
2008/3/7, Alfred von Campe [EMAIL PROTECTED]: Hi - I am not an expert at shell script writing. Me neither, Perl is my thing, and with regular expressions this would be trivial. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. This is probably not the best approach, but it should work: awk -F ks= /proc/cmdline '{print $2}' | awk -F / '{print $3}' Sorry for the intromision, but I tried it and didn't work :S Greets! -- -- Open Kairos http://www.openkairos.com Watch More TV http://sebelk.blogspot.com Sergio Belkin - ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] parsing /proc/cmdline
I didn't see the original, so I'm jumping in here... Hi - I am not an expert at shell script writing. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. This should work with bash/ksh or similar shells a=$(cat /proc/cmdline) a=${a##*ks=http://} a=${a%%/*} echo $a -- rgds Stephen ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
RE: [CentOS] parsing /proc/cmdline
Jerry Geis wrote: Hi - I am not an expert at shell script writing. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. Try: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\/.*/\1/'` This will find an IP in between /.../ -Ross __ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof. smime.p7s Description: S/MIME cryptographic signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
RE: [CentOS] parsing /proc/cmdline
Ross S. W. Walker wrote: Jerry Geis wrote: Hi - I am not an expert at shell script writing. If /proc/cmdline looks like option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ... How can I get the 192.168.1.8 out of this cmdline. Try: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([1-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\/.*/\1/'` This will find an IP in between /.../ Actually shorter sed line: # IPADDR=`cat /proc/cmdline | sed 's/.*\/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\/.*/\1/'` When testing the '+' operator initially, it didn't work for me, then it occurred to me to escape it from the shell. I didn't realize bash used '+', need to look that one up. Also this regex isn't so picky about ip address validity, but since it's in kickstart chances are it's a valid ip. -Ross __ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof. smime.p7s Description: S/MIME cryptographic signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos