Input from a batch file

  • Follow


I work under Linux, and run programs using shell scripts, with data
read directly out of the script, by using something like this

ifort bla.f90
../a.out << eoi
<data1>
<data2>
eoi

A colleague (who doesn't frequent news groups) works under Windows
and wants to do something similar. He already has a compiled
program, e.g. bla.exe and wants to know how to make the batch
process read data directly from the batch file, as my script
does. How is that done?

-- 
Dieter Britz (dieterhansbritz<at>gmail.com)
0
Reply dieterhansbritz (43) 12/14/2011 2:11:06 PM

On Wed, 14 Dec 2011 15:11:06 +0100, Dieter Britz wrote:

> I work under Linux, and run programs using shell scripts, with data
> read directly out of the script, by using something like this
> 
> ifort bla.f90
> ./a.out << eoi
> <data1>
> <data2>
> eoi
> 
> A colleague (who doesn't frequent news groups) works under Windows
> and wants to do something similar. He already has a compiled
> program, e.g. bla.exe and wants to know how to make the batch
> process read data directly from the batch file, as my script
> does. How is that done?

Under Windows the executable is usually given the name of the first
Fortran file, so it would be

bla <eoi

which would read data requested from the default terminal (usually unit 5;
I always use the * as my default terminal). To save default screen output,
try

bla <eoi >my-output.txt

We normally make sure that our files have an extension, so would have

bla <eoi.txt >my-output.txt

You would need to make sure that bla was compiled for command-line prompt
(Windows console) NOT QuickWin or Windows GUI.
0
Reply none3 (1062) 12/14/2011 1:36:55 PM


On 2011-12-14 15:11, Dieter Britz wrote:
> I work under Linux, and run programs using shell scripts, with data
> read directly out of the script, by using something like this
> 
> ifort bla.f90
> ./a.out << eoi
> <data1>
> <data2>
> eoi
> 
> A colleague (who doesn't frequent news groups) works under Windows
> and wants to do something similar. He already has a compiled
> program, e.g. bla.exe and wants to know how to make the batch
> process read data directly from the batch file, as my script
> does. How is that done?
> 

You can - at the very least - do that as follows:
- Put the data in a separate file, say "input"
- Then run the program like this:

   program.exe < input

This will certainly work, but alternatives you might try is
a pipe:

   cat input |program.exe

I do not think the <<label ... label trick works with Windows
batch files. (But then: MinGW provides a bash for Windows and
there is also a winbash ...)

Regards,

Arjen
0
Reply arjen.markus895 (634) 12/14/2011 1:38:34 PM

2 Replies
93 Views

(page loaded in 0.043 seconds)

Similiar Articles:













7/24/2012 5:56:09 PM


Reply: