Deployment Architecture

--data-urlencode doesn't work on linux. Is there an alternative?

shantu
Explorer

I'm using curl to export some csv data from Splunk using the REST API. The curl command is below:

curl --get -s -u admin:pwd -k https:localhost:8088/servicesNS/admin/search/search/jobs/export -d output_mode=csv --data-urlencode search="search index=* sourcetype="log4j" | rex field=_raw ".ERROR\s+(?.)\n | top limit=20 ErrorMessage" -o aggregatedErrors.csv

It works fine on cygwin, but my linux boxes say "curl: option --data-urlencode: is unknown" (because in fact, it isn't an option when I look under curl --help). What's the alternative? Is there a way to encode this on linux/mac terminals as well?

Tags (3)
1 Solution

chanfoli
Builder

What version of curl are you running?

curl --version

--data-urlencode was added around v 7.18.0 before 2010 I believe. If you have a previous version, is upgrading curl an option?

-Sean

View solution in original post

chanfoli
Builder

What version of curl are you running?

curl --version

--data-urlencode was added around v 7.18.0 before 2010 I believe. If you have a previous version, is upgrading curl an option?

-Sean

shantu
Explorer

Good question Sean. I should have mentioned in my post. The version is definitely the issue. My Cygwin instance is using 7.39.xx while my linux boxes have 7.15.xx. Unfortunately, I'm a non-root user so upgrading curl isn't an option.

0 Karma

chanfoli
Builder

Hmm, in that case you may want to look at doing it with perl. Hopefully URI::escape is installed. There are several ideas in this thread:

http://stackoverflow.com/questions/296536/urlencode-from-a-bash-script

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 ...