Pentaho execute shell component not working for CURL - shell

I'm trying to download a file to my local path from Azure Storage Account.
CURL command works fine on command prompt but it's not working from Pentaho execute shell component
curl -H "x-ms-version: 2017-11-09" -X GET "STORAGE_ACCOUNT_NAME/BLOBNAME?STORAGE_ACCOUNT_KEY" -o "C:/Users/FileName8.txt"
I'm getting below error from pentaho
{"error":{"code":"AuthenticationFailed","message":"Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:65018b37-401f-0021-5f01-2fe938000000\nTime:2023-01-23T08:03:18.5896810Z"}}
expecting CURL to work same as CMD

Related

curl in windows read function returned funny value

I am using the following command to upload file to an endpoint
curl -X POST -H "authorization: Basic base64encode" -H "Content-Type:
multipart/form-data" -H "X-Atlassian-Token: nocheck" -F
"file=#c:/Users/User/Desktop/testresults.xml" https://jira.test-
server.ag/rest/api/latest/issue/man-287/attachments
the command under mac works without problems, under windows I become the following error
curl: (26) read function returned funny value
curl version
curl 7.64.0 (x86_64-w64-mingw32) libcurl/7.64.0 OpenSSL/1.1.1a
installed using https://chocolatey.org
I ran into the same problem when I used curl on the Windows Subsystem for Linux on Windows 10. I had to change the path from C:\Temp\File.txt to /mnt/c/Temp/File.txt.
Check if you can access the file in your shell e.g. with dir c:\path\to\file.txt and if it fails then you know that you have to fix the path first.

java.io.IOException: Cannot run program "cmd"

I am running below code in jenkinsfile. Currently we have 1450 xml files which we send to webserver for validation with below command it runs 140 times for each xml file we have.
String responseFile = bat(returnStdout: true,
script: "curl --header \"Content-Type: text/xml;charset=UTF-8\"
--header \"MAXAUTH: ${env_auth['envname']}\"
--header \"SOAPAction:urn:processDocument\" --data-binary $str $url").trim()
It works fine sometime but failing with below error most of the time.
java.io.IOException: Cannot run program "cmd" (in
directory "c:\directory_name"): CreateProcess error=5,
Access is denied
Could you guys please help with this?
You need to configure the command prompt in Jenkins, including the command in% PATH%. On the folder, you need to give write and execute permission to the user who is running jenkins.

Twilio-call bash script returns 404 NOT FOUND

I have a paid twilio account with verified number and am trying to use the bash script supplied by twilio entitled "twilio-call" on Ubuntu 16.04.3 LTS. The response is: Failed to call 941-8XX-XXXX: curl (22): The requested URL returned: 404 NOT FOUND.
I know that I have the credentials set correctly as the bash script entitled "twilio-sms" works flawlessly.
The bash script "twilio-call" has been downloaded directly from twilio.com/labs/bash and the permissions have been set correctly.
The actual curl command is:
RESPONSE=curl -fSs -u "$ACCOUNTSID:$AUTHTOKEN" -d "Caller=$CALLERID" -d "Called=$PHONE" -d "Url=http://twimlets.com/message?Message=$MSG" "https://api.twilio.com/2008-08-01/Accounts/$ACCOUNTSID/Calls" 2>&1
The variables $ACCOUNTSID, $AUTHTOKEN, $CALLERID, $PHONE, and $MSG have all been verified to be populated correctly.
What could be causing this 404 response? Am I correct in my understanding that a verified number from twilio which works correctly for sms should also work for call?
It must be some old example at Twilio. Where did you find it?
The API endpoint URL it's not
https://api.twilio.com/2008-08-01/Accounts/$ACCOUNTSID/Calls
it is
https://api.twilio.com/2010-04-01/Accounts/$ACCOUNTSID/Calls

"'resource' is not recognized as an internal or external command" while POSTing using Web Service API in SonarQube 5.1.2

I am using SonarQube 5.1.2 on Windows 7 Professional. I am using Web Service API over cURL 7.32.0 (x86_64-pc-win32). I want to upload sonar.exclusions and few more such properties for a specific project using POST.
I use curl -u admin:admin -X POST http://localhost:9512/api/prop
erties/?id=sonar.exclusions -v -T "D:\sonar-exclusions.xml" and I am able to POST it as global sonar.exclusions.
Where as if I use resource to post it to a specific project with the command - curl -u admin:admin -X POST http://localhost:9512/api/prop
erties/?id=sonar.exclusions&resource=org.myProject:myProject -v -T "D:\sonar-exclusions.xml" I get the error {"err_code":200,"err_msg":"property created"}'resource' is not recognized as an
internal or external command, operable program or batch file
What's going wrong with the resource parameter here?
The problem is with the & in the URL, it's interperted by your command line prompt as: Let me run this command:
curl -u admin:admin -X POST http://localhost:9512/api/properties/?id=sonar.exclusions
and then run this command:
resource=org.myProject:myProject -v -T "D:\sonar-exclusions.xml"
The first one returns {"err_code":200,"err_msg":"property created"} while the second one is bound to fail with:
'resource' is not recognized as an internal or external command, operable program or batch file
You should either escape the & or simply put the URL between "quotes".

cURL to call REST Api

So I want to call a REST API from Bamboo after a deployment has completed.
This API needs a username and password but it can't be stored in Bamboo as it seems it can be viewed in the Bash History of the Build agent.
I intended to use a script task and execute something like
curl -f -v -k --user "${bamboo.user}":"${bamboo.password}" -X POST https://bamboo.url/builds/rest/api/latest/queue/project_name"/
This would make the REST call. But the username and password is a problem.
I do have the option, however of using a PEM file. It can be provided so does anyone know if this can be used in conjunction with the cURL?
--OR--
One other thought- could I encrypt a password within a file in my source control, and somehow decrypt it on the build agent, and then have curl use the file instead of reading the password from the command line? How would this look in cURL?
Any ideas how this could be achieved?
Your command seems to have an extra quote at the end of your command
Using a pem file to authenticate with curl:
curl -E /path/to/user-cert.pem -X POST https://bamboo.url/builds/rest/api/latest/queue/project_name
The file should have both private key and public key inside.

Resources