Moirsky
Moirsky

Reputation: 68

Curl call working in cmd but not in .bat

Following code is working perfectly fine when ran from cmd, but it fails (Access Denied) when ran as bat from Pentaho DI.

curl -k --data "data=username%%3[DUSERNAME]%%26password%%3D[PASSWORD]%%26pid%%3D[1]%%26lid%%3D[2]" https://[...]/export/csv.php -o [...]\output.csv

Anything specific I should be aware of? Assuming the issue lies in credentials part.

Upvotes: 1

Views: 3600

Answers (2)

Christian.K
Christian.K

Reputation: 49300

The problem is that the %<number> parts are interpreted as the arguments to the batch file %1, %2, ...

You can simply double all % characters to escape them:

curl -k --data "data=username%%%%3[DUSERNAME]%%%%26password%%%%3D[PASSWORD]%%%%26pid%%%%3D[1]%%%%26lid%%%%3D[2]" ...

Upvotes: 7

Moirsky
Moirsky

Reputation: 68

I have managed to fix it by creating external .bat file and calling it with Pentaho's Shell function. Previously I was implementing the code inside Pentaho (it creates then temp .bat file on run time).

Upvotes: 1

Related Questions