I can get the kickstart command line with /proc/cmdline it looks something like xxxxx ks=http://192.168.1.8/ks/ks.cfg xxxxxx in the %pre sections of my ks.cfg I was wanting to extract the IP from the ks= part. I was going to utilize the "tr" command but its not available in %pre. how can I go about extracting the IP address from with in the %pre section I was going to do something like: cat /proc/cmdline | tr ' ' '\n' | grep ks=http | tr '/' ' ' | awk {' print $2'} Since tr isnt available how else can I do it? Thanks, Jerry
>how can I go about extracting the IP address from with in the %pre section > >I was going to do something like: >cat /proc/cmdline | tr ' ' '\n' | grep ks=http | tr '/' ' ' | awk {' >print $2'} > >Since tr isnt available how else can I do it?Jerry, You ever solve this? You can do this all with awk alone.
On 2011-08-13 04:26, Jerry Geis wrote:> I can get the kickstart command line with /proc/cmdline > > it looks something like xxxxx ks=http://192.168.1.8/ks/ks.cfg xxxxxx > in the %pre sections of my ks.cfg I was wanting to extract the IP from > the ks= part. > I was going to utilize the "tr" command but its not available in %pre. > > how can I go about extracting the IP address from with in the %pre section > > I was going to do something like: > cat /proc/cmdline | tr ' ' '\n' | grep ks=http | tr '/' ' ' | awk {' > print $2'} > > Since tr isnt available how else can I do it? >This one should work in sh environment KS_IPADDR=`< /proc/cmdline sed 's/ /\n/g' | grep "ks=http" | cut -d/ -f3` /Thomas
>Since tr isnt available how else can I do it?Check out page 21 of this pdf: http://www.redhat.com/promo/summit/2010/presentations/summit/decoding-the-code/wed/cshabazi-530-more/MORE-Kickstart-Tips-and-Tricks.pdf Interesting, while the awk solution is more appropriate for your need, this can make it easier and allow for other options: echo $ks |cut -d'/' -f3 after running the above...