src/sb/Samba/Connection.php
public function execute($command, &$output = null)
    {

        $cmd = "smbclient '\\\\{$this->host}\\{$this->share}' $this->password -U $this->username -W $this->domain -c '$command' 2>&1";
        exec($cmd, $output, $return);

        if($return === 1){
            $errmsg = sprintf("Host: %s / Share: %s / Username: %s / Domain: %s / Error Message: %s",
                $this->host,
                $this->share,
                $this->username,
                $this->domain,
                implode(" ", $output)
            );
            throw new \Exception($errmsg);
        }

        if($this->debug == true){
            file_put_contents("php://stdout", "\n".$cmd);
            file_put_contents("php://stdout", "\n".print_r($output, 1));
        }

        //LOG: Transaction
        if(self::$log) {
            self::$log->samba("Command: $cmd \n Output:" . print_r($output, 1) . "\n Return: " . print_r($return, 1) . "\n\n\n");
        }

        return $return;
    }
public function execute($command, &$output = null)
    {

        $cmd = "smbclient '\\\\{$this->host}\\{$this->share}' $this->password -U $this->username -W $this->domain -c '$command' 2>&1";
        exec($cmd, $output, $return);

        if($return === 1){
            $errmsg = sprintf("Host: %s / Share: %s / Username: %s / Domain: %s / Error Message: %s",
                $this->host,
                $this->share,
                $this->username,
                $this->domain,
                implode(" ", $output)
            );
            throw new \Exception($errmsg);
        }

        if($this->debug == true){
            file_put_contents("php://stdout", "\n".$cmd);
            file_put_contents("php://stdout", "\n".print_r($output, 1));
        }

        //LOG: Transaction
        if(self::$log) {
            self::$log->samba("Command: $cmd \n Output:" . print_r($output, 1) . "\n Return: " . print_r($return, 1) . "\n\n\n");
        }

        return $return;
    }
public function execute ( $ command , & $ output = null ) { $ cmd = "smbclient '\\\\{$this->host}\\{$this->share}' $this->password -U $this->username -W $this->domain -c '$command' 2>&1" ; exec ( $ cmd , $ output , $ return ) ; if ( $ return === 1 ) { $ errmsg = sprintf ( "Host: %s / Share: %s / Username: %s / Domain: %s / Error Message: %s" , $ this -> host , $ this -> share , $ this -> username , $ this -> domain , implode ( " " , $ output ) ) ; throw new \ Exception ( $ errmsg ) ; } if ( $ this -> debug == true ) { file_put_contents ( "php://stdout" , "\n" . $ cmd ) ; file_put_contents ( "php://stdout" , "\n" . print_r ( $ output , 1 ) ) ; } //LOG: Transaction if ( self :: $ log ) { self :: $ log -> samba ( "Command: $cmd \n Output:" . print_r ( $ output , 1 ) . "\n Return: " . print_r ( $ return , 1 ) . "\n\n\n" ) ; } return $ return ; }
Executes the command line function that completes the remote windows operations
@param $command string the command to issue to the smbclient
@param $output array what the command line returns
@param $log boolean whether to log this transaction
@return int Exit code for smbclient: 0 for success, 1 for error
Executes the command line function that completes the remote windows operations