Thanks Davor.
Here's a slightly tweaked version:
---
#include "common.ch"
#include "fileio.ch"
FUNCTION hb_processRun( cCommand, cStdIn, cStdOut, cStdErr )
LOCAL hProcess
LOCAL hStdIn, hStdOut, hStdErr
LOCAL nErrorLevel
hProcess := hb_processOpen( cCommand, @hStdIn, @hStdOut, @hStdErr )
IF hProcess == F_ERROR
nErrorLevel := F_ERROR
ELSE
IF ISCHARACTER( cStdIn ) .AND. Len( cStdIn ) > 0
FWrite( hStdIn, cStdIn )
ENDIF
IF PCount() >= 3
cStdOut := ReadHnd( hStdOut )
ENDIF
IF PCount() >= 4
cStdErr := ReadHnd( hStdErr )
ENDIF
nErrorLevel := hb_processValue( hProcess )
hb_processClose( hProcess, .T. )
FClose( hStdIn )
FClose( hStdOut )
FClose( hStdErr )
ENDIF
RETURN nErrorLevel
STATIC FUNCTION ReadHnd( hHandle )
LOCAL cBuffer := Space( 4096 )
LOCAL cOutput := ""
LOCAL nLen
DO WHILE ( nLen := FRead( hHandle, @cBuffer, Len( cBuffer ) ) ) > 0
cOutPut += SubStr( cBuffer, 1, nLen )
ENDDO
RETURN cOutput
---
Any opinions on including it in core RTL? Przemek?
Brgds,
Viktor
2009/6/16 Davor Siklic <[email protected]>
> Hi all
>
> I need to have run command with standard input, std. output and error
> output which I use in past. After discover found hb_process* functions and
> find that are little difficult to use.
> Attached is syscmd.prg and is good example of using hb_process* functions.
> I get inspired with uhttpd. Be free to use or include this in harbour if
> find useful
>
> best regards
> Davor
>
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour