$zf(-1) can only return status code from called process
To get some output result, you should redirect this output to some file, and read result from this file after executing.
set status=$zf(-1, "find /tmp -name *.tmp > /tmp/result.log")
set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="/tmp/result.log"
set result=fs.Read()
Like most DC posts nowadays, this one got auto-crossposted to the intersystems-public-cache Google Group. When I checked this morning there were 5 responses from people trying to help the original poster. But since those answers don't automatically feed across to DC I'm drawing attention to them here. Because unless the OP knows to look there they may never see them.
using a Command Pipe would be the way to achieve this:
Set Command="git status" Set Pipe="|CPIPE|" Open Pipe:(Command:"R"):0 If '$Test Return "Cannot open CommandPipe to "_Command For { Use Pipe Read Line If $ZEOF Quit Set Lines($Increment(Lines))=$ZStrip(Line,"<>W") } Close Pipe
$zf(-1) can only return status code from called process
To get some output result, you should redirect this output to some file, and read result from this file after executing.
Be aware that Herman's code relies on the process having the non-default SetZEOF setting. More info here.
If you are trying to get the output of the command, one way is to use a pipe device. See this post.
I use this wrapper.
I have used this in order to call python code in the server, it calls bcrypt encryption in python.
Like most DC posts nowadays, this one got auto-crossposted to the intersystems-public-cache Google Group. When I checked this morning there were 5 responses from people trying to help the original poster. But since those answers don't automatically feed across to DC I'm drawing attention to them here. Because unless the OP knows to look there they may never see them.
https://groups.google.com/forum/#!topic/intersystems-public-cache/fngd5j...
Don't forget $ZF(-2,OS_COMMAND) for a quick and dirty way to spawn a child process on the OS level.
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
Tom Fitzgibbon | 347-464-8531 | gototomAtG...l.com
using a Command Pipe would be the way to achieve this:
Set Pipe="|CPIPE|"
Open Pipe:(Command:"R"):0
If '$Test Return "Cannot open CommandPipe to "_Command
For {
Use Pipe Read Line If $ZEOF Quit
Set Lines($Increment(Lines))=$ZStrip(Line,"<>W")
}
Close Pipe
Do not forget to mark answer as accepted.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue