[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Batch Loop Help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 24
Thread images: 2

File: cmd-dir.gif (12KB, 669x338px) Image search: [Google]
cmd-dir.gif
12KB, 669x338px
Sup /g/,

I have an old Windows machine I need to automate something on, bash and powershell aren't available to me, and I'm not sure how to do what I'm trying to do with only batch scripting available.

essentially, I'd like to have somewhere, in the batch file, in a text file, wherever

arg1 arg2 arg3 etc.

and have the batch file repeatedly execute...

command $arg staticarg anotherstaticarg

...until there are no arguments left.

Yeah, I know I can just do

command $arg1 staticarg anotherstaticarg
command $arg2 staticarg anotherstaticarg
command $arg3 staticarg anotherstaticarg

...but the list of variable arguements is likeky going to change often, so I don't want to do that.

Any ideas /g/?

Should I just install Cygwin and do this in bash?
>>
>>61948642
lrn2goto
>>
why would you waste your time with batch when you already know you can do it in bash?

batch was not meant for this sort of thing.
>>
RTFM
https://en.wikibooks.org/wiki/Windows_Batch_Scripting#FOR
>>
>>61948709
I know, I've just been asked to "not install anything" unless I absolutely have to.
>>
>>61948642

Just kill that NT4 box
>>
>>61948726
This is a stupid idea. You don't understand CMD, aren't really a hot shit programmer. You'll probably wreck shit if you use it.

Install bash & play it safe.
>>
>>61948725
Yeah I've looked at this, but have no idea where to even start, I haven't touched batch in around 20 years.

I'm probably going to just use Windows task scheduler to make a different machine on the network (that has Cygwin) generate a crappy batch file using the...

command $arg1 staticarg anotherstaticarg
command $arg2 staticarg anotherstaticarg
command $arg3 staticarg anotherstaticarg

...method.
>>
>>61948754
2000 Advanced Server, you were close.

It has to do with DNR reporting at the water department.
>>
>>61948759
Haven't used cmd once but maybe you can try this by putting each arg on new line on list.txt.
for /f "tokens=*" %%a in (list.txt) do @command %%a staticarg anotherstaticarg
>>
File: 1501959398238.jpg (544KB, 2953x3508px) Image search: [Google]
1501959398238.jpg
544KB, 2953x3508px
I'm a batch programmer so I think I can help, but you are going to have to give me more to work with because I don't understand what you are trying to achieve here.

Explain in baby steps exactly what you want this script to do and I will post you the code to do it.
>>
>>61948725
>%i is to be used from the command line while %%i is to be used from a batch
Who thought of this?
>>
>>61948806
fixedtext $variabletext fixedtext fixedtext

I'm going to be executing the same command multiple times.

Argument 2 and argument 3 will always be the same.

Argument 1 is dymanic, I'd like to retrieve it from somewhere, I don't care where.
>>
>>61948642
>>>/wsr/
>>
>>61948790
This worked for what I want to do, thanks.
>>
>>61948642

You install a GNU/Linux distro on it so that """old'''''' computer will feel as new again. The you google how bash works and solve your problem in 1 minute.
>>
for /f "delims=" %%X in ('args.txt') do (command %%X staticarg anotherstaticarg)
>>
>>61948882
I'm using gov. provided software on a server I don't own. Said software only runs on Win2k Adv. Server

I already know how bash works :-)
>>
>>61948932
best of luck, anon!
>>
OP if possible, you can run a somewhat limited bash via busybox for windows
https://frippery.org/busybox/

The bash is kinda old, but it beats scripting with Batch.
>>
>>61948964
I've already finished what I was trying to accomplish, this >>61948790 did what I needed.
>>
Irrelevant to OP's question, do you know a batch interpreter that can be run on Linux?
>>
>>61948642
Download busybox.exe and do it in the busybox shell. It's under a megabyte.

>>61949057
$ wine cmd
>>
>>61948820
Don't question it it's microsoft, probablly some weird compatibility issue.
Thread posts: 24
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.