PHP Warning: fopen(/var/www/html/supermon/astdb.txt): Failed to open stream

this is the message I'm getting when i run "sudo -u asterisk /etc/asterisk/scripts/astdb.sh"

PHP Warning: fopen(/var/www/html/supermon/astdb.txt): Failed to open stream: Permission denied in /var/www/html/supermon/astdb.php on line 98
Cannot open /var/www/html/supermon/astdb.txt./etc/asterisk/scripts/astdb.sh: line 12: astdb.txt.1: Permission denied
mv: cannot stat 'astdb.txt.1': No such file or directory

Hi! You could try getting direct root access by typing sudo -s and then typing your command without sudo /etc/asterisk/scripts/astdb.sh

Look in said files and show us what is on lines in error

But it looks like a permission/ownership of the files being called.

You also need to state what version of asl and supermon you are dealing with.

sudo -s works fine no warnings come up

hey mike

here is the astdb.php file, i'm not sure how to find what your looking for

astdb.php.txt (2.9 KB)

ASL Version: Asterisk 22.2.0+asl3-3.3.0-6.deb12
SM Version: 7.4+

Then definitely a permissions issue as @Mike stated.

You could cd into the folder and type ls -a which will show the owners of that file and the permission level. If it is working with sudo -s and that's not an issue then you could always use it with that.

What mike is saying is that in the error it says line 98 is causing the issue so share that line from within the file.

I think maybe if you add your asterisk user to the www-data (or the relevant user group) then the issue will get resolved.

A 'shell script' is just a list of commands that you can run from the command line. But you must have the right of the files.. All asl files will be owned by user asterisk and group asterisk.

But I don't know what this is., sorry I don't use supermon

Go to this file and see what is on line 12

But the other error seems to be that the asterisk db is not opening for reading.
Likely causing the other error.

That is the best I can guess from what you presented.

line 12 = $SMDIR/astdb.php ${Arg}; cd $SMDIR; cat astdb.txt |sort -nu > astdb.txt.1; mv astdb.txt.1 astdb.txt

ls -a
total 20
-rwxr-xr-x 1 root root 47 Feb 4 11:29 allmon3-restart
-rwxr-xr-x 1 root root 44 Feb 4 11:29 allmon3-stop
-rwxr-xr-x 1 asterisk asterisk 274 May 16 02:47 astdb.sh
-rwxr-xr-x 1 root root 59 Feb 4 11:29 asterisk-restart
-rwxr-xr-x 1 root root 45 Feb 4 11:29 asterisk-stop

does astdb.txt exist ?

Is it owned by asterisk ? permissions ?

yes and yes
i think it is
-rw-r--r-- 1 root root 1404661 May 18 12:53 astdb.txt - sm folder
-rw-r--r-- 1 asterisk asterisk 1406215 May 18 12:51 astdb.txt - asterisk folder

I'm not worried about fixing it as its only you update the astdb.txt file from dtmf
so I'll make this as closed

1 Like

I see you added additional info since yesterday.

root:root

Without any context on the files & location I can't say any more.

But you do need to say if you are using asl3 or what you are using if you still need help.