Help with fetching a command from a remote text-file.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Enigma_
Posts: 2
Joined: 17 Sep 2011 17:07

Help with fetching a command from a remote text-file.

#1 Post by Enigma_ » 17 Sep 2011 17:23

For some reason, this code:

Code: Select all

for /f "delims=" %a in ('URL2FILE http://www.website.com/file.txt ^| findstr /v "linux"') do @%a

Works perfectly fine from the command line, but will fail when I use it in a batch file. :s

Basically it's supposed to fetch the file's contents, and feed them into the variable and the variable is executed as a line of code.

So, for example, I could use this in an simple auto-updator for a program, or client.
This would fetch the code from the file which would instruct the batch file to download the new file version, or the current dependencies.
This could also be used to fetch 'users' from a list.
There are a few other things it could be used for, but they're moot.


Essentially, I'm just looking for some insight as-to why it doesn't seem to work in a batch file.
As well as a fix, if possible.
If not, I'd be immensely appreciative if somebody could provide an ulterior means of accomplishing what I'm aiming for.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Help with fetching a command from a remote text-file.

#2 Post by dbenham » 17 Sep 2011 19:46

The answer is in the HELP contents (relevant part highlighted in blue):

>HELP FOR
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

%variable - Specifies a single letter replaceable parameter.
(set) - Specifies a set of one or more files. Wildcards may be used.
command - Specifies the command to carry out for each file.
command-parameters - Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable.
Variable names are case sensitive, so %i is different
from %I.

etc....



Dave Benham

Enigma_
Posts: 2
Joined: 17 Sep 2011 17:07

Re: Help with fetching a command from a remote text-file.

#3 Post by Enigma_ » 20 Sep 2011 16:29

Thank you for your help.
I've got to say, I feel very...Foolish. >_<

I guess it was a simple mistake, but apparently the people on these forums are patient enough to deal with me. :)

Once again, thank you!

Post Reply