Reputation: 19
I am trying to write a little project thing to get my javascript skills up. The goal is for, when using curln
, the .cmd
file will write %~dp0\#temp
with the curl %1
(the curled html result of the first parameter)
expected with curln "https://www.google.com"
: (long html)
actual: "<< was unexpected at this time.
"
I have tried looking things up, this was a mesh of what I found online. I have tried using <
and <<
as, a beginner, I don't understand the difference.
Code:
%~dp0\#temp << cmd curl %1
I would like the output of curl to be written to the current directory's (%~dp0
) file named #temp
. %1
is a preset *.cmd
parameter variable that is shown in this example:
example "this is %1"
Upvotes: 0
Views: 188
Reputation: 125661
>
and >>
are output. The first creates a new file, the second appends to an existing file. <
is input. It accepts input (reads) into a program from another source, which is typically a file or the output of another program. It doesn't work with writing to files.
You're most likely looking for curl %1 >>"%~dp0#temp"
instead. You don't need the cmd in front of it, as you're already in a command window when the batch file executes.
Upvotes: 1
Reputation: 11728
For a simple transfer I use repeatedly using curl the minimal call is
curl -o "%~dpnx0" remote.url
That ensures the fileName and eXtension are saved in the current DrivePath
There is no error checking or security communication so is only useful for a single .html or .js or .pdf etc.
Thus a complex call can run to dozens of lines.
Upvotes: 0