Redirected Input in .BAT file

  • Thread starter Thread starter Duncan
  • Start date Start date
D

Duncan

Hi,

I have a .BAT file (moved from my Win98 machine) with the
following line in it:

start /WAIT "C:\Program Files\Joho\release\pro.exe"
<"c:\webpro505.inp"

When I double-click the BAT file, the DOS Window shows
the line as:

start /WAIT "C:\Program Files\Joho\release\pro.exe"
0<"c:\webpro505.inp"

When that line gets executed, another DOS window shows up
(titled ....pro.exe), shows the MS copyright notice and
the correct DOS command prompt. But pro.exe never
executes. If I EXIT from this 2nd DOS window, the batch
script continues with the next line.

pro.exe and webpro505.inp both exist in the right folders.

So where is that mysterious "0" coming from?

TIA
Duncan
 
< and 0< mean the same thing - there is an implied 0 in the first example - type redirection in help for more.

If you type start /? you notice that the syntax of start is slightly different (to 98) if the first term is enclosed in quotes. The first quoted term, if any, becomes the window title.

Try

1/ Use the short file name and lose the quotes or
2/ Stick a window title in - it can be blank.

start /WAIT "My Window Title" "C:\Program Files\Joho\release\pro.exe" <"c:\webpro505.inp"
 
David,
-----Original Message-----
< and 0< mean the same thing - there is an implied 0 in
the first example - type redirection in help for more.
If you type start /? you notice that the syntax of start
is slightly different (to 98) if the first term is
enclosed in quotes. The first quoted term, if any,
becomes the window title.
Perfect. The Title parameter and the change to a "<&"
operator got it all working as it should. Thank you very
much.

This brings up a bigger issue for me. I have VB code
that generates and executes .BAT files using Command.com
as part of the process. Clearly on XP I could use Cmd.exe
instead, as long as I generate Cmd.exe compatible files.

Is there any information from MS about the advisability
(or not) of continuing to use the old command.com? For
example, will this break if I migrate my code to VB.Net?

Thanks,
Duncan
 
Command.com will be around for a few more versions yet. But XP has Dos 5 command.com with one magor difference to real Dos 5. It passes all commands to cmd.exe for execution. So the only way to get command.com to execute Dos 5 commands is via the command line.

command /k <dos 5 command>

Also command doesn't support long file names.

Most programming languages (I'm thinking of Dos ones as the exception) just pass a string to Windows to work out what to do with it. Therefore the language is irrelevent.
 
David,

I said:
Perfect. The Title parameter and the change to a "<&"
operator got it all working as it should. Thank you very
much.

Well I spoke too soon. The "&" just caused a complete
failure. (It was a little hard for me to see the effect
of the failure.)

So now:

start /WAIT "Title" "Prog.exe" <"Input.inp"

starts the program but expects and can accept input from
the keyboard instead of the file, as if the redirected
input was not there.

The Prog.exe file is a recently re-compiled MS Fortran
program. Perhaps that old compiler is incompatible with
cmd.exe?

TIA
Duncan
 
I wondered why you were putting in the ampersand. I thought it was mis-typing.

Does it work if all files are in the same directory and (so) there are no paths to wonder about? If you put prog.exe and input.imp in one folder, change to it and type
prog <input.imp

If this works then the program reads from standard input - redirection only works with standard input (File Handle 0). Typically these are command line programs though non MS Dos commercial programs often had compatability modes to work on non IBM compatible MSDos computers.
 
David,
Does it work if all files are in the same directory and
(so) there are no paths to wonder about? If you put
prog.exe and input.imp in one folder, change to it and
type
prog <input.imp

If this works then the program reads from standard
input -

It works by typing the command line in a DOS window with
the exe and inp files in the current folder, and no paths
specified. It also works if I'm in a completely different
folder and type the command line exactly as it is in
the .BAT file with full path names. So it looks like
STDIN is working.

If I type the name of the .BAT file at the command
prompt, it fails expecting input from the keyboard.

If I create a .BAT file with no path names, it also fails
expecting input from the keyboard when i double click the
BAT file or enter the BAT file name at the command prompt.

Very mysterious.

Thanks again, David.
 
Can you post the entire bat file?
David,

(so) there are no paths to wonder about? If you put
prog.exe and input.imp in one folder, change to it and
type
input -

It works by typing the command line in a DOS window with
the exe and inp files in the current folder, and no paths
specified. It also works if I'm in a completely different
folder and type the command line exactly as it is in
the .BAT file with full path names. So it looks like
STDIN is working.

If I type the name of the .BAT file at the command
prompt, it fails expecting input from the keyboard.

If I create a .BAT file with no path names, it also fails
expecting input from the keyboard when i double click the
BAT file or enter the BAT file name at the command prompt.

Very mysterious.

Thanks again, David.
 
David,
Can you post the entire bat file?

I got it to work, almost, with this .BAT file:

d:
cd "\johodata\stockdb\download03"
start "Title" /WAIT /B "C:\Program
Files\Joho\release\pro.exe" <"c:\webpro505.inp"
pause

Note the /B. Adding /B enabled pro.exe to recognize the
fact that there is a redirected input file. Without
the /B pro.exe wanted input from the keyboard.

/B has the effect of running pro.exe in the same window
that was running the .bat file. Perhaps handle 0 is not
assigned properly if there is a new window for pro.exe.

The downside is that the prompt associated with the PAUSE
command does not appear, although the DOS window does
halt and wait for a keystroke before disappearing.

This will be confusing for my users. But I guess I'm
closer.

Thanks again for all your assistance, David.
Duncan
 
I thought it was something like that.
Duncan said:
David,


I got it to work, almost, with this .BAT file:

d:
cd "\johodata\stockdb\download03"
start "Title" /WAIT /B "C:\Program
Files\Joho\release\pro.exe" <"c:\webpro505.inp"
pause

Note the /B. Adding /B enabled pro.exe to recognize the
fact that there is a redirected input file. Without
the /B pro.exe wanted input from the keyboard.

/B has the effect of running pro.exe in the same window
that was running the .bat file. Perhaps handle 0 is not
assigned properly if there is a new window for pro.exe.

The downside is that the prompt associated with the PAUSE
command does not appear, although the DOS window does
halt and wait for a keystroke before disappearing.

This will be confusing for my users. But I guess I'm
closer.

Thanks again for all your assistance, David.
Duncan
 
Back
Top