Can't run an external script - need help

I’m trying to run an external script, lets say "reboot the server"
This is what I did:

  1. In extentions_custom.conf I put this:

    [custom-restart-server]
    exten => restartserver,1,Answer
    exten => restartserver,2,Playback(agent-logoff)
    exten => restartserver,3,system(reboot)
    exten => restartserver,4,Hangup()

  2. In Custom Destinations I added:
    Custom Destination: custom-restart-server,restartserver,1
    Description: restartmyserver

  3. In my IVR I added:
    Ext:8 , Destination: Custom Destination restartmyserver

Now I can call my machine and the IVR is answering, but if I press 8 the line just hangup.
What am I doing wrong?

Thanks

The Asterisk user does not have permission to shutdown the server (honestly it shouldn’t)

It try another and it didn’t work:
I changed the extentions_custom.conf I put this:

[custom-restart-server]
exten => restartserver,1,Answer
exten => restartserver,2,Playback(agent-logoff)
exten => restartserver,3,Hangup()

So it will just play a sound and hangup.
It didn’t play it.

can you provide a call trace

Hi Itzik,

You are doing it wrong. You should replace the restartserver in _X! like this:

[custom-restart-server]
exten => _X!,1,Answer
same => n,Playback(agent-logoff)
same => n,Hangup()

In your custom destination change it to:

custom-restart-server,${EXTEN},1

You will probably would have to delete your old custom destination.

Thank you,

Daniel Friedman
Trixton LTD.

and this is what I found in the log:

pbx.c: Channel ‘Dongle/dongle0-0100000000’ sent to invalid extension but no invalid handler: context,exten,priority= custom-restart-server,restartserver,1

Daniel: I did the what you wrote (changed [custom-restart-server] and ( custom destination), The same. the call is hangup.

Hi Itzik,

You did not change the name of your custom destination.

Thank you,

Daniel Friedman
Trixton LTD.

Hi Itzik,

Take another look at my previous answers.

Thank you,

Daniel Friedman
Trixton LTD.

This my configuration:

Hi,

Show me a detailed log again. I think that the IVR sends you to a different destination.

Thank you,

Daniel Friedman
Trixton LTD.

Stop the madness.

@danielf, your suggestions won’t work. Please test diaplan before posting,

@itzikbereby, go back to your original dialplan before the suggestions and try playing a different sound file that is known to work.

[2015-11-04 19:07:36] DTMF[1839][C-00000003] channel.c: DTMF begin ‘8’ received on Dongle/dongle0-0100000003
[2015-11-04 19:07:36] DTMF[1839][C-00000003] channel.c: DTMF begin ignored ‘8’ on Dongle/dongle0-0100000003
[2015-11-04 19:07:36] DTMF[1839][C-00000003] channel.c: DTMF end ‘8’ received on Dongle/dongle0-0100000003, duration 280 ms
[2015-11-04 19:07:36] DTMF[1839][C-00000003] channel.c: DTMF end passthrough ‘8’ on Dongle/dongle0-0100000003

Hi Lorne,

I suggest you cool it major buddy. What sort of madness do you see here exactly???
My dialplan works perfectly.

Thank you,

Daniel Friedman
Trixton LTD.

1 Like

Hi Itzik.

Why are you not showing all the log? I do not need to see the DTMF. I need to know what is going on after you are pressing on the 8 digit.

From your previous log it seems that you do not change your custom destinations.

pbx.c: Channel 'Dongle/dongle0-0100000000' sent to invalid extension but
 no invalid handler: context,exten,priority=custom-restart-server,restartserver,1

You should see something like that:

pbx.c: Channel 'Dongle/dongle0-0100000000' sent to invalid extension but
 no invalid handler: context,exten,priority=custom-restart-server,8,1

Thank you,

Daniel Friedman
Trixton LTD.

I’ve been promoted, my current rank is Lieutenant Colonel Buddy.

2 Likes

Hi,
First, sorry for the mess.

Lorne, You right, my dialplan was good but with wrong sound file, I fix it and with a little change I can now restart the server from the IVR, BIG THANKS.

Daniel , Your dialplan didn’t work for me but thanks anyway.

Itzik

1 Like

Hi,

You had a mistake in your custom destination name and in your audio file name. Your dial plan is bad and you should not write it in this style. Always keep a strict dial plan to avoid breaking to your pbx through the IVR. If you would have attached the logs to your post, I would have told you immediately that you had a mistake in your audio file name.

Thank you,

Daniel Friedman
Trixton LTD.

Hi Itzik,

I took a second look at my dialplan sample and realize that I made a mistake during writing it. I have corrected it at the previous post and I am attaching it here again. It is a better approach to write it.

[custom-restart-server]
exten => _X!,1,Answer
same => n,Playback(agent-logoff)
same => n,Hangup()

Thank you,

Daniel Friedman
Trixton LTD.

@danielf

Your dial plan fine, but you repeatedly miss your error; which is your advice to structure the Custom Destination. If we create a Custom Destination in the GUI then examine extensions_additional.conf, we will see content like this:

[customdests]
include => customdests-custom

exten => dest-6,1,Noop(Entering Custom Destination Missed Call script)
exten => dest-6,n,Goto(missing,2002,1)

The part in parentheses on the goto line is the content of the field in the GUI for the custom destination. Note the extension “dest-6”, the user has no control over that, it is generated by FreePBX. Your advice to use ${EXTEN} as part of the Custom Destination and _X! for the dial plan won’t work because they will never match. I can’t envision any circumstance where it would be useful or correct to use ${EXTEN} in a custom destination.

Your first post to this thread has the misinformation, it has been edited twice and is still wrong. Please test and confirm for yourself. The op’s very first post had dial plan and a custom destination definition that work fine except for the sound file issue.

@lgaetz

I am doing that for years and I think that you do not understand what I am doing.
Every time I need to bypass the Freepbx dial plan, this is the way I do it through the GUI.
I am writing my own context in the extension_custom.conf file and sending the channel to this context.

My mistake in the example I have provided was the typo of the same extension and that is why I have corrected it.

There is nothing wrong to learn something new once in while, so please have respect to other people experience.

Thank you,

Daniel Friedman
Trixton LTD.