I am using PHPSeclib to access server with dokku-alt installed:
http://dokku-alt.github.io/how-it-works.html
By following a typical example, I manage to send commands to a custom shell on my account:
$ssh=$this->connect();
echo trim($ssh->exec("version");
This is equivalent to
ssh dokku@my.node.org version
and works as expected. If I however try to execute a command which expects me to send data through STDIN, there is a problem. According to Net_SSH2 documentation, I need to write
the data into SSH stream instead of using exec(). Unfortunately my next example does not work, because custom shell does not receive any argument and responds with help page:
$ssh=$this->connect();
$ssh->write("mysql mariadb:console myapp newdb\n");
$ssh->write("show tables\n");
$ssh->read('[prompt]');
The result of this is identical to
ssh dokku@my.node.org
which simply responds with help page.
How can I combine the "exec" functionality and still be able to write data? Something like this does not work either:
$ssh=$this->connect();
$ssh->exec("mysql mariadb:console myapp newdb");
$ssh->write("show tables\n");
$ssh->read('[prompt]');
Thank you.