Need help with BASH to MS-DOS Batch conversion.

Reply

Join Date: Mar 2004
Posts: 209
Reputation: i686-linux is on a distinguished road 
Solved Threads: 12
i686-linux's Avatar
i686-linux i686-linux is offline Offline
Posting Whiz in Training

Need help with BASH to MS-DOS Batch conversion.

 
0
  #1
Apr 29th, 2004
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.
PARANOIA:
A healthy understanding of the way the universe works.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 113
Reputation: liliafan is on a distinguished road 
Solved Threads: 2
liliafan's Avatar
liliafan liliafan is offline Offline
Junior Poster

Re: Need help with BASH to MS-DOS Batch conversion.

 
0
  #2
May 2nd, 2004
Hi I think the following should work:
Shell Scripting Syntax (Toggle Plain Text)
  1.  
  2. SET DOMAIN=mydomain.com
  3. 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
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 209
Reputation: i686-linux is on a distinguished road 
Solved Threads: 12
i686-linux's Avatar
i686-linux i686-linux is offline Offline
Posting Whiz in Training

Re: Need help with BASH to MS-DOS Batch conversion.

 
0
  #3
May 3rd, 2004
That yields the same problem that I was having:

%%A was unexpected at this time.
PARANOIA:
A healthy understanding of the way the universe works.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 113
Reputation: liliafan is on a distinguished road 
Solved Threads: 2
liliafan's Avatar
liliafan liliafan is offline Offline
Junior Poster

Re: Need help with BASH to MS-DOS Batch conversion.

 
0
  #4
May 3rd, 2004
Originally Posted by i686-linux
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.
Application development, webhosting, and much more: www.webcentric-hosting.com
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 209
Reputation: i686-linux is on a distinguished road 
Solved Threads: 12
i686-linux's Avatar
i686-linux i686-linux is offline Offline
Posting Whiz in Training

Re: Need help with BASH to MS-DOS Batch conversion.

 
0
  #5
May 3rd, 2004
Using Windows 2000 server. I was testing it at the command line. That was the problem. Thanks!
PARANOIA:
A healthy understanding of the way the universe works.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 113
Reputation: liliafan is on a distinguished road 
Solved Threads: 2
liliafan's Avatar
liliafan liliafan is offline Offline
Junior Poster

Re: Need help with BASH to MS-DOS Batch conversion.

 
0
  #6
May 3rd, 2004
NP glad to help.

Ben
Application development, webhosting, and much more: www.webcentric-hosting.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC