Re: bilingual scripts, bash/PHP?



Richard Kettlewell <rjk@xxxxxxxxxxxxxxx> writes:

crankypuss <no@xxxxxxxxxxxx> writes:
Okay, a bash script has to start with this:

#!/bin/bash

And a PHP script begins suchly:

#!/usr/bin/php
<?php
// code
?>

The question is, how can one code a script that will run PHP if it's
available and if not fall back to bash?

Possibly easier to do it the other way around (certainly so for me since
I don't speak PHP).

#! /bin/bash
set -e
if type php >/dev/null 2>&1; then
exec php /path/to/php/script

Should be:
exec php /path/to/php/script "$@"
of course, to be fully general.

--
http://www.greenend.org.uk/rjk/
.



Relevant Pages

  • Re: Attempt to de-mystify AJAX
    ... created and populated by the PHP script. ... string is initialized in line 1 to the opening select tag. ...
    (comp.databases.pick)
  • Re: File permissions for a wiki-like site
    ... the content using PHP scripts. ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ... The web user is used for things like ...
    (comp.lang.php)
  • Re: File permissions for a wiki-like site
    ... the content using PHP scripts. ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ... The web user is used for things like ...
    (comp.lang.php)
  • Re: File permissions for a wiki-like site
    ... the content using PHP scripts. ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ... The web user is used for things like ...
    (comp.lang.php)
  • Re: High Scores
    ... If you want to view High scores it returns Could Not load scores ... here is the PHP script ... Edit the game Flash file to point to this file on your server ... >> And the PHP script is here ...
    (alt.php)