capture cli output

Find quick help here to get you started with Hollywood

capture cli output

Postby 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
emeck
 
Posts: 43
Joined: Fri Apr 03, 2015 3:17 pm

Re: capture cli output

Postby 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
airsoftsoftwair
 
Posts: 2202
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: capture cli output

Postby 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           
User avatar
lazi
 
Posts: 256
Joined: Fri Feb 25, 2011 12:08 am


Return to Newbie questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron