| | |
Need help with BASH to MS-DOS Batch conversion.
![]() |
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.
#!/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.
PARANOIA:
A healthy understanding of the way the universe works.
A healthy understanding of the way the universe works.
Hi I think the following should work:
You may need to play with it a little to get it working exactly right but that is the basic syntax.
HTH
Ben
Shell Scripting Syntax (Toggle Plain Text)
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
Application development, webhosting, and much more: www.webcentric-hosting.com
•
•
•
•
Originally Posted by i686-linux
That yields the same problem that I was having:
%%A was unexpected at this time.
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.
Application development, webhosting, and much more: www.webcentric-hosting.com
![]() |
Similar Threads
- Executing DOS batch files in Python (Python)
- Question about DOS Batch Files (Legacy and Other Languages)
- Watch out - DOS batch commands ?? (Legacy and Other Languages)
Other Threads in the Shell Scripting Forum
- Previous Thread: C++ and CGI
- Next Thread: Help with SED/AWK email parser
| Thread Tools | Search this Thread |





