How to execute system commands in the current shell instance
이전 댓글 표시
Hello,
I am using Matlab 7.8.0.347 (R2009a) on a Linux cluster. I use functions "system" and "unix" execute Unix commands, sometimes as simple as 'ls'.
However, these functions execute the command in a new shell, so what is actually executed is not only the command but also the login scripts, with the associated waste of time and resources. This can easily tested by including an 'echo world' line in the login files (e.g. .profile).
Is it possible to execute a command directly as a child process without an intervening shell process?
Thank you in advance,
Alessandro
답변 (1개)
Walter Roberson
2012년 7월 17일
0 개 추천
It is the responsibility of those profiles to test to see whether they are being used in interactive form or not.
In shells derived from the Bourne shell, the usual way to do this is with the "-t" test.
if [[ -t 0 ]] #then stdin is associated with a terminal, indicating interactive use
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!