Questions on executing *.sql files in Windows

I want to run the following inside a windows_batch resource

windows_batch “Drop DB” do
sqlcmd -S -db or -U user -P passwork -i DropDB.sql
end

Do I put the DropDB.sql file in my cookbook’s files/default directory? If so the file will end up in c:\chef\cache\cookbooks\mycookbook\files\default directory. Will windows_batch resource know to find it there? If not I may have to do this?

windows_batch “Drop DB” do
sqlcmd -S -db or -U user -P passwork -i c:\chef\cache\cookbooks\mycookbook\files\default DropDB.sql
end

Is there a path known to Chef that I can use to replace c:\chef\cache at least?

Chris

It won’t just find your script.

To reference the file_cache_path, you can use Chef::Config[:file_cache_path]

Steve

Steven Murawski
Community Software Development Engineer @ Chef
Microsoft MVP - PowerShell
http://stevenmurawski.com [http://stevenmurawski.com/]
On 7/15/2015 9:38:17 AM, Fouts, Chris chris.fouts@sensus.com wrote:
I want to run the following inside a windows_batch resource

windows_batch “Drop DB” do
sqlcmd –S -db or -U user –P passwork –i DropDB.sql
end

Do I put the DropDB.sql file in my cookbook’s files/default directory? If so the file will end up in c:\chef\cache\cookbooks\mycookbook\files\default directory. Will windows_batch resource know to find it there? If not I may have to do this?

windows_batch “Drop DB” do
sqlcmd –S -db or -U user –P passwork –i c:\chef\cache\cookbooks\mycookbook\files\default DropDB.sql
end

Is there a path known to Chef that I can use to replace c:\chef\cache at least?

Chris

Thank you!

Chris

From: Steven Murawski [mailto:steven.murawski@gmail.com]
Sent: Wednesday, July 15, 2015 11:05 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Questions on executing *.sql files in Windows

It won’t just find your script.

To reference the file_cache_path, you can use Chef::Config[:file_cache_path]

Steve

Steven Murawski
Community Software Development Engineer @ Chef
Microsoft MVP - PowerShell
http://stevenmurawski.comhttp://stevenmurawski.com/

On 7/15/2015 9:38:17 AM, Fouts, Chris <chris.fouts@sensus.commailto:chris.fouts@sensus.com> wrote:
I want to run the following inside a windows_batch resource

windows_batch “Drop DB” do
sqlcmd –S -db or -U user –P passwork –i DropDB.sql
end

Do I put the DropDB.sql file in my cookbook’s files/default directory? If so the file will end up in c:\chef\cache\cookbooks\mycookbook\files\default directory. Will windows_batch resource know to find it there? If not I may have to do this?

windows_batch “Drop DB” do
sqlcmd –S -db or -U user –P passwork –i c:\chef\cache\cookbooks\mycookbook\files\default DropDB.sql
end

Is there a path known to Chef that I can use to replace c:\chef\cache at least?

Chris