943,649 Members | Top Members by Rank

Ad:
Apr 29th, 2004
0

Need help with BASH to MS-DOS Batch conversion.

Expand Post »
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.
Similar Threads
Reputation Points: 87
Solved Threads: 12
Posting Whiz in Training
i686-linux is offline Offline
208 posts
since Mar 2004
May 2nd, 2004
0

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

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
Reputation Points: 66
Solved Threads: 3
Junior Poster
liliafan is offline Offline
117 posts
since Apr 2004
May 3rd, 2004
0

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

That yields the same problem that I was having:

%%A was unexpected at this time.
Reputation Points: 87
Solved Threads: 12
Posting Whiz in Training
i686-linux is offline Offline
208 posts
since Mar 2004
May 3rd, 2004
0

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

Quote 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.
Reputation Points: 66
Solved Threads: 3
Junior Poster
liliafan is offline Offline
117 posts
since Apr 2004
May 3rd, 2004
0

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

Using Windows 2000 server. I was testing it at the command line. That was the problem. Thanks!
Reputation Points: 87
Solved Threads: 12
Posting Whiz in Training
i686-linux is offline Offline
208 posts
since Mar 2004
May 3rd, 2004
0

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

NP glad to help.

Ben
Reputation Points: 66
Solved Threads: 3
Junior Poster
liliafan is offline Offline
117 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: C++ and CGI
Next Thread in Shell Scripting Forum Timeline: Case and loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC