December 26, 20223 yr I just upgraded from 6.10.3 to 6.11.5, no real issues with the upgrade. I see that Unraid now has PHP included, which is really nice. However, I am trying to execute a small PHP script from the Unraid Terminal, using the following command: php -f /mnt/user/sagemedia/pictures/DeleteOrphanedRecordingFiles.php I get the following error: Fatal error: Uncaught Error: Call to undefined function scandir() in /mnt/user/sagemedia/pictures/DeleteOrphanedRecordingFiles.php:18 scandir is a PHP internal/built-in function (since version 5), so I'm not sure what I am doing wrong that Unraid's PHP is not recognizing it. Any ideas?
December 26, 20223 yr Community Expert 28 minutes ago, KeithAbbott said: I just upgraded from 6.10.3 to 6.11.5, no real issues with the upgrade. I see that Unraid now has PHP included, which is really nice. However, I am trying to execute a small PHP script from the Unraid Terminal, using the following command: php -f /mnt/user/sagemedia/pictures/DeleteOrphanedRecordingFiles.php I get the following error: Fatal error: Uncaught Error: Call to undefined function scandir() in /mnt/user/sagemedia/pictures/DeleteOrphanedRecordingFiles.php:18 scandir is a PHP internal/built-in function (since version 5), so I'm not sure what I am doing wrong that Unraid's PHP is not recognizing it. Any ideas? root@computenode:~# /mnt/user/appdata/test array(21) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(22) "community.applications" [3]=> string(6) "emhttp" [4]=> string(13) "file.activity" [5]=> string(19) "fix.common.problems" [6]=> string(9) ".ICE-unix" [7]=> string(9) "mover.php" [8]=> string(4) "nics" [9]=> string(13) "notifications" [10]=> string(7) "plugins" [11]=> string(11) "recycle.bin" [12]=> string(9) "snapshots" [13]=> string(15) "snapshots_27528" [14]=> string(15) "start_snapshots" [15]=> string(18) "unassigned.devices" [16]=> string(13) "update-helper" [17]=> string(11) "usb_manager" [18]=> string(12) "user.scripts" [19]=> string(9) ".X11-unix" [20]=> string(23) "zfs.master-session.data" } root@computenode:~# cat /mnt/user/appdata/test #!/usr/bin/php <?php var_dump(scandir("/tmp")) ; root@computenode:~# This works fine for me, try adding #! and <?php to the code. chmod +x and then run the file. Edited December 26, 20223 yr by SimonF
December 26, 20223 yr Author I added #! as the first line, and changed the permissions for the .php file to 777. I already had <?php in the code. Still getting exact same error message as before. Here is the stripped down php script that I am executing: #!/usr/bin/php <?php $files2 = scandir('/tmp'); ?>
December 26, 20223 yr Community Expert 43 minutes ago, KeithAbbott said: I added #! as the first line, and changed the permissions for the .php file to 777. I already had <?php in the code. Still getting exact same error message as before. Here is the stripped down php script that I am executing: #!/usr/bin/php <?php $files2 = scandir('/tmp'); ?> Not sure why this does not run for you. root@computenode:~# /mnt/user/appdata/test array(21) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(22) "community.applications" [3]=> string(6) "emhttp" [4]=> string(13) "file.activity" [5]=> string(19) "fix.common.problems" [6]=> string(9) ".ICE-unix" [7]=> string(9) "mover.php" [8]=> string(4) "nics" [9]=> string(13) "notifications" [10]=> string(7) "plugins" [11]=> string(11) "recycle.bin" [12]=> string(9) "snapshots" [13]=> string(15) "snapshots_27528" [14]=> string(15) "start_snapshots" [15]=> string(18) "unassigned.devices" [16]=> string(13) "update-helper" [17]=> string(11) "usb_manager" [18]=> string(12) "user.scripts" [19]=> string(9) ".X11-unix" [20]=> string(23) "zfs.master-session.data" } root@computenode:~# cat /mnt/user/appdata/test #!/usr/bin/php <?php $files = scandir('/tmp') ; var_dump($files) ; root@computenode:~# Edited December 26, 20223 yr by SimonF
December 26, 20223 yr Author Solution It seems to be working now. I think I was supplying an invalid directory name to the scandir function, and the error that was being returned was a red herring. Thanks for your help, SimonF! p.s. Turns out that wasn't the root cause of the problem. I was pasting in some code snippets, and what looked to be spaces in the code were actually a non-space character. Once I figured that out and over-typed with actual spaces, everything started working smoothly. I sure was getting some strange results until I found the actual problem. Edited December 27, 20223 yr by KeithAbbott
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.