I am trying to execute a simple PHP script from a simple BASH script. The answers on this website don't answer my issue.
Here is my BASH script
#!/bin/sh
railmove="/usr/bin/php -q /home/username/subfolder"
php "$railmove"/$shelltest.php
Here is my PHP script
#!/usr/bin/php
<html>
<head>
</head><body>
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
require('connect_db.php');
$timer="222222";
$railinfo2=$mysql_link->prepare('INSERT INTO stillrunning(timer) VALUES(:timer)');
$railinfo2->execute(array(':timer'=>$timer));
$mysql_link=null;
?>
</body>
</html>
I get the following error when I run my BASH script from the command line.
Could not open input file: /usr/bin/php -q /home/username/subfolder/.php
I have tried typing /usr/bin/php -q /home/username/subfolder/durable2.sh and that works fine. ie it runs
asked Dec 15, 2014 at 20:09
user2635961
3795 silver badges20 bronze badges
1 Answer 1
You already include /usr/bin/php in the $railmove string. You don't need to specify php again as a new command. Also, $shelltest doesn't appear to be defined.
So:
#!/bin/sh
railmove="/usr/bin/php -q /home/username/subfolder"
$railmove/your-php-script.php
might work.
answered Dec 15, 2014 at 20:14
Andrew
14.5k4 gold badges47 silver badges66 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
user2635961
Thanks. That worked. The $ in front of the shelltest was part of the problem and adding your script change also helped
default
$shelltestdefined?