0

I have a colleague who is connecting to a remote web host through a php/command line tool that the CMS Drupal uses called drush.

Drush connects to the remote host through ssh, but when we issue commands, we're getting an error when bash tries to parse a certain file. However, it doesn't tell which file has the syntax error.

Begin redispatch via drush_invoke_process(). [2.01 sec, 6.87 MB]        [notice]
Backend invoke: ssh -p 2222 -o "AddressFamily inet"                    [command]
user@myremotehost.com
'drush  --debug --verbose --uri=myremotehost.com
--db-url='\''mysql://host:myremotehost.com:11297/database'\''
 cache-rebuild 2>&1' 2>&1 [2.01 sec, 6.88 MB]
Calling proc_open(ssh -p 2222 -o "AddressFamily inet" user@myremotehost.com 'drush  --debug --verbose --uri=mysite.com --db-url='\''mysql://host:myremotehost.com:11297/database'\''  cache-rebuild 2>&1' 2>&1);
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
End redispatch via drush_invoke_process(). [5.36 sec, 6.88 MB]          [notice]

The shell starts up normally and we can run typical GNU utility commands, so it doesn't seem like the .bashrc or other dotfiles have the error.

As a troubleshooting measure, we re-installed the drush command ( a combination of shell and php scripts). We can run various commands with it, except this one, which connects to a remote host.

How can we begin to track down where the error is occurring?

We're using git-bash GNU bash, version 4.4.12(1)-release (x86_64-pc-msys) on Windows 7.

Edit

In the output I pasted above, there were some verbose and debugging switches I used, to garner more information.

I just re-downloaded our drush alises file and re-ran the command with out the switches, and this is what we get

$ drush @mysite status
/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
  • Sounds to me like there is a problem with the 'drush --debug --verbose ... part but I do not see it. That part is passed by ssh to a shell via -c and it's just one line. Maybe the outer layer proc_open() somehow destroys the quoting. Can you change that command line to --db-url='mysql://host:myremotehost.com:11297/database? No need for quoting there anyway. – Hauke Laging Aug 15 '17 at 21:13
  • 1
    @user394: It is not bash which is outputting the errors you are refering too, because if this would be the case, the wording would be different. It is /bin/sh which is either Posix shell, or maybe bash running in Posix mode. While this doesn't really matter in your concrete case, you should at least be aware of it in the future. – user1934428 Aug 16 '17 at 10:45
  • @HaukeLaging see edits please; we re-downloaded the alias file and re-ran the commands without the verbose and debugging switches. We are still getting the sh errors. – user394 Aug 16 '17 at 13:34
0

According to the log, the command sent via ssh is broken. To solve your problem, first locate where is the invocation to ssh within drush.

The command passed to ssh is

    drush  --debug --verbose --uri=myremotehost.com --db-url='\''mysql://host:myremotehost.com:11297/database'\'
  1. it breaks down to drush ... --db-url= '\' 'mysql://.../database' \'
  2. the latter \' same as ' is opening a quoting thus not closed

Bash reference is the best place to get an accurate idea of

  • 1
    It is closed later: cache-rebuild 2>&1' – Hauke Laging Aug 16 '17 at 6:27
0

It turns out, because of the PATH variable on our windows, we were linking do a different drush from a previous install. This drush was sending the unmatched quote to the remote host, which was sending back the sh errors.

We updated the path (after testing out specifying the full path to drush) and it works now.

  • Please remember to accept this answer (possibly tomorrow). – roaima Aug 16 '17 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.