0

An automatic upgrade Bash script requires PHP executable 5.3+, how do I ensure that is the case in the upgrade script? I'd like the script to quit and generate some message into the log when php 5.3+ is not available.

Update: the servers where I currently need this to work is Debian and in near future it'll be Ubuntu. Another assumption is that PHP are "standardly" installed.

2
  • I highly doubt there is going to be a generic answer to this if you don't limit your target system in some way. Can you be assured that this is limited to a single Linux distro? Can you assume the package was installed with the distro packaging system? Are you certain the PHP CLI will be available, and not just the apache module?
    – Zoredache
    Sep 19, 2014 at 0:47
  • Debian and possible Ubuntu.
    – qazwsx
    Sep 19, 2014 at 2:04

1 Answer 1

2

php -r 'print_r(version_compare("5.3", phpversion()));'

5
  • What if there is /usr/local/php54/bin/php but the default php is not linked to it?
    – qazwsx
    Sep 19, 2014 at 2:08
  • @user213607 That contradicts your "another assumption" given in your question. Sep 19, 2014 at 2:14
  • You mean if php is installed standardly there can't be a /usr/local/php54/bin/php?
    – qazwsx
    Sep 19, 2014 at 2:24
  • That would not fall under the definition of 'standardly installed' for me. Sep 19, 2014 at 6:20
  • You mean if php is installed standardly - Per Debian policy no official package can place files under /usr/local. Someone could build a deb package that would drop files their, but you certainly will never see that on a package from the Official Debian/Ubuntu repos.
    – Zoredache
    Sep 19, 2014 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .