Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Dos Batch Script Variable Question

Posted on 2009-05-02
16
Medium Priority
?
405 Views
Last Modified: 2012-05-06
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
Comment
Question by:Wandering99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
16 Comments
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 1000 total points
ID: 24288373
For /f "tokens=*" %%a in (filename.txt) do echo myapp %%a
0
 
LVL 1

Expert Comment

by:scubadu123
ID: 24344534
Try this
for /f %%a in (type.txt) do (
   echo myapp %%a
)

Open in new window

0
 
LVL 16

Expert Comment

by:t0t0
ID: 24555582
@echo off
for /f "tokens=*" %%a in (type.txt) do (
   echo myapp %%a
)
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 25219292
I gave the same exact answer on one line instead of 4...

Ok,  I omitted the echo off...
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25219435
Thank you
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25219494
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
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 25219532
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
 
LVL 16

Expert Comment

by:t0t0
ID: 25219546
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
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 25219585
I can understand that in long questions or with long comments...or in opinion questions.
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25219598
or...... in a long list of questions to process......
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25222040
No thank you.
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25260674
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
 
LVL 16

Expert Comment

by:t0t0
ID: 25260725
Okay... I'm backing down.... I didn't see DropBearMod's comment above before posting.

0
 
LVL 16

Expert Comment

by:t0t0
ID: 25260746
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question