<?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: Why my CLI query returns empty field values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272366#M81985</link>
    <description>&lt;P&gt;I'm thinking it has to do with the time picker.  In web ui you probably have all time selected but it doesn't appear you're specifying a time in cli and I don't know what it defaults to.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Sep 2016 20:05:48 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-09-10T20:05:48Z</dc:date>
    <item>
      <title>Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272364#M81983</link>
      <description>&lt;P&gt;My query works from Splunk Web UI and returns field values of &lt;CODE&gt;Source&lt;/CODE&gt; in a &lt;CODE&gt;table&lt;/CODE&gt; form, but it doesn't work from the CLI.  &lt;/P&gt;

&lt;P&gt;Splunk web returns &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Source 
==========
stock
funds
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk CLI returns output EMPTY&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Source
===========
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk CLI doesn't returns the field values with the table command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk search "index=apps sourcetype=weblogs | rex field=_raw \'Source:\s(?&amp;lt;Source&amp;gt;.*)\' | search Source | dedup Source | table Source"  user admin password changeme
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried with &lt;CODE&gt;eval&lt;/CODE&gt; and &lt;CODE&gt;fields&lt;/CODE&gt; command instead of &lt;CODE&gt;table&lt;/CODE&gt;  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk search "index=apps sourcetype=weblogs | rex field=_raw \'Source:\s(?&amp;lt;Source&amp;gt;.*)\' | search Source | dedup Source | eval chicken=Source | fields chicken"  user admin password changeme
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but still it output empty values&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chicken
===========
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it works well in web search results&lt;/P&gt;

&lt;P&gt;Is there any other way to display the field values from command interface ? &lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 18:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272364#M81983</guid>
      <dc:creator>vkakani60</dc:creator>
      <dc:date>2016-09-10T18:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272365#M81984</link>
      <description>&lt;P&gt;What search &lt;EM&gt;exactly&lt;/EM&gt; are you running successfully in the search bar?  Sounds like a quoting issue in the shell.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 18:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272365#M81984</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-09-10T18:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272366#M81985</link>
      <description>&lt;P&gt;I'm thinking it has to do with the time picker.  In web ui you probably have all time selected but it doesn't appear you're specifying a time in cli and I don't know what it defaults to.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 20:05:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272366#M81985</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-09-10T20:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272367#M81986</link>
      <description>&lt;P&gt;Maybe Your search should start with the search command?&lt;/P&gt;

&lt;P&gt;splunk search "search ..."&lt;/P&gt;

&lt;P&gt;Also you might want some time modifiers.&lt;/P&gt;

&lt;P&gt;See this reference &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/CLIsearchsyntax"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/CLIsearchsyntax&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 20:09:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272367#M81986</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-09-10T20:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272368#M81987</link>
      <description>&lt;P&gt;Trying to back-pedal from the example you gave from the CLI, I still think your issue is related to shell quoting.  Going back to the updates I gave to your other question, &lt;A href="https://answers.splunk.com/answers/449193/how-to-run-rex-commands-from-cli-mode.html#answer-450021"&gt;https://answers.splunk.com/answers/449193/how-to-run-rex-commands-from-cli-mode.html#answer-450021&lt;/A&gt; ... using &lt;CODE&gt;set -x&lt;/CODE&gt; in the shell prompt helps you see better how shell expansion and quoting rules are affecting what is passed on to Splunk.&lt;/P&gt;

&lt;P&gt;Given what you show above, your most likely to be successful CLI command is probably:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk search 'index=apps sourcetype=weblogs | rex field=_raw "Source:\s(?&amp;lt;Source&amp;gt;.*)" | search Source | dedup Source | table Source'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We wrap the whole SPL command in single quotes &lt;CODE&gt;'&lt;/CODE&gt; because that is the environment where the shell does the LEAST amount of interpretation and replacement.  From the &lt;CODE&gt;bash&lt;/CODE&gt; man page:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Enclosing  characters  in single quotes preserves the literal value ofeach character within the quotes.  A single quote may not occur between single quotes, even when preceded by a backslash.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 10 Sep 2016 21:27:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272368#M81987</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-09-10T21:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272369#M81988</link>
      <description>&lt;P&gt;The more I think about it the more I agree with you!  Seems like last time I did this I made the same mistake and swapped quotes around to fix it.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 22:04:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272369#M81988</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-09-10T22:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272370#M81989</link>
      <description>&lt;P&gt;It doesn't help me in any way. Moreover, if I keep &lt;CODE&gt;"&lt;/CODE&gt; double quote at REX it throws me an error, and &lt;CODE&gt;\"&lt;/CODE&gt; doesn't work for REX anyway. And I am using windows machine cmd prompt, shell and bash don't apt to this scenario ?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 01:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272370#M81989</guid>
      <dc:creator>vkakani60</dc:creator>
      <dc:date>2016-09-12T01:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272371#M81990</link>
      <description>&lt;P&gt;splunk search "search .,. " is not valid command. &lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 01:23:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272371#M81990</guid>
      <dc:creator>vkakani60</dc:creator>
      <dc:date>2016-09-12T01:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272372#M81991</link>
      <description>&lt;P&gt;I have tried with -index_earliest parameter. its display empty field value.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 01:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272372#M81991</guid>
      <dc:creator>vkakani60</dc:creator>
      <dc:date>2016-09-12T01:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272373#M81992</link>
      <description>&lt;P&gt;Oh well now you tell us &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;
Are you doing this in a script?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 02:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272373#M81992</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-09-12T02:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why my CLI query returns empty field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272374#M81993</link>
      <description>&lt;P&gt;It helps you plenty.  If you are running a Splunk CLI search via the Windows CMD prompt, then you need to understand the quoting rules &lt;EM&gt;IT&lt;/EM&gt; uses.  It's the same thing, only different.  When you're using a command line shell to run a command - regardless of what the command line shell is - you are subject to how IT interprets and quotes input before it passes it along to the child process it is starting on your behalf.&lt;/P&gt;

&lt;P&gt;If you are not using CMD, but using PowerShell instead - it may have different quoting rules that you have to account for.&lt;/P&gt;

&lt;P&gt;A quick google search of "windows command prompt quoting rules" brings these resources:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://ss64.com/nt/syntax-esc.html"&gt;http://ss64.com/nt/syntax-esc.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/"&gt;https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/7760545/escape-double-quotes-in-parameter"&gt;http://stackoverflow.com/questions/7760545/escape-double-quotes-in-parameter&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/24173825/what-does-single-quote-do-in-windows-batch-files"&gt;http://stackoverflow.com/questions/24173825/what-does-single-quote-do-in-windows-batch-files&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 18:31:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-my-CLI-query-returns-empty-field-values/m-p/272374#M81993</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-09-12T18:31:42Z</dc:date>
    </item>
  </channel>
</rss>

