I have a bash script and now I need to convert it into php, as a cgi script.See I've a bash line like this
wget http://repo.domain/sources/latest_version.tar.gz > /dev/null 2>&1;
if [ $? != 0 ]
then
echo "Could not download file...";
exit 0;
fi
If I run the wget
using php system/exec
, is there a way to catch the exit status like $?
used in this script? I have read that file download can be done using file_put_contents()
as here in this stackoverflow post.But I'm also concerned about the allow_fopen_url Off
part as one of the comments mentioned.I think I need a more universal solution keeping the changes from bash to php minimum.
How can I catch the exit status here ? Any hint please?