<?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: need to search keyword in specified sourcetype via CLI in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49265#M11796</link>
    <description>&lt;P&gt;Depending upon your goals and level of desired integration with splunk, you might want to consider talking to splunk directly over HTTP at some point via REST at some point.  A lot more work, a lot more power.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Feb 2011 06:51:32 GMT</pubDate>
    <dc:creator>jrodman</dc:creator>
    <dc:date>2011-02-24T06:51:32Z</dc:date>
    <item>
      <title>need to search keyword in specified sourcetype via CLI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49262#M11793</link>
      <description>&lt;P&gt;Im not sure what i am doing wrong... I read the documentation and googled and cannot seem to figure it out. &lt;/P&gt;

&lt;P&gt;Im using Splunk 4.1. If i want to search for specific keyword in specified sourcetype using the web interface, i type the following into the search bar:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;keyword_abc sourcetype=sourcetype_123
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives correct results - i see log entries from &lt;EM&gt;sourcetype&lt;/EM&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;EM&gt;123&lt;/EM&gt; that mention &lt;EM&gt;keyword&lt;/EM&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;EM&gt;abc&lt;/EM&gt;.&lt;/P&gt;

&lt;P&gt;Transforming this to a CLI via SSH, i have:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ssh username@sp.lu.nk.ser /opt/splunk/bin/splunk dispatch 'keyword_abc sourcetype=sourcetype_123' -output csv -auth user:pass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me ALL matches of &lt;EM&gt;keyword&lt;/EM&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;EM&gt;abc&lt;/EM&gt; on all sourcetypes. If i switch the dispatch text around to  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dispatch 'sourcetype=sourcetype_123 keyword_abc'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i get ALL (top 100) lines from &lt;EM&gt;sourcetype&lt;/EM&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;EM&gt;123&lt;/EM&gt; which may or may not include &lt;EM&gt;keyword&lt;/EM&gt;&lt;STRONG&gt;_&lt;/STRONG&gt;&lt;EM&gt;abc&lt;/EM&gt;.&lt;/P&gt;

&lt;P&gt;I tried changing &lt;EM&gt;dispatch&lt;/EM&gt; to &lt;EM&gt;search&lt;/EM&gt;. I tried adding AND and + between source and keyword. I dont know what else to do to get specific keyword in specified sourcetype. Please help!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 05:08:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49262#M11793</guid>
      <dc:creator>smcap</dc:creator>
      <dc:date>2011-02-24T05:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: need to search keyword in specified sourcetype via CLI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49263#M11794</link>
      <description>&lt;P&gt;You're struggling with ssh, not splunk.&lt;/P&gt;

&lt;P&gt;Ssh manually, then test your command.  It should work fine.  &lt;/P&gt;

&lt;P&gt;ssh passes its command off to the shell, which reparses it into tokens.  which means that your single quotes, which got eaten at the ssh invocation time, are long gone.  I'm not an expert on ssh escaping stuff, you might try \'keyword_abc ...\'  but I'm not really sure.  Maybe best practice for ssh is to quote the whole command if possible.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ssh username@sp.lu.nk.ser "/opt/splunk/bin/splunk dispatch 'keyword_abc sourcetype=sourcetype_123' -output csv -auth user:pass"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Obviously that breaks down if the command itself has quotation  marks.&lt;/P&gt;

&lt;P&gt;Anyway this is just a unix shell and ssh behavior thing.  Check with resources in those arenas for best practices, if you have more complex cases to consider.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 05:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49263#M11794</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2011-02-24T05:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: need to search keyword in specified sourcetype via CLI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49264#M11795</link>
      <description>&lt;P&gt;Omg, THANK YOU! Putting quotation marks around the whole ssh command gave me the desired results. This will be transformed into a Perl script, so im not worried about accidental additional quotation marks. This is exactly what i needed for a solution!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 06:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49264#M11795</guid>
      <dc:creator>smcap</dc:creator>
      <dc:date>2011-02-24T06:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: need to search keyword in specified sourcetype via CLI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49265#M11796</link>
      <description>&lt;P&gt;Depending upon your goals and level of desired integration with splunk, you might want to consider talking to splunk directly over HTTP at some point via REST at some point.  A lot more work, a lot more power.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2011 06:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-to-search-keyword-in-specified-sourcetype-via-CLI/m-p/49265#M11796</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2011-02-24T06:51:32Z</dc:date>
    </item>
  </channel>
</rss>

