Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch file: <part of command line> was unexpected at this time

Tags:

batch-file

Trying to execute a command inside a batch file and drop the result into a variable.

Here's what I would execute interactively:

curl -d "username=someUser" http://someServer/trusted

The result is a 15-20 character alpha-numeric string.

Here's my attempt at doing same in a batch file:

FOR /f %AA IN('curl -d \"username=someUser\" http://someServer/trusted') DO ECHO %AA

Error returned is:

//someServer/Trusted') was unexpected at this time

I thought I was dealing with some sort of escaping issue, so I added the \ symbols in front of my quotes. From what I've read, the : symobol in http doesn't need to be escaped, but it's interesting to me that's where the failure appears to "start".

Any ideas on this? I'm on Win8.1, FYI

like image 552
Russell Christopher Avatar asked Dec 01 '13 18:12

Russell Christopher


1 Answers

  1. for-variables have one-char-variables (%A instead of %AA)
  2. you missed a space between IN and (
  3. in a batch-file you have to double the percent-signs for the for-variable (%%A instead of %A)
like image 79
Stephan Avatar answered Sep 29 '22 02:09

Stephan