I have created shell script:
#!/bin/bash
file="/home/upload/ftp/$1.ifc"
if [ -f "$file" ]
then
echo "Found."
else
echo "Not found."
fi
IfcConvert --use-element-guids /home/upload/ftp/${1}.ifc /home/upload/ftp/${1}.dae
When I go to linux terminal and execute it from there with
./script.sh drevodomek
everything works fine.. I got "Found." message and also converter executes
But when I created helper.php
<?php
if (file_exists("/home/upload/ftp/drevodomek.ifc"))
{
echo "The file exists";
}
else
{
echo "The file does not exists";
}
$cmd = "./script.sh drevodomek";
$results = shell_exec($cmd);
echo $results
?>
I get answers:
"The file exists." from PHP,
"Found." from script.sh
IfcConvert: input file "/home/upload/ftp/drevodomek.ifc" doesn't exists. from script.sh
I am new to linux, has anyone any idea what is the difference running script from terminal and with shell_exec()? Thanks!
The problem was with the rights, seems like terminal was run as root, but php exetuted script as normal user. Always check your 777!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.