1

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

1
  • so where's $shelltest defined? Commented Dec 15, 2014 at 20:11

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That worked. The $ in front of the shelltest was part of the problem and adding your script change also helped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.