<?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: JavaScript SDK Normal Search in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106789#M22463</link>
    <description>&lt;P&gt;Alright, the Splunk JavaScript SDK is built on top of Node.js &amp;amp; requires it. Node.js is a server-side JavaScript framework, similar in nature to PHP or Ruby on Rails.&lt;/P&gt;

&lt;P&gt;Make sure you have the JS SDK requirements here: &lt;A href="http://dev.splunk.com/view/SP-CAAAED6"&gt;http://dev.splunk.com/view/SP-CAAAED6&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Currently, the SDK only supports up to v0.8.x of Node.js but we're releasing an update mid-August which will support up to v0.10.x. &lt;BR /&gt;
You can download a specific version of Node.js here: &lt;A href="http://nodejs.org/dist/"&gt;http://nodejs.org/dist/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Once installed, you can run JavaScript files from the command line by entering in "node [yourfilename].js" without the quotes.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2013 16:29:25 GMT</pubDate>
    <dc:creator>smohamed_splunk</dc:creator>
    <dc:date>2013-07-26T16:29:25Z</dc:date>
    <item>
      <title>JavaScript SDK Normal Search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106786#M22460</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;
I am trying to create a JavaScript SDK search. I am getting the data I want thru the row and field like so:&lt;/P&gt;

&lt;P&gt;Async.chain([&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            function(done) {
                service.login(done);
            },
            // Perform the search
            function(success, done) {
                if (!success) {
                    done("Error logging in");
                }

                service.search("search XXXXXX | spath YYYYYYY | head 10", {}, done);
            },
            // Wait until the job is done
            function(job, done) {
                Async.whilst(
                    // Loop until it is done
                    function() { return !job.properties().isDone; },
                    // Refresh the job on every iteration, but sleep for 1 second
                    function(iterationDone) {
                        Async.sleep(1000, function() {
                            // Refresh the job and note how many events we've looked at so far
                            job.fetch(function(err) {
                                iterationDone();
                            });
                        });
                    },
                    // When we're done, just pass the job forward
                    function(err) {
                        done(err, job);
                    }
                );
            },
            // Print out the statistics and get the results
            function(job, done) {      
                // Ask the server for the results
                job.results({}, done);
            },
            // Print the raw results out
            function(results, job, done) {
                // Find the index of the fields we want
                var rawIndex = utils.indexOf(results.fields, "YYYYYYY");


                // Print out each result and the key-value pairs we want
                document.write('{"RESULTS":"10", "ZIPS":[');


                for(var i = 0; i &amp;lt; results.rows.length; i++) {
                    if(i&amp;gt;0) document.write(",");
                    //console.log(results.rows[i][rawIndex]);
                    document.write('"'+ results.rows[i][rawIndex] +  '"' );
                    if (i== 9) document.write(']}');
                }

                // Once we're done, cancel the job.
                job.cancel(done);
            }
        ],
        function(err) {;        
        }
    );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want to do is to grab the YYYYY that I am document.write to the page and use it as a JSON file for another page. The problem I am having is I want to import the YYYYY data as a JSON file on my other webpage but I do not know how to write that info into a JSON file. Any help?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2013 18:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106786#M22460</guid>
      <dc:creator>rickshaw12</dc:creator>
      <dc:date>2013-07-25T18:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript SDK Normal Search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106787#M22461</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;

&lt;P&gt;From what I understand, you need help on writing data to a file.&lt;BR /&gt;
What you can do is put all the data you want in a variable, then write it to a file as shown by the top answer &lt;A href="http://stackoverflow.com/questions/2496710/nodejs-write-to-file"&gt;on this Stack Overflow question&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;Instead of passing the "Hey there!" string as the second argument, pass your the data you want written to the file you specify as the first argument.&lt;/P&gt;

&lt;P&gt;-Shakeel&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2013 19:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106787#M22461</guid>
      <dc:creator>smohamed</dc:creator>
      <dc:date>2013-07-25T19:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript SDK Normal Search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106788#M22462</link>
      <description>&lt;P&gt;Thank you very much for the response, I am having difficulties writing to the file though. It is coming up as required not defined when I try to require the variable.I now know that I have to do this not in the browser but I am confused now where to do this because so far I have done everything client side&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 12:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106788#M22462</guid>
      <dc:creator>rickshaw12</dc:creator>
      <dc:date>2013-07-26T12:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript SDK Normal Search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106789#M22463</link>
      <description>&lt;P&gt;Alright, the Splunk JavaScript SDK is built on top of Node.js &amp;amp; requires it. Node.js is a server-side JavaScript framework, similar in nature to PHP or Ruby on Rails.&lt;/P&gt;

&lt;P&gt;Make sure you have the JS SDK requirements here: &lt;A href="http://dev.splunk.com/view/SP-CAAAED6"&gt;http://dev.splunk.com/view/SP-CAAAED6&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Currently, the SDK only supports up to v0.8.x of Node.js but we're releasing an update mid-August which will support up to v0.10.x. &lt;BR /&gt;
You can download a specific version of Node.js here: &lt;A href="http://nodejs.org/dist/"&gt;http://nodejs.org/dist/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Once installed, you can run JavaScript files from the command line by entering in "node [yourfilename].js" without the quotes.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 16:29:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JavaScript-SDK-Normal-Search/m-p/106789#M22463</guid>
      <dc:creator>smohamed_splunk</dc:creator>
      <dc:date>2013-07-26T16:29:25Z</dc:date>
    </item>
  </channel>
</rss>

