Reputation: 379
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
Upvotes: 1
Views: 123
Reputation: 14447
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.
Upvotes: 2