Get return text of DOS command!?

Post Reply
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Get return text of DOS command!?

Post 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"
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
MOISES
Posts: 824
Joined: Wed Aug 22, 2007 10:09 am

Post by MOISES »

tracert -d 10.1.1.1 >> file.txt

memoread file.txt
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post 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() ?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
AlexSchaft
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Post 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")
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Post 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
Post Reply