[clue] seeking regex advice

Mike Nolte obiwanmikenolte at gmail.com
Thu Sep 4 10:57:39 MDT 2014


Problem #2 isn't clear to me.  Are the public and gpfs addresses different?
 Your sed command is replacing the existing IP, followed by a space,
then $VMName,
with $publicIP.  You have a g on your sed command; does that mean that
there's more than one instance of this string in /etc/hosts?  Nothing seems
to be addressing a gpfs entry.  What's Invoke-VMScript do?


On Thu, Sep 4, 2014 at 10:46 AM, Dan Kulinski <daniel at kulinski.net> wrote:

> Why no use sed -ire 's/[0-9]{2}\.[0-9]{2}\.[0-9]{2,3}\.[0-9]{2,3} ... ?
>
> This should catch NN.NN.NN.NN, NN.NN.NN.NNN, NN.NN.NNN.NN and
> NN.NN.NNN.NNN.
>
> Good luck.
>
>
> On Tue, Sep 2, 2014 at 9:54 AM, Mike Bean <beandaemon at gmail.com> wrote:
>
>>
>> So I have this script that does deployments of large numbers of virtual
>> machines by cloning from a template and customizing the clone based on the
>> contents of a CSV file.   It's not especially pretty, but the functionality
>> is there, it's pretty solid (sans ONE bug).   It doesn't adjust the ip
>> addresses in /etc/hosts properly.   I was hoping the cluebies might provide
>> some advice.   Our /etc/hosts files look like this:
>>
>> xx.xx.xx.xx (server).domain
>> xx.xx.xx.xx (server)gpfs server.domain
>>
>> the code from the script looks like this:
>>
>> #changes IP addresses in /etc/hosts
>>  $cmd = "sed -i 's/[0-9][0-9].[0-9][0-9].[0-9][0-9].[0-9][0-9] $VMName
>> /$publicIP/g' /etc/hosts"
>> Invoke-VMScript -VM $VMName -GuestUser "root" -GuestPassword $guestPass
>> -ScriptText $cmd -Confirm:$false
>>
>> There's two logical problems I'm trying to solve.
>>
>> Problem#1 is we have two common IP spaces, one of which is xx.xx.xx.xx,
>> and the other is xx.xx.xxx.xxx.  Obviously with the regex the way it is, it
>> only catches xx.xx.xx.xx.
>>
>> Problem#2 is how to adjust the sed command so that it replaces the public
>> line with the public address, and the gpfs line with the gpfs address.
>>
>> I'm kinda scratching my head here trying to figure out a regex that would
>> fit the bill, advice is appreciated.
>>
>> (Oh, distro is RHEL6.3)
>>
>> eep - the longer I look at that, the more I realize that sed is all kinds
>> of messed up.
>>
>> Mike B.
>>
>> _______________________________________________
>> clue mailing list: clue at cluedenver.org
>> For information, account preferences, or to unsubscribe see:
>> http://cluedenver.org/mailman/listinfo/clue
>>
>
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20140904/0df9d370/attachment.html 


More information about the clue mailing list