Monitoring Splunk

Using windows batch file to run search on CLI

quahfamili
Path Finder

Hi,

I was trying to use window batch file to run CLI search command.

The command is something like this:
splunk search "index=xx |eval xx| table xx xx xx" -output csv c:\test.csv

This cmd like works when I manually key in on cmd prompt, but when I saved the file as a batch files or *.cmd, the command will only run : splunk search "index=xx

I know the pipe in cmd needs to be escaped using caret (^|). However, it is not working even when I added the caret.

Thanks in advance.
AQ

Tags (2)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Give this a try

start "" CALL 'splunk.exe search "index=xx |eval xx| table xx xx xx" -output csv c:\test.csv'

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Give this a try

start "" CALL 'splunk.exe search "index=xx |eval xx| table xx xx xx" -output csv c:\test.csv'
0 Karma

quahfamili
Path Finder

Anyone have any ideas?

0 Karma

nickhills
Ultra Champion

Do you have anything in your batch file to login as a Splunk user before running this command?

If my comment helps, please give it a thumbs up!
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...