I am getting the following response in ssh when trying to run this php script… it worked fine under php 5.2 and now with 5.3 installed I am running into trouble. I cannot see what is wrong.
The errors :
line 1: ?php: No such file or directory
line 2: syntax error near unexpected token `0′
line 2: `set_time_limit(0) ;’
Here is the script.
<?php
set_time_limit(0) ;
$arr = explode("/",$_SERVER['SCRIPT_FILENAME']);
$ct = count($arr);
unset($arr[$ct-1]);
$path=implode("/",$arr);
$path=$path."/";
if(is_file($path."state.txt"))
{
$lines = file($path."state.txt");
if($lines)
{
foreach($lines as $line)
{
if($line)
{
$state = trim($line);
if(!is_dir($path.$state))
{
@mkdir($path.$state,0777);
if(is_file($path."copieble/state/index.php"))
{
$from = $path."copieble/state/index.php";
$to = $path.$state."/index.php";
@copy($from,$to);
}
}
}
}
}
}
@chdir($path);
$handle=opendir('.');
while (($file = readdir($handle))!==false)
{
@chdir($path);
if (($file != ".") && ($file != ".."))
{
if(is_dir($file) && $file != "copieble" && $file !="_vti_cnf")
{
if(is_file($path.$file.".txt"))
{
$lines = file($path.$file.".txt");
if($lines)
{
foreach($lines as $line)
{
if($line)
{
$city = trim($line);
@chdir($path.$file);
if(!is_dir($city))
{
@mkdir($city,0777);
if(is_file($path."copieble/city/index.php"))
{
$from = $path."copieble/city/index.php";
$to = $path.$file."/".$city."/index.php";
@copy($from,$to);
}
}
}
}
}
}
}
}
}
closedir($handle);
include("reflect_changes.php");
?>
I’m guessing that you’re running it like this:
Try running it like this:
The reason the first would error is that when you try to run it like an executable, the shell first looks to see if there’s a hashbang. If so, it runs it with that interpreter. If not (like in your case), it tries to run it as an executable. That, too, fails, so it resorts to trying to execute it as a shell script.
<?phpin a shell script would try to start reading from a file called?phpand pipe that into a command that follows, but there’s no file called?phpto read from. Thus, it errors.