<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with &amp;quot;search&amp;quot; from Windows batch file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13729#M1346</link>
    <description>&lt;P&gt;good, btw i am pulling this out as a "correct" answer, so when you get a chance please "accept" it so people will know it's solved.&lt;/P&gt;</description>
    <pubDate>Mon, 24 May 2010 17:55:39 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2010-05-24T17:55:39Z</dc:date>
    <item>
      <title>Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13722#M1339</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I've got a problem with the execution of this command from a Windows ".bat" script:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;splunk.exe search "| savedsearch test01" -app windows -format csv -auth admin:password &amp;gt; C:\temp\splunklocalhost.csv&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The command &lt;STRONG&gt;works perfectly from a command prompt&lt;/STRONG&gt; (I'm on a Windows Server 2008 Standard).&lt;/P&gt;

&lt;P&gt;Tried also:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;splunk.exe search """| savedsearch test01""" -app windows -format csv -auth admin:password &amp;gt; C:\temp\splunklocalhost.csv&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;and:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;splunk.exe search \"| savedsearch test01\" -app windows -format csv -auth admin:password &amp;gt; C:\temp\splunklocalhost.csv&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;with no luck.&lt;/P&gt;

&lt;P&gt;The suspect is that there is something wrong with the double quotes and that the parameters are not passed correctly (by the Windows command interpreter) to "splunk.exe".&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Thank you very much,
Luca&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 15:22:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13722#M1339</guid>
      <dc:creator>logicasrl</dc:creator>
      <dc:date>2010-05-18T15:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13723#M1340</link>
      <description>&lt;P&gt;do you literally have that exact string in your &lt;CODE&gt;.bat&lt;/CODE&gt; file, or are you using parameter or environment variables anywhere? The correct syntax is to use doubled double-quotes (i.e., your second example). it would also be helpful if you gave the exact error message in each case. you might &lt;EM&gt;also&lt;/EM&gt; try renaming your script to &lt;CODE&gt;.cmd&lt;/CODE&gt; instead of &lt;CODE&gt;.bat&lt;/CODE&gt;, as there is some possibility that it makes a difference in which command processor (&lt;CODE&gt;cmd.exe&lt;/CODE&gt; vs &lt;CODE&gt;command.com&lt;/CODE&gt;) gets invoked, though probably not in W2k8.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 18:33:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13723#M1340</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-18T18:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13724#M1341</link>
      <description>&lt;P&gt;Thank you for the hint.&lt;BR /&gt;
See others trials below...&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 23:01:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13724#M1341</guid>
      <dc:creator>logicasrl</dc:creator>
      <dc:date>2010-05-18T23:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13725#M1342</link>
      <description>&lt;P&gt;The preceding code still does not work.&lt;/P&gt;

&lt;P&gt;The strange thing is that the following works correctly (from within a .bat file):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* splunk.exe search ""host="vmw03n" source="WinEventLog:Security" sourcetype="WinEventLog:Security" earliest_time="-24h""" -format csv -auth admin:password &amp;gt; C:\temp\splunklocalhost.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I will proceed with new tests tomorrow.&lt;/P&gt;

&lt;P&gt;Luca&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 16:50:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13725#M1342</guid>
      <dc:creator>logicasrl</dc:creator>
      <dc:date>2010-05-19T16:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13726#M1343</link>
      <description>&lt;P&gt;I suspect it's because Windows considers the &lt;CODE&gt;|&lt;/CODE&gt; vertical bar to be some kind of delimiter as well even inside the string. Quoting rules are different inside a batch file in some cases (e.g., &lt;CODE&gt;%i&lt;/CODE&gt; vs &lt;CODE&gt;%%i&lt;/CODE&gt; in a &lt;CODE&gt;for&lt;/CODE&gt; statement). You might just try putting a space before the initial &lt;CODE&gt;|&lt;/CODE&gt;. Or you could switch to PowerShell or cscript.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 19:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13726#M1343</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-19T19:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13727#M1344</link>
      <description>&lt;P&gt;SOLVED &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
The solution is to use ".cmd" and NOT ".bat" (at least in Win2008).&lt;BR /&gt;
With a ".cmd" script, there is NO NEED of doubling the double quotes and everything goes smooth.&lt;BR /&gt;
Thank you very much for the hint, gkanapathy &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
Luca&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 19:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13727#M1344</guid>
      <dc:creator>logicasrl</dc:creator>
      <dc:date>2010-05-19T19:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13728#M1345</link>
      <description>&lt;P&gt;The following pulled from comments:&lt;/P&gt;

&lt;P&gt;you might also try renaming your script to .cmd instead of .bat, as there is some possibility that it makes a difference in which command processor (cmd.exe vs command.com) gets invoked - gkanapathy May 18 at 11:33&lt;/P&gt;

&lt;P&gt;SOLVED &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; The solution is to use ".cmd" and NOT ".bat" (at least in Win2008). With a ".cmd" script, there is NO NEED of doubling the double quotes and everything goes smooth. Thank you very much for the hint, gkanapathy &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Luca - logicasrl May 19 at 12:34&lt;/P&gt;</description>
      <pubDate>Sun, 23 May 2010 22:20:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13728#M1345</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-23T22:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13729#M1346</link>
      <description>&lt;P&gt;good, btw i am pulling this out as a "correct" answer, so when you get a chance please "accept" it so people will know it's solved.&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2010 17:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13729#M1346</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-24T17:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "search" from Windows batch file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13730#M1347</link>
      <description>&lt;P&gt;I do have to say, I would have thought that the difference would be gone by Windows 2008. Apparently backwards compatibility is that important to Microsoft.&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2010 17:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-quot-search-quot-from-Windows-batch-file/m-p/13730#M1347</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-24T17:56:57Z</dc:date>
    </item>
  </channel>
</rss>

