From: Charles Coldwell on
Arjen Markus <arjen.markus(a)wldelft.nl> writes:

>
> Cute solution, but here are a few caveats:
>
> 1. The device file "/dev/tty" exists or is usuable for this purpose on
> UNIX, Linux and (I assume, I have no access to it) OSX and systems
> like that.

Quoting the OP

>> > The program package I am using executes programs in the following
>> > way (under Unix): program.bin < program.input

> 3. The second loop does not terminate: there is no end-of-file
> condition,
> even with an empty line.

Try "ctrl-D"

Chip

--
Charles M. "Chip" Coldwell
"Turn on, log in, tune out"
GPG Key ID: 852E052F
GPG Key Fingerprint: 77E5 2B51 4907 F08A 7E92 DE80 AFA9 9A8F 852E 052F
From: Arjen Markus on
On 5 mei, 04:16, Charles Coldwell <coldw...(a)gmail.com> wrote:
> Arjen Markus <arjen.mar...(a)wldelft.nl> writes:
>
> > Cute solution, but here are a few caveats:
>
> > 1. The device file "/dev/tty" exists or is usuable for this purpose on
> >    UNIX, Linux and (I assume, I have no access to it) OSX and systems
> >    like that.
>
> Quoting the OP

It is a rather elegant solution - I had not thought
there would be any :) - so I was interested to see
how it turned out on Windows ...

>
> >> > The program package I am using executes programs in the following
> >> > way (under Unix): program.bin < program.input
> > 3. The second loop does not terminate: there is no end-of-file
> > condition,
> >    even with an empty line.
>
> Try "ctrl-D"
>

Oops, that feature of UNIX/Linux shells had fallen into
the cracks of my memory :).

Regards,

Arjen
From: Charles Coldwell on
Arjen Markus <arjen.markus(a)wldelft.nl> writes:

> It is a rather elegant solution - I had not thought
> there would be any :) - so I was interested to see
> how it turned out on Windows ...

That's a very interesting question, actually. Unix grew up in the era
of real, hardware terminals and so the concept is well developed in
the OS. So well, in fact, that even after the era ended the concept
lives on as "pseudo-terminals". So if you run a terminal emulator in
Unix (xterm, gnome-terminal, kterm, what-have-you) the emulator is
connected to the shell (or a program forked and exec'd by the shell)
through a pseudo-terminal provided by the operating system kernel
(/dev/pts/N on Linux -- UNIX98 PTYs, /dev/ttypN or /dev/ttyXY on BSD).

In any process, /dev/tty is an alias for the process' controlling
terminal (you can find the real name of your controlling terminal by
running the "tty" command). So, in fact, having standard input (unit
5) connected to /dev/tty is exactly what would have happened if input
had not been redirected from a file.

I have no idea if any of these concepts (controlling terminal,
pseudo-terminal, foreground process groups, etc) exist at all on
Windows.

>> Try "ctrl-D"
>>
>
> Oops, that feature of UNIX/Linux shells had fallen into
> the cracks of my memory :).

Actually, it's not a feature of the shell at all; when the Fortran
program is running the shell is out of the picture. The Fortran
program is getting input from the terminal device (or
pseudo-terminal), and the terminal driver in the OS kernel converts
the ASCII Ctrl-D (EOT -- end of transmission) into and end-of-file
condition.

Chip

--
Charles M. "Chip" Coldwell
"Turn on, log in, tune out"
GPG Key ID: 852E052F
GPG Key Fingerprint: 77E5 2B51 4907 F08A 7E92 DE80 AFA9 9A8F 852E 052F