What could be causing the Inappropriate ioctl for device error when executing the script via PHP