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.
THanks,
Jerry
On Fri, Mar 7, 2008 at 10:35 AM, Jerry Geis geisj@pagestation.com 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 for@F' /tmp/cmdline 192.168.1.8 $
Obviously, you should use /proc/cmdline instead of the file in /tmp as I used. Filipe
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 geisj@pagestation.com 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.
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
2008/3/7, Alfred von Campe alfred@von-campe.com:
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!
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
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.
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.
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://%5C(.*%5C)/ks/.*,%5C1,'
Jim
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://%5C(.*%5C)/ks/.*,%5C1,'
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.