Reputation: 47
I use a cURL command stored in .bat file.
I want to have variables implemented in the command, that will receive the value when I call the command to execute the .bat file.
Can anybody help with understading the syntax of:
Here is my cURL command (Parts in bold should be variables):
curl -k --user "usercode:" -d source="https://secure.4log.com/**431032**" https://api.pdfshift.io/v2/convert/ -d sandbox=true --output C:\Users\administrator\Desktop\**testpdf11**.pdf
Upvotes: 0
Views: 10289
Reputation: 56228
Parameters to the batchfile are referenced by %1
for the first one, %2
for the second one and so on until %9
This makes your command:
curl -k --user "usercode:" -d source="https://secure.4log.com/%~1" https://api.pdfshift.io/v2/convert/ -d sandbox=true --output C:\Users\administrator\Desktop\%~2.pdf
Note: use %~1
to remove surrounding quotes (no effect, if there aren't such)
You might want to check if there are at least two parameters before with:
if "%~2"=="" (echo you need two parameters & goto :eof )
(Maybe even add some plausibility tests)
Upvotes: 1
Reputation:
If you want to send parameters you simply use:
curl %1 %2 %3
Each numeric value defines the position of the word after your batch.
so as a simple example, if you run only need to run something like:
mybatch.bat 1234 5678
That 1234
will be seen as %1
and 5678
will be %2 and you will get:
source="https://secure.4log.com/%1" C:\Users\administrator\Desktop\%2.pdf
resulting to:
source="https://secure.4log.com/1234" C:\Users\administrator\Desktop\5678.pdf
If you plan on using paramters with space, or any quoted text for that matter, you should rather use %~1
and %~2
as it will remove the quotes for you.
Upvotes: 1