File tree 2 files changed +5
-28
lines changed
2 files changed +5
-28
lines changed Original file line number Diff line number Diff line change @@ -96,30 +96,12 @@ public function disconnect()
96
96
ssh2_disconnect ($ this ->resource );
97
97
}
98
98
99
- public function run ($ commands )
99
+ public function run (string $ command )
100
100
{
101
- if (is_string ($ commands )) {
102
- $ commands = [$ commands ];
103
- }
104
-
105
- if (!is_array ($ commands )) {
106
- throw new InvalidArgumentException ('Command(s) passed should be a string or an array of string. ' );
107
- }
108
-
109
101
if (!$ this ->connected ) {
110
102
throw new RuntimeException ('Unable to run commands when not connected. ' );
111
103
}
112
104
113
- $ results = [];
114
-
115
- foreach ($ commands as $ command ) {
116
- $ results [] = new SSHCommand ($ this ->resource , $ command );
117
- }
118
-
119
- if (count ($ results ) === 1 ) {
120
- return $ results [0 ];
121
- }
122
-
123
- return $ results ;
105
+ return new SSHCommand ($ this ->resource , $ command );
124
106
}
125
107
}
Original file line number Diff line number Diff line change 11
11
->withPassword ('password ' )
12
12
->connect ();
13
13
14
- $ outputs = $ connection ->run ([
15
- 'ls -lah ' ,
16
- 'echo "Hello world!" ' ,
17
- ]);
14
+ $ output = $ connection ->run ('ls -lah ' );
18
15
19
- foreach ($ outputs as $ output ) {
20
- var_dump ($ output ->getOutput ());
21
- var_dump ($ output ->getError ());
22
- }
16
+ var_dump ($ output ->getOutput ());
17
+ var_dump ($ output ->getError ());
You can’t perform that action at this time.
0 commit comments