Ferreteria/v0.6/clade/IO/Aspect/Connx/Process/@fx/Run
Jump to navigation
Jump to search
About
- Action: Sends the command, buffers the response, closes the command process
This and PipeToStream() (which it calls) have a lot of overlap with what Convey() does, and I'm trying to figure out if they can be consolidated.
- Q1: what is the relationship between a
Bufferand aStream?- A: Tentatively, a
Bufferis actually a type ofStream-- so we should be able to pass aBufferwherever aStreamis needed.
- A: Tentatively, a
- Q2: What is the relationship between
GetErrsBuff()and$oaPipes->ErrsQRes()?- A:
GetErrsBuff()returns aBufferobject, which is a type ofStream.$oaPipes->ErrsQRes()returns aQPipeobject, which wraps around a native resource.
- A:
History
- 2024-11-24 created. This is experimental; if it works, this kind of thing should probably be encapsulated in its own class.
- 2024-11-25 moved from shell/Secure to Shell
Code
#
public function Run() : CommOpIface {
$this->Open();
$oBuffErrs = $this->GetErrsBuff();
$oBuffRecv = $this->QORecvBuff()->GetIt();
$oBuffErrs->Open();
$oBuffRecv->Open();
$oaPipes = $this->OAPipes();
$this->PipeToStream($oaPipes->SrceRsrc(),$oBuffRecv,TRUE); // receive any output from process
$this->PipeToStream($oaPipes->ErrsRsrc(),$oBuffErrs,FALSE); // check for error messages from process
$oAct = $this->GetOpStator();
if ($oBuffErrs->HasBytes()) {
$sMsg = $oBuffErrs->PullBytes();
$oAct->SetOkay(FALSE);
$oAct->AddMsgObject(new MsgClass($sMsg));
$oAct->QResponseErr()->SetIt($sMsg);
} else {
$oAct->SetOkay(TRUE);
if (!$oBuffRecv->HasBytes()) {
$oAct->AddMsgString('No error messages, but also no regular output received.');
}
}
$this->Shut();
$oBuffRecv->Shut();
$oBuffErrs->Shut();
return $oAct;
}