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
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 guptasachin1112mrt@gmail.com 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
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 kbarry@tunein.com 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 guptasachin1112mrt@gmail.com
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
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 https://github.com/vertiginous/ruby-wmi or wmi-lite
https://github.com/opscode/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
http://msdn.microsoft.com/en-us/library/aa394245(v=vs.85).aspx.
Thanks,
Brandon
On Tue, Jan 13, 2015 at 7:24 PM, Sachin Gupta guptasachin1112mrt@gmail.com
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 kbarry@tunein.com 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 guptasachin1112mrt@gmail.com
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