Getting Data In

Why does CURL script fails to output when called by Splunk?

aweddell
New Member

Hi Guys,

I'm pulling m hair out trying to get my CURL script to run.

I've set up a scripted input in my app, it calls a bash script which has the line

curl -O -s -H "X-Requested-With: Curl Sample" -b "path=/api; secure" -u "TRUCNATED" "https://TRUNCATED&id=$id"

The script works fine when I call it normally (It dumps XML), however when I try it with
$SPLUNK_HOME/bin/splunk cmd script.sh, nothing happens.

I added an echo statement to the script and that prints normally when I execute it through cmd, however it still wont print the xml. I've tried -o -O > 1>& 2>& to files, variables, etc. It seems that when Splunk calls the script which calls CURL, output fails to work!

Any ideas would be great!

Labels (1)
Tags (3)
0 Karma

rtllaguno
New Member

Same issue encountered when I'm trying to curl Jenkins endpoint to output the Crumb. Does anyone resolved it yet? 

curl -s -u <user|pass> "https://<url>/crumbIssuer/api/json" -o qrMerchant_jenkinsCrumb
0 Karma

jplumsdaine22
Influencer

Is $id is actually set? My guess would be that splunk is running

curl -s -H "X-Requested-With: Curl Sample" -b "path=/api; secure" -u "TRUCNATED"https://TRUNCATED&id="

which probably gives you no body.

0 Karma

stath002
Path Finder

My Curl command is different and if i manually run it as the splunk user it returns the desired results.

0 Karma

stath002
Path Finder

I am having a similar issue. However when I run $SPLUNK_HOME/splunk cmd /path/to/my_curl_script.sh I am getting the following error:

exec(): 0509-036 Cannot load program /usr/bin/curl because of the following errors:
0509-150 Dependent module /opt/splunk/splunkforwarder/lib/libz.a(libz.so.1) could not be loaded.
0509-103 The module has an invalid magic number.

0 Karma

griebn
Engager

I had the same issue getting a curl to fire. Echo out the response code of the curl command ($?) if it is returning (1) then you have an unsupported protocol and need to add to your script:

unset LD_LIBRARY_PATH

Try this, it worked for me.

aweddell
New Member

Sorry, please disregard the -O, thats not actually in there!

0 Karma
Get Updates on the Splunk Community!

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...