Execute with CaptureOutput set to true doesn't returns rc

Find quick help here to get you started with Hollywood
Post Reply
bitRocky
Posts: 160
Joined: Fri Nov 14, 2014 6:01 pm

Execute with CaptureOutput set to true doesn't returns rc

Post by bitRocky »

Execute() should return the rc of the program which gets executed if CaptureOutput is set to true, but it doesn't work here on MorphOS.
It always returns 0.

Did I something wrong?

Here is an example with tries to execute an unknown command "Echo2".

Code: Select all

@VERSION 11,0

rc, out = Execute("Echo2", "Hallo", {CaptureOutput=True})
DebugPrint("rc = "..rc)
DebugPrint("out = "..out)
If rc = 0
	DebugPrint("Successful")
Else
	DebugPrint("Failed!")
Endif
plouf
Posts: 753
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by plouf »

Do you have latest hollywood11?
Some fixes have been made for this

Relative discusion -> https://forums.hollywood-mal.com/viewtopic.php?t=4225
Christos
bitRocky
Posts: 160
Joined: Fri Nov 14, 2014 6:01 pm

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by bitRocky »

Yes v11 here on MorphOS
plouf
Posts: 753
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by plouf »

try the following example i test it in mos now works
comment/uncomment the two Run()

Code: Select all

Function p_HandlerFunc(msg)
	Switch(msg.action)
	Case "RunFinished":
		NPrint("Return code "..StrStr(msg.returncode))
		NPrint("Press Return to continue.")
		WaitLeftMouse()
	EndSwitch
EndFunction

InstallEventHandler({RunFinished = p_HandlerFunc})

;Run("ed","",{Returncode=True})     ; returncode 0
Run("sss","",{Returncode=True})   ; dont exist not return code in win / returncode 10 in amigaos

Repeat
	WaitEvent
Forever
Christos
bitRocky
Posts: 160
Joined: Fri Nov 14, 2014 6:01 pm

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by bitRocky »

I wanted to use Execute (), because it didn't have to run asynchronously.
And it should work according to the docs.
User avatar
airsoftsoftwair
Posts: 6017
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by airsoftsoftwair »

Your code is correct. But I'm not sure if it's a bug or a feature. I mean you're trying to execute a non-existing program here and technically non-existing programs can't return a return code so one could also say that it's correct for Execute() to behave that way. I need to check how this behaves on other platforms and then decide about some sensible behaviour here...
plouf
Posts: 753
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Execute with CaptureOutput set to true doesn't returns rc

Post by plouf »

based on discusion we had in https://forums.hollywood-mal.com/viewtopic.php?t=4225 returncode must be what OS does

the following example works
in amigaos3.x by returning code 10 (As the OS does),
works in windows by returning 127 (as the OS does)

but not in Morphos/AmigaOS4
In morphos i see thext "failed code 10" in output text (as the OS does print in shell by executing a command)..bug or "feature"?
in AmigaOS4, works with 68kbinary, with ppc binary i see "return code 10" , if ed started without argument (missing) and "return code 0" if fail

Code: Select all

rc, output =Execute("ed","d",{CaptureOutput=True,Consolemode=True})   ; dont exist not return code in win / returncode 10 in amigaos
;rc, output =Execute("not_ed","",{CaptureOutput=True})   ; dont exist not return code in win / returncode 10 in amigaos

NPrint("Return code "..StrStr(rc))
NPrint("output "..output)
Repeat
	WaitEvent
Forever
Christos
Post Reply