How to execute system commands in the current shell instance
Ältere Kommentare anzeigen
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
Antworten (1)
Walter Roberson
am 17 Jul. 2012
0 Stimmen
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
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!