[chef] Re: Re: Converting batch script to chef


Chronological Thread 
  • From: Brandon Raabe < >
  • To:
  • Subject: [chef] Re: Re: Converting batch script to chef
  • Date: Tue, 13 Jan 2015 20:26:18 -0800

Disclaimer: I'm not much of a windows guy

What you've suggested will work, and there's nothing technically 'wrong' with doing it that way. However, in my opinion it is something to avoid if better options exist. In this case, I would probably look into finding and setting the data you want to manipulate using ruby code via one of the WMI gems (e.g., ruby-wmi or wmi-lite). I have some ruby and chef experience so I might try and and wrap it all up in an LWRP, if it made sense.

Here's the WMI reference page I was able to find for Win32_PageFileSetting.


Thanks,

Brandon

On Tue, Jan 13, 2015 at 7:24 PM, Sachin Gupta < " target="_blank"> > wrote:
This portion of code in batch will search for any instance with c:/ in pagefileset  list and based on the output will eitther set CurrentInitialPagingFileSizeMBC/CurrentMaximumPagingFileSizeMBC or goto another label
FindCurrentPagingFileSettingsP.

In my current environment, there are two instances of pagefile one in c: and another in p:

Thanks
Sachin

On Tue, Jan 13, 2015 at 8:18 PM, Kenneth Barry < " target="_blank"> > wrote:
Can you tell us in lay mans terms what that script accomplishes? There is a chance this is either done in another cookbook, or it would be better to create an lwrp.

Sent from my iPhone

> On Jan 13, 2015, at 6:15 AM, Sachin Gupta < " target="_blank"> > wrote:
>
> Hello,
>
>  I am trying to convert a windows batch script into chef script.  The sample  code is like below
>
> :FindCurrentPagingFileSettingsC
>     wmic pagefileset list | findstr /i /c:"c:">nul
>         if not {%errorlevel%}=={0} set NoPagingFileC=true&goto :FindCurrentPagingFileSettingsP
>     for /f "tokens=1-10 delims= " %%a in ('wmic pagefileset list ^| findstr /i /c:"c:"') do (
>         set CurrentInitialPagingFileSizeMBC=%%d
>         set CurrentMaximumPagingFileSizeMBC=%%e
>         set CurrentPagingFileC=%%f
>         )
>         if defined CurrentPagingFileC (
>             for /f "tokens=1-10 delims=\" %%a in ('echo %CurrentPagingFileC%') do set CurrentPagingFileCwmic=%%a\\%%b
>             )
>
> I would like to know whether its good to write such code as
>
> batch "FindCurrentPagingFileSettingsC" do
> code <<-EOH
> ##  here come the code
> EOH
> end
>
>  or first try to learn some ruby stuff and then write code in ruby. I am new to ruby .
>
> Any help would be great.
>
>
> Thanks & Regards,
> Sachin Gupta
>





Archive powered by MHonArc 2.6.16.

§