bash:

#!/bin/bash

DOMAIN=mydomain.com

for client in ServerA ServerB ServerC ServerD
do
xhost +$client.$DOMAIN
done


MS-DOS:
@echo off
for..... crap.....

I can't seem to get the for loop to work properly. Has anyone had much experience with batch files in DOS? I realize that running xhost inside of a batch file sounds silly, but there is a need for it in this situation. :)

I wouldn't doubt if the first response is RTFM, or whatever, but there is no "man" in ms-dos, and doing "for /?" didn't help at all. :)

Hi I think the following should work:

SET DOMAIN=mydomain.com
FOR %%A IN (ServerA ServerB ServerC ServerD) DO xhost +%%A%.%DOMAIN%

You may need to play with it a little to get it working exactly right but that is the basic syntax.

HTH

Ben

That yields the same problem that I was having:

%%A was unexpected at this time.

That yields the same problem that I was having:

%%A was unexpected at this time.

Hmmmm running on windows XP that works fine, what version of windows are you using?

Additionally is this from a bat file or are you testing on the commandline? On the command line %%A becomes %A.

From checking for / do on commandline requires an NT class OS.

Using Windows 2000 server. I was testing it at the command line. That was the problem. Thanks!

NP glad to help.

Ben

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.