I have the following files:
vars.txt
C=1234567890
Ascript.php
#!/usr/bin/php
<?php
var $C="$argv[1]";
echo "\n $C \n";
$con = mysql_connect('localhost','root','123') or die ("No connected");
mysql_select_db("test_database",$con);
if($C !=''){
$rs = mysql_query("SELECT name FROM test_table WHERE `identifier`= '$C'");
while($fields = mysql_fetch_row($rs)){
$file = fopen("/var/log/Test/Result.txt","a") or die ("No created");
for ($i=0, $x=count($fields); $i < $x; $i++){
fputs($file, "$fields[$i]\n");
fclose($file);
}
}
}
else {
echo "There is not identifier \n";
}
mysql_close($con);
?>
Bscript.sh
#!/bin/bash
C=`grep -oPa '[Cc]=[^\s]+' /var/log/Test/vars.txt|cut -d= -f2|sed -e 's/-//'`
echo -e "Identifier: $C"
`php -f /root/Ascript.php $C`
When I execute from cli:
[me]# php -f Ascript.php 1234567890
There's no problem!
But if I execute:
[me]# ./Bscript.sh
(Bscript has 755 permissions) I get this:
Identifier: 1234567890
./Bscript.sh: line 4: 1234567890: command not found
Even if I write the value directly in my Bscript.sh
...
`php -f /root/Ascript.php 1234567890`
I get the same error.