[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: system and shell_cmd
From: |
Ben Abbott |
Subject: |
Re: system and shell_cmd |
Date: |
Tue, 06 Dec 2011 20:02:06 -0500 |
On Dec 6, 2011, at 5:53 PM, Rik wrote:
> 12/6/11
>
> Can someone with access to Matlab run the following code snippet?
>
> system ('echo hello')
>
> I think it will return just the output, but it might return the output and
> the status.
>
> Also,
>
> x = system ('echo hello')
>
> Is x set to status or the actual output of the command?
>
> Finally, is there any objection to deprecating shell_cmd which is an alias
> for system?
>
> Cheers,
> Rik
Rik,
One point, that you may not be aware of, Matlab's system() function behaves
differently when one and two outputs are present.
status = system ('echo hello')
hello
status =
0
[status, output] = system ('echo hello')
status =
0
output =
hello
And second example ...
status = system ('foo')
/bin/bash: foo: command not found
status =
127
[status, output] = system ('foo')
status =
127
output =
/bin/bash: foo: command not found
Ben