Re: Batch scripting, special character
From: Norman Bullen (norm_at_BlackKittenAssociates.com.INVALID)
Date: 09/21/04
- Next message: rykk: "Legecy shared fax"
- Previous message: Mbear: "Batch scripting, special character"
- In reply to: Mbear: "Batch scripting, special character"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 21 Sep 2004 02:19:50 GMT
Mbear wrote:
> I'm tryint to writhe a batch script that needs a < put into the command line
> and I am not getting a succesful ru of the batch. It works fine if I type it
> directly in the command line but it is not working in a batch file.
>
> here is the line that is failing
>
> start /w c:\imail\addalias < c:\files\filename.txt
>
> When I run it form a batch file it is putting a 0 in front of the < and
> erroring out.
>
> How would I get this to wok. Thanks in advance for all the help.
If I understand correctly, you have placed the START command in a .BAT
file and when you run the .BAT you see the command echoed with a "0" in
front of the "<". It appears that you are trying to run one .BAT file as
a "sub-script" of another.
First, the "0" is _not_ a problem. This is normal when a .BAT file is
run and the statement are echoed to the screen. "<" becomes "0<" and ">"
becomes "1>". (The zero and one are the standard file descriptors for
input and output, respectively.)
The reason that your command does not work is that the input redirection
is being interpreted as part of the START command rather than part of
the command to be started. Thus the START command, if it chose to read
from standard input, would read the contents of the file
c:\files\filename.txt. The batch file being started has no standard
input redirection so it probably waits for input from the console when
it wants to read something.
To correct this, change the START statement to:
start /w cmd /c "c:\imail\addalias < c:\files\filename.txt"
This runs the command processor and tells it to run the command on its
invocation line: c:\imail\addalias < c:\files\filename.txt
Now the redirection supplies a standard input for your .BAT file rather
than the START command.
Note that it's probably more efficient to use the CALL command rather
than the START in this situation. START with the /W option waits for the
"external" command to complete just and CALL does but it requires
starting a new instance of CMD. With CALL the statements in the .BAT
file are executed by the same instance of CMD. The equivalent CALL
statement would be
CALL c:\imailaddalias < c:files\filename.txt
The only difference, I think, is that CALL may allow the .BAT file to
change environment variable in the calling script.
Norm
-- -- To reply, change domain to an adult feline.
- Next message: rykk: "Legecy shared fax"
- Previous message: Mbear: "Batch scripting, special character"
- In reply to: Mbear: "Batch scripting, special character"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|