0

My sites are running Drupal 7, Drush 8.0.3.

I'm creating a dashboard to check what core and module versions my Drupal sites are running (they're all on the same server). I use a shell script to get Drush to check available updates, write them to a JSON file then my dashboard script reads the JSON file.

/usr/local/bin/drush --root=/home/www/html/www.mysite.com rf
/usr/local/bin/drush --root=/home/www/html/www.mysite.com ups --security-only --format=json > /home/www/html-private/mysite.json

This works fine but the problem I have is that when there are no updates available I get an empty JSON file. How can I tell the difference between this and a failure to write the JSON properly? Can I get it to output 'No updates available' or something so I can tell it ran correctly?

1 Answer 1

0

Did you check to see if $? is correctly set? It should be 0 for success, and 1 if there was an error. Please open an issue in the Drush queue if this is not the case.

2
  • I'm not sure I understand, how do I check $?
    – nexus_6
    Jan 17, 2017 at 14:30
  • if [[ $? -eq 0 ]]; then echo "OK"; else echo "NOT OK"; fi
    – hansfn
    Jan 18, 2017 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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