dc
can read command from a file or/and from standard input.
If I want to print user input :
cat essai_dc
[enter a number : ]
n
?
p
dc essai_dc
enter a number : 4
4
Now, if I try with a heredoc
:
dc <<EOF
> [enter a number : ]
> n
> ?
> p
> EOF
enter a number : dc: stack empty
I get the same with standard input :
cat essai_dc | dc
enter a number : dc: stack empty
The command ? get the p
and execute it but the stack is empty.
Is it possible to get it to work (tell dc
to wait for the input)