Ferreteria/v0.6/clade/IO/Aspect/Connx/Stream/Runner/Remote/SSH2/@fx/DoCommand

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Stream‎ | Runner‎ | Remote‎ | SSH2
Jump to navigation Jump to search

About

  • Assumes: connection has been opened

History

  • 2026-01-09 THINKING: It doesn't really make sense to pass in a Stream here, since ssh2_exec() creates one.
    • Also, $oItWent has two Str objects for receiving data -- one for regular replies, one for errors.
    • So: we could either create an ItWent podling that encapsulates reply & error streams, or...
      ...we could just PullBytes() from the returned stream, and stuff them into the reply QStr.
      ...ohbutwait! That must be what $oItWent = $oStream->PullBytes() does, except we need to create & set up $oStream.
  • 2026-01-17 disabled, with the note "This is actually an OVERRIDE -- and the parent properly creates a Process..." -- but it turns out I was confused
  • 2026-01-20 Re-enabled, because Process only executes locally -- so either the command needs to be wrapped, or we need to execute it with ssh2.
    • I guess we need different versions of SSH depending on which way we want to do things. Note that the ssh2 library functions cannot wrap more than once, i.e. you can't use this class to build a chain of ssh connections (A connecting to B and then connecting to C).

Code

as of 2026-01-09 (revision still in progress):

#
    public function DoCommand(CmdLineIface $oCmd, StreamIface $oResps) : CommOpIface {
        $rRecv = ssh2_exec($this->QNative()->GetIt(), $oCmd->AsString());
        $oItWent = $oStream->PullBytes();
        $oItWent->SetOkay(is_resource($rRecv));
        return $oItWent;
    }