Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

MS Dos Batch Script Variable Question

Wondering what the syntax is to do this. I have a txt file full of data, each line represents a complete type. I want to use a batch(.bat) script to echo commands in form of

PsuedoCode

scan 1 line from type.txt into %type

while(%type != EOF)
{
    echo myapp %type
}

result in dos window would look like

myapp type
myapp type2
myapp type3
...
etc until end of file
0
Wandering99
Asked:
Wandering99
  • 9
  • 4
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
For /f "tokens=*" %%a in (filename.txt) do echo myapp %%a
0
 
scubadu123Commented:
Try this
for /f %%a in (type.txt) do (
   echo myapp %%a
)

Open in new window

0
 
t0t0Commented:
@echo off
for /f "tokens=*" %%a in (type.txt) do (
   echo myapp %%a
)
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
Lee W, MVPTechnology and Business Process AdvisorCommented:
I gave the same exact answer on one line instead of 4...

Ok,  I omitted the echo off...
0
 
t0t0Commented:
Thank you
0
 
t0t0Commented:
leew

It may be something to do with style. I've seen this happen more than once with Qlemo where my code has been favoured over his cryptic one-liners. It seems as though some askers feel less intimidated by code that actually looks like codethat may bear a closer resemblence to what they may already know.

On occasions, I have had askers reply saying they have learned so much from my code.... So I have stuck to the rule of keeping it simple whenever I can.

I could be wrong though......

 
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
So have I - sometimes I've provided great detail and others I have just provided the code.  USUALLY, I do it based on the perceived skill level of the asker and since the asker had clear programming experience, it didn't seem necessary.

I would request though, with your post coming more than a month after mine, if you want to provide a slightly different syntax, please acknowledge my code and why yours is different/what benefits it may have over mine.
0
 
t0t0Commented:
I'll take your suggestion on board however, sometimes I skip all the comments and head straight for the answer box.... which is what may have happened on this occasion.

0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
I can understand that in long questions or with long comments...or in opinion questions.
0
 
t0t0Commented:
or...... in a long list of questions to process......
0
 
t0t0Commented:
No thank you.
0
 
t0t0Commented:
I can't understand what's going on....

Where in the rules does it state an asker MUST accept the first working solution? Or were they re-assigned to the person who sobbed the loudest!

I find it unpalatable when moderators sneak in behind our backs and take points away from us.

One minute I have points, then the next minute they're gone! - without ANY consultation whatsoever!!

Where is the fairness in that?
0
 
t0t0Commented:
Okay... I'm backing down.... I didn't see DropBearMod's comment above before posting.

0
 
t0t0Commented:
How about re-opening the question and awarding a 334, 333, 333 split with the 334 going to the first solution? Wouldn't that seem much fairer?
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 9
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now