AwsInspector\Ssh\Command::exec PHP Method

exec() public method

public exec ( )
    public function exec()
    {
        // file_put_contents('/tmp/exec.log', $this->__toString() . "\n\n", FILE_APPEND);
        $returnVar = null;
        exec($this->__toString(), $output, $returnVar);
        return ['output' => $output, 'returnVar' => $returnVar];
    }

Usage Example

コード例 #1
0
 /**
  * @test
  */
 public function runLocalCommandasUser()
 {
     try {
         $testfile = tempnam(sys_get_temp_dir(), __FUNCTION__);
         $command = new Command(new LocalConnection(), 'whoami > ' . $testfile, 'root');
         $command->exec();
         $this->assertEquals('root', trim(file_get_contents($testfile)));
         unlink($testfile);
     } catch (\Exception $e) {
         $this->markTestSkipped('It is ok if this test fails');
     }
 }
All Usage Examples Of AwsInspector\Ssh\Command::exec