difference btwn entering commands after ssh vs entering as a one-liner
Kind of an odd problem: When I do this, everything works fine:
ssh abc@myurl drush -v
But like this it fails:
ssh abc@myurl "drush -v"
: No such file or directorysh/drush: line 10: cd: /cygdrive/c/ProgramData/Drush /drush.phpopen input file: .
Exact same commands, just doesn't work as an inline command, which is what I need in order to script this thing. Yes, cygwin is involved, so dunno if that's relevant here, hopefully not.
Any idea how to make the 2nd form work? Other commands work fine, eg:
ssh abc@myurl "cd /cygdrive/c/mydrupaldir; pwd"
[EDIT] I've narrowed down the steps to reproduce for simplicity, and I also found the reason this fails: drush has special handling for cygwin, which it relies on uname -a to determine, and that is the key difference:
ssh abc@myurl uname -a
CYGWIN_NT-6.1 MYURL 1.7.28(0.271/5/3) 2014-02-09 21:06 x86_64 Cygwin
ssh abc@myurl "uname -a"
Server 4.0 windows32 MYURL 2.6.1 7601 ix86-pc AMD unknown MinGW
I've solved my immediate problem by hard-coding changes to the script, but the question now is, why does uname give different results in these two scenarios?
Because you're trying to execute a shell command without any environment variables. The system doesn't know how to answer. The correct way to do this is:
ssh abc@myurl "/usr/bin/bash.exe -cl 'uname -a'"
Here -c is for reading the following string as commands, while -l is used to specify that bash should be invoked as a "login shell". There are probably other working variations on this.