Page 1 of 1

Get return text of DOS command!?

Posted: Fri Jun 06, 2008 1:48 pm
by JC
Hi friends!


How I can get the return of a line command into DOS with fivewin/xharbour like this:

"tracert -d 10.0.0.1"

Posted: Fri Jun 06, 2008 3:09 pm
by MOISES
tracert -d 10.1.1.1 >> file.txt

memoread file.txt

Posted: Fri Jun 06, 2008 6:51 pm
by JC
MOISES wrote:tracert -d 10.1.1.1 >> file.txt

memoread file.txt
Thanks Moises, but how I can execute this?

With shellExecute()? winExec() ?

Posted: Sat Jun 07, 2008 7:17 am
by AlexSchaft
Hi,

I'd suggest using the Waitrun(), otherwise the program will continue without the command having finished

Waitrun("tracert.exe -d 10.1.1.1 >> file.txt")

Posted: Sat Jun 07, 2008 7:24 am
by xProgrammer
Hi JC

You can use the RUN command

Code: Select all

 RUN tracert -d 10.1.1.1 >> file.txt 
should work.

The more flexible way is as follows:

Code: Select all

LOCAL sOSCommand
sOSCommand := "tracert -d 10.1.1.1 >> file.txt"
RUN ( sOSCommand )
Should work fine under Windows. Certainly works under Linux. I recently wrote a "proof of concept" for compiling and linking xHarbour/FiveLinux projects via an xHarbour/FiveLinux "project manager" and the following code ran fine:

Code: Select all

FUNCTION Compile( xProject )

LOCAL sOsCommand

sOsCommand := "./m.sh " + xProject + " > " + xProject + ".flb" 
RUN ( sOsCommand )
MsgInfo( MemoRead( xProject + ".flb" ) )

RETURN nil
Hope that helps
xProgrammer