External program is not creating output

3 vues (au cours des 30 derniers jours)
Matthias Otten
Matthias Otten le 23 Mai 2017
Commenté : Walter Roberson le 8 Juin 2017
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 commentaires
Jan
Jan le 7 Juin 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 le 8 Juin 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.

Connectez-vous pour commenter.

Réponse acceptée

Matthias Otten
Matthias Otten le 8 Juin 2017
Modifié(e) : Matthias Otten le 8 Juin 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

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by