Problem with starting a bash-Script

Hey Ho,

I´m new about asterisk, but I like it a lot. So I already tried a lot, but still can´t get him working! I just want to start a script, written in Bash.
But first something about my System, I´m using Debian, it´s up to date, also like Asterisk and all the other programms. I´m able to call my Asterisk, answer the Call, play some Music or soundfiles, so please take a look at my Sourcecode and tell me what´s wrong!

exten => 11,1,Answer() exten => 11,2,Background(marryme) ;exten => 11,n,TryExec(/etc/asterisk/scripte/laptop) exten => 11,n,System(/etc/asterisk/scripte/laptop) exten => 11,n,System(echo '${DATETIME} - ${CALLERID} - ${CHANNEL}' >> /etc/asterisk/log/anrufe/11 exten => 11,n,Playback(thank-you-cooperation) exten => 11,n,Playback(thank-you-cooperation)

Die Fehlermeldung: [quote][Aug 7 04:41:37] WARNING[16121]: app_exec.c:150 tryexec_exec: Could not find application (/etc/asterisk/scripte/laptop)[/quote]

That´s just a part, but the relevant part. So, do you know what I need to do? :mrgreen:

Bye Bye :smile:

Edit: What I forgot to say, the rights of the script are 755, the path is correct and the script starts and works if I start it at the prompt!

What user is asterisk running as and what user did you check it ran as ? normally the problem is that asterisk is running as asterisk andteh script is created by root.

su asterisk and try again


YOu´re right… Asterisk runs as asterisk. I tried to start the script like this su asterisk /etc/asterisk/scripte/laptop but it didn´t work… So I changed the rights to 777, the owner of this script is already asterisk. (chown asterisk /etc/asterisk/scripte/laptop)

I also tried to login as asterisk and create the script directly out of this account, but don´t know the password. I never set a password for this account.

Donßt know what to do else… :frowning:


chown asterisk:asterisk /etc/asterisk/scripte/laptop

su asterisk

ls -l /etc/asterisk/scripte/laptop


and post any errors

Okay, I changed the owner, now it looks like this:

-rwxrwxrwx 1 asterisk asterisk 52 Aug 4 07:39 laptop -rwxrwxrwx 1 asterisk asterisk 53 Aug 4 07:39 pc

After typing

[quote]su asterisk
the script worked correct again, but only via command prompt, not because of calling…

The error in the asterisk-cli:

[Aug 7 06:06:19] WARNING[16321]: app_exec.c:150 tryexec_exec: Could not find application (/etc/asterisk/scripte/laptop)

But I´m totaly sure the script is there, and the rights are fine! … :frowning:

Could the packager have gone really paranoid and run Asterisk in a chroot jail?

I´m not sure I got it correctly. You think asterisk isn´t able to read/write/execute something out of his normal folder?

It is possible that the person who created the Debian package tried to make it really secure by making it run with a changed root directory. The purpose of this would be to minimise the ability of anyone who succeeded in a privilege escalation attack’s ability to access resource on the host system. Programs started by Asterisk would see an almost empty file system, with only Asterisk specific files.

In my experience the result of packagers’ attempts to make Asterisk more secure are always to cause grief.

Does the Debian package come from Debian, or from Digium. In the former case, you really should seek support from Debian.

If this is not the case, it is likely that Asterisk is misinterpreting a permission denied condition, so you should check that the asterisk user has sufficient rights on all the directories leading to the script. You should also check for features like SELINUX, if Debian uses it.

Incidentally, giving files mode 777 pretty much defeats the intention behind running Asterisk non-root!

Hey I´m affraid you´re right… It looks like it´s because of Debian, that´s sad.
I used to install asterisk via apt-get install asterisk so it needs to be the Debian-Version.

What do you think, should I use the AsteriskNow Distribution? Do you use it? Or what´s your favourite?

Thanks a lot for your help!

Ok I missed something obvious here, you say you have a problem with the System application , but the error is todo with teh tryexec_exec application

[code] -= Info about application ‘TryExec’ =-

Executes dialplan application, always returning

Usage: TryExec(appname(arguments))
Allows an arbitrary application to be invoked even when not
hardcoded into the dialplan. To invoke external applications
see the application System. Always returns to the dialplan.
The channel variable TRYSTATUS will be set to:
SUCCESS if the application returned zero
FAILED if the application returned non-zero
NOAPP if the application was not found or was not specified[/code]

not System

check you dialplan and reload it.

I´m sorry, but that was the wrong screenshot. I used to try it with TrySystem, System, TryExc or Exec but nothing worked! I also tried to put the command directly into the TrySystem-command, like this TrySystem(etherwake 00:XX:XX:XX:XX:XX), but it also didn´t work!

exten => 11,1,Answer() exten => 11,n,System(echo '${DATETIME} - ${CALLERID} - ${CHANNEL}' >> /etc/asterisk/log/anrufe/anrufe11 exten => 11,n,TrySystem(/etc/asterisk/scripte/laptop) exten => 11,n,TrySystem(etherwake 00:A0:D1:BB:47:4C) exten => 11,n,System(etherwake 00:A0:D1:BB:47:4C)

I´m frustrated… but thanks a lot for your help till now :smile:

Unless I am misunderstanding something in this thread, if Asterisk was installed chroot’ed, then I think all you’d need to do is place that script in the correct directory in order for Asterisk to find it.

I also tried to put the script into /var/lib/asterisk/agi-bin but it still didn´t work!
But let´s take a look at the whole Problem. I just want to execute a command (etherwake xx:xx:xx…), it would be more clear with a bash-script, because I have to wake up about 40 to 50 computers, but it´s also okay to put the etherwake-ommand directly into the dialplan, but I don´t know how to do that ant the script isn´t executed by asterisk, but I don´t know why!

Can you provide output from this code:

exten => 11,1,Verbose(Testing....) exten => 11,n,Set(FNAME=/etc/asterisk/scripte/laptop) exten => 11,n,Verbose(Size: ${STAT(s,${FNAME})}) exten => 11,n,Verbose(Mode: ${STAT(m,${FNAME})}) exten => 11,n,Verbose(${FILE(${FNAME},,100)}) exten => 11,n,TrySystem(${FNAME}) exten => 11,n,Verbose(${SYSTEMSTATUS}) exten => 11,n,Hangup()

Also das wurde auf der CLI ausgespuckt:

[quote]Connected to Asterisk currently running on AsteriskJan (pid = 12833)
Size: 52Jan
Mode: 100755
[Aug 10 10:57:45] ERROR[12867]: pbx.c:1550 ast_func_read: Function FILE not registered

Hoffe es hilft dir weiter!

APPERROR Specified command successfully executed, but returned error code

Shows us your script

At the moment it´s looking like this:


for i in {1…10};
echo "Wecke Laptop auf!"
etherwake 00:A0:D1:BB:47:4C
sleep 1

I tried it at the console and it worked correctly!

I also thought about starting the command with a PHP-Script, I know it doesn´t make much sense, but I just can´t get it working with my bash-script!

You tried it as root. Switch to user asterisk:

and try again.

Now read about setuid.

You can also try this:

etherwake doesn’t exist on my system, but I would strongly suspect that it can only be run by root, in which case there is no point in trying to invoke it from a packaged Asterisk set to run non-root.

Also, it is very likely to be in /usr/sbin, which will only be in root’s PATH. I suspect that either no PATH is set, or because it is running non-root, PATH is set as for a normal user, without /usr/sbin.