External program is not creating output

3 visualizzazioni (ultimi 30 giorni)
Hello,
I am using Matlab R2013a and I want to run an external interactive program as non-interactive from within a matlab-script by piping the Input either through echoing a string or through a text-file. The Input consists of a string and 2 numbers. If I call
echo -e " 'String' \n 1 \n 2.2" | myFotran
in the unix shell, it creates an Output file as expected. Doing the same in matlab with
unix('echo -e " ''String'' \n 1 \n 2.2" | myFotran')
is not generating the Output-file. Why? Can someone help me? I can't change the external program, since it is not mine.
  29 Commenti
Jan
Jan il 7 Giu 2017
If you found a solution finally, the discussion was necessary and successful. It is the nature of questions, that a solution is sometimes not efficient.
Please post your solution as an answer and accept it. Thanks.
Walter Roberson
Walter Roberson il 8 Giu 2017
The shell echo does not use the fortran unit numbers, so I would not have expected the behavior to change for an echo test.

Accedi per commentare.

Risposta accettata

Matthias Otten
Matthias Otten il 8 Giu 2017
Modificato: Matthias Otten il 8 Giu 2017
the following did it for me. Setting STDOUT was not necessary
setenv('GFORTRAN_STDIN_UNIT', '5')
setenv('GFORTRAN_STDOUT_UNIT', '6')
setenv('GFORTRAN_STDERR_UNIT', '0')
!myfortran < Input.txt
setenv('GFORTRAN_STDIN_UNIT', '-1')
setenv('GFORTRAN_STDOUT_UNIT', '-1')
setenv('GFORTRAN_STDERR_UNIT', '-1')
The following threads contain the needed Information. Thank you Walter Roberson and Jan Simon. https://fr.mathworks.com/matlabcentral/answers/44388-or-system-or-unix-input-redirection https://fr.mathworks.com/matlabcentral/answers/91919-why-does-the-output-of-my-fortran-script-not-show-up-in-the-matlab-command-window-when-i-execute-it

Più risposte (0)

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by