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.

qazwsx
  • 105
  • 3
  • 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 '14 at 00:47
  • Debian and possible Ubuntu. – qazwsx Sep 19 '14 at 02:04

1 Answers1

2

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

YodaDaCoda
  • 134
  • 3
  • What if there is `/usr/local/php54/bin/php` but the default php is not linked to it? – qazwsx Sep 19 '14 at 02:08
  • @user213607 That contradicts your "another assumption" given in your question. – Michael Hampton Sep 19 '14 at 02:14
  • You mean if php is installed standardly there can't be a `/usr/local/php54/bin/php`? – qazwsx Sep 19 '14 at 02:24
  • That would not fall under the definition of 'standardly installed' for me. – toppledwagon Sep 19 '14 at 06: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 '14 at 07:03