You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I'm correctly understanding the syntax for retrieving the exit status of the last command executed, then it doesn't seem to work. Here is code to reproduce the issue:
$command = 'true'; // It doesn't matter what command you put here
SSH::run($command);
$status = SSH::status();
var_dump($status); // use var_dump instead of dd - it's clearer
exit;
Result:
bool(false)
As noted above, it doesn't matter what command you send it. It always says bool(false).
I dug through the code, and what appears to be happening is that the SSH connection is dropped as soon as the specified commands are done running. When execution of the above code makes it down to SSH::status(), it ends up opening a new connection and returning the status of that.
I also tried placing the SSH::status() inside a closure, like this:
Still no love. Although I didn't debug this one as thoroughly, I suspect what is happening here again is that the call to phpseclib->exec() is finishing and closing the connection before the status can be retrieved.
Does that assessment make sense, or am I just calling status() incorrectly?
The text was updated successfully, but these errors were encountered:
Every time you make a call to the SSH facade a new connection is setup. If you keep a reference to the connection the status will be returned properly:
$ssh = SSH::connection(); // or SSH::into('env')$ssh->run('...');
$status = $ssh->status(); // $status will now hold the exit status
If I'm correctly understanding the syntax for retrieving the exit status of the last command executed, then it doesn't seem to work. Here is code to reproduce the issue:
Result:
As noted above, it doesn't matter what command you send it. It always says bool(false).
I dug through the code, and what appears to be happening is that the SSH connection is dropped as soon as the specified commands are done running. When execution of the above code makes it down to SSH::status(), it ends up opening a new connection and returning the status of that.
I also tried placing the SSH::status() inside a closure, like this:
Still no love. Although I didn't debug this one as thoroughly, I suspect what is happening here again is that the call to phpseclib->exec() is finishing and closing the connection before the status can be retrieved.
Does that assessment make sense, or am I just calling status() incorrectly?
The text was updated successfully, but these errors were encountered: