How to execute system commands in the current shell instance
4 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 17 Jul 2012
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
0 Comments
See Also
Categories
Find more on Software Development Tools in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!