List Info

Thread: Executing external program and obtaining stdout, stderr and the return value




Executing external program and obtaining stdout, stderr and the return value
user name
2006-01-26 18:09:59
I'd like to execute an external program (under LINUX) from
within a Basic 
script, and I would like to obtain it's stdout, stderr and
it's return value.  
I know that I could do it for example as follows (untested):

1. Shell( _
   "/bin/bash -c 'some_program >/tmp/out
2>&1; echo $? >/tmp/retval'")

2. Read the files "/tmp/out" and
"/tmp/retval".

But, is there a simpler way?  Is there an alternative to
"shell"?

-- 
Dipl.-Phys. Felix E. Klee
Email: fklinuxburg.de (work), felix.kleeinka.de (home)
Tel: +49 721 8307937, Fax: +49 721 8307936
Linuxburg, Goethestr. 15A, 76135 Karlsruhe, Germany

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

Executing external program and obtaining stdout, stderr and the return value
user name
2006-01-31 12:17:27
Hi Felix,

no way to get the output directly, because Basic would need
to handle
pipes then.
It is under consideration whether UNO should be extended to
give
support for standard IO, see #i53061#.

Workaround is either such glue stuff like you presented or
to use
another (UNO-supported) language, for example Python, which
does this
stuff in a few lines of code easily (os.popen).

2006/1/26, Felix E. Klee <fklinuxburg.de>:
> I'd like to execute an external program (under LINUX)
from within a Basic
> script, and I would like to obtain it's stdout, stderr
and it's return value.
> I know that I could do it for example as follows
(untested):
>
> 1. Shell( _
>    "/bin/bash -c 'some_program >/tmp/out
2>&1; echo $? >/tmp/retval'")
>
> 2. Read the files "/tmp/out" and
"/tmp/retval".
>
> But, is there a simpler way?  Is there an alternative
to "shell"?


--
Best Regards
Christian Junker

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )