Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Internal Function(s) Missing?

Featured Replies

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?

Solved by KeithAbbott

  • 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 by SimonF

  • 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');

?>

 

  • 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 by SimonF

  • 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 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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.