handle smbclient help message

This commit is contained in:
Robin Appelman 2018-01-17 18:26:40 +01:00
commit 0ef64a9156
2 changed files with 12 additions and 0 deletions

View file

@ -34,6 +34,14 @@ class Connection extends RawConnection {
parent::write($input . PHP_EOL);
}
public function clearTillPrompt() {
do {
$promptLine = $this->readLine();
} while (!$this->isPrompt($promptLine));
$this->write('');
$this->readLine();
}
/**
* get all unprocessed output from smbclient until the next prompt
*

View file

@ -72,6 +72,9 @@ class Share extends AbstractShare {
if (!$connection->isValid()) {
throw new ConnectionException($connection->readLine());
}
$connection->write('');
// some versions of smbclient add a help message in first of the first prompt
$connection->clearTillPrompt();
return $connection;
}
@ -125,6 +128,7 @@ class Share extends AbstractShare {
//check output for errors
$this->parseOutput($output, $path);
$output = $this->execute('dir');
$this->execute('cd /');
return $this->parser->parseDir($output, $path);