I've followed the steps here http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
to connect to my server with ssh via Python. I can connect fine and send commands.
When I run stderr.readlines(), however, it shows me the error message below every time, even if the command seems to have executed correctly. I've closed the connection and restarted Python, and still the same result.
Here's a Python sample:
>>> stdin, stdout, stderr = myssh.exec_command("xyz")
>>> stderr.readlines()
['which: no php in (/usr/bin:/bin:/usr/sbin:/sbin:/big/dom/mydomain/pear/drush)\n', '/big/dom/mydomain/pear/drush/drush: line 89: exec: : not found\n', 'bash: xyz: command not found\n']
I have drush installed and it seems to work fine. If I type in "which php" on the server I'm told where it resides, instead of the error message above. I sent some other commands to purposefully get an error message to see if it cleared anything out. Instead it tacked things on at the end.
Following the error message, I went and looked at the drush file referenced. Here's line 89:
exec "$php" $php_options "$SCRIPT_PATH" --php="$php" --php-options="$php_options" "$@"
I believe the "which php" command comes from the $php variable in the chunk above this line
if [ ! -z "$DRUSH_PHP" ] ; then
# Use the DRUSH_PHP environment variable if it is available.
php="$DRUSH_PHP"
else
# Default to using the php that we find on the PATH.
# Note that we need the full path to php here for Dreamhost, which behaves oddly. See http://drupal.org/node/662926
php=`which php`
# We check for a command line (cli) version of php, and if found use that.
which php-cli >/dev/null 2>&1
if [ "$?" = 0 ] ; then
php=`which php-cli`
fi
# On MSYSGIT, we need to use "php", not the full path to php
if [ ! -z "$MSYSTEM" ] && [ "x${MSYSTEM:0:5}" = "xMINGW" ] ; then
php="php"
fi
fi
The full text of the file is here: http://pastebin.com/29AXmHKF
I get the same error if I try to execute any drush command. But drush commands work fine if I just log myself into the server directly w/o using python/paramiko.