Skip to content

Commit a16d974

Browse files
committed
SSH2: More updates to interactive example
1 parent 8776f5d commit a16d974

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ssh/examples.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ <h1>php<span class="red">sec</span>lib: SSH2 Examples and Notes</h1>
180180
echo $ssh->exec('pwd'); // (despite the previous command) outputs /home/username</span><span style="display: none">
181181
</span><span class="interactive">echo $ssh->read('username@username:~$');
182182
$ssh->write("ls -la\n");
183-
echo $ssh->read('username@username:~$');</span><span class="sudo">echo $sftp->read('username@username:~$');
184-
$sftp->write("sudo ls -la\n");
185-
$output = $sftp->read('#Password:|username@username:~\$#', NET_SSH2_READ_REGEX);
183+
echo $ssh->read('username@username:~$');</span><span class="sudo">echo $ssh->read('username@username:~$');
184+
$ssh->write("sudo ls -la\n");
185+
$output = $ssh->read('#[pP]assword[^:]*:|username@username:~\$#', NET_SSH2_READ_REGEX);
186186
echo $output;
187-
if (preg_match('#Password:#', $output)) {
187+
if (preg_match('#[pP]assword[^:]*:#', $output)) {
188188
$ssh->write("password\n");
189-
echo $sftp->read('username@username:~$');
190-
}</span><span class="timeout">$ssh->setTimeout(5);
189+
echo $ssh->read('username@username:~$');
190+
}</span><span class="timeout">$ssh->setTimeout(1);
191191
echo $ssh->read();</span><span class="top">$ansi = new File_ANSI();
192192

193193
$ansi->appendString($ssh->read('username@username:~$'));

0 commit comments

Comments
 (0)