Ferreteria/v0.6/clade/Sys/Data/Engine/Conn/MyMar/@fx/DoCommand

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine‎ | Conn‎ | MyMar
Jump to navigation Jump to search

About

  • Action: Using the current connection-plug ($this->OSock()->OPlug()), execute the given command and save its output in $oResp.

Code: Current

As of 2026-01-10 (including debug code):

#
    public function DoCommand(CmdLineIface $oCmd, StreamIface $oResp) : CommOpIface {
        #$this->AmHereShort('ORIGINAL COMMAND: '.self::Screen()->BoldIt($saCmd));
        $oCreds = $this->CredsForCmd();
        $oCmd->EmbedWithin(
          CmdLineClass::FromString('echo'),
          CmdLineClass::FromArray(['|','mysql '.$oCreds->AsString()])
          );

        $this->AmHere("COMMAND: ".$oCmd->AsString());

        $oPlug = $this->OSock()->OPlug();
        $oAct = $oPlug->DoCommand($oCmd,$oResp);
        return $oAct;
    }

Code: Removed

2026-01-10

#
    // 2026-01-07 old API
    // TODO: handle when $saCmd is array
    public function DoCommand(string|array $saCmd, StreamIface $oResp) : CommOpIface {
        #$this->AmHereShort('ORIGINAL COMMAND: '.self::Screen()->BoldIt($saCmd));
        $sCreds = $this->CredsForCmd();
        $seCmd = escapeshellarg($saCmd);
        $sCmd = "echo $seCmd | mysql $sCreds";
        $this->AmHere("COMMAND: $sCmd");

        $oPlug = $this->OSock()->OPlug();
        #echo $oPlug->ReflectThis()->Report(); die();
        $oAct = $oPlug->DoCommand($sCmd,$oResp);
        return $oAct;
    }