capture cli output

Find quick help here to get you started with Hollywood
Post Reply
User avatar
emeck
Posts: 52
Joined: Fri Apr 03, 2015 3:17 pm

capture cli output

Post by emeck » Fri Mar 31, 2017 2:05 pm

Hello,

I want to run a cli program from a Hollywood app, and to capture any output from the ran cli program. What I'm doing now is use a temporary file in T:, like this this:

Code: Select all

Local today$

Execute("date > T:today")

todayfile=OpenFile(Nil, "T:today")
today$=ReadLine(todayfile)
CloseFile(todayfile)
DeleteFile("T:today")

moai.Set("second", "text", today$)  ;send the output to the status bar
Ithis the best way or can I capture cli output without the temporary file?

User avatar
airsoftsoftwair
Posts: 2448
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: capture cli output

Post by airsoftsoftwair » Sat Apr 01, 2017 3:47 pm

No, I think what you're doing is the best way to capture CLI output with Hollywood.

User avatar
lazi
Posts: 285
Joined: Fri Feb 25, 2011 12:08 am

Re: capture cli output

Post by lazi » Mon Apr 10, 2017 9:40 am

There is a way to avoid temp files.
However it has a problem if the executed command does not send anything to the named pipe:

Code: Select all

Execute("date >pipe:day")

todayfile=OpenFile(Nil, "pipe:day")
pos,today$=-1,""
While FilePos(todayfile)<>pos
	pos=FilePos(todayfile)
	today$=today$..ReadLine(todayfile)
Wend
CloseFile(todayfile)

NPrint(today$)
WaitLeftMouse           

Post Reply