1
function [rep,stat]=unix_g(cmd)
2
//unix_g - shell command execution
6
// cmd - a character string
7
// rep - a column vector of character strings
9
// cmd instruction (sh syntax) is passed to shell, the standard output
10
// is redirected to scilab variable rep.
18
if prod(size(cmd))<>1 then error(55,1),end
21
tmp=strsubst(TMPDIR,'/','\')+'\unix.out';
22
cmd1= cmd + ' > '+ tmp;
24
tmp=TMPDIR+'/unix.out';
25
cmd1='('+cmd+')>'+ tmp +' 2>'+TMPDIR+'/unix.err;';
30
rep=read(tmp,-1,1,'(a)')
31
if size(rep,'*')==0 then rep=[],end
32
case -1 then // host failed
33
disp('host does not answer...')
37
write(%io(2),'unix_g: shell error');
40
msg=read(TMPDIR+'/unix.err',-1,1,'(a)')