How do you detect the version of asterisk that is running?

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
With the dial plan syntax changes that we have to deal with on a regular basis (between Asterisk 1.4 and 1.6 for example) - it would be very helpful if we could detect what version of Atserisk was running from within the dial plan.

Ive been hunting around for a while, and havent found a way to do this - does anyone have any idea, or refrence link that might help out?
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

Just for interest, try using a , instead of |on the "Gold" release of PiaF. I know that later versions of 1.4 support the use of either.

Joe
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
Thats good to know - Im glad they are making syntaxes obsolete - it really messes with a lot of existing code when they do that.

But for earlier version....

Please check out the Bug ticket here. I have done some research, and there is a possible workaround - but Id like your opinion also.
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
How about this?

Code:
[noah-swift]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(TIMEOUT(digit)=7)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,swift("At the beep enter the five digit zip code for the weather report you wish to retrieve.")
exten => s,n,Read(ZIPCODE,beep,5)
exten => s,n,swift("Please hold a moment while we contact the National Weather Service for your report.")
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)
exten => s,n,GotoIf($["${VERSION}" = "Asterisk 1.6"]?agi16)
exten => s,n,AGI(nvweather-zip.php|${ZIPCODE})
exten => s,n(agi16),AGI(nvweather-zip.php,${ZIPCODE})
exten => s,n,NoOp(Wave file: ${TMPWAVE})
exten => s,n,Playback(${TMPWAVE})
exten => s,n,Hangup

[noah-flite]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(TIMEOUT(digit)=7)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Flite("At the beep enter the five digit zip code for the weather report you wish to retrieve.")
exten => s,n,Read(ZIPCODE,beep,5)
exten => s,n,Flite("Please hold a moment while we contact the National Weather Service for your report.")
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)
exten => s,n,GotoIf($["${VERSION}" = "Asterisk 1.6"]?agi16)
exten => s,n,AGI(nvweather-zip.php|${ZIPCODE})
exten => s,n(agi16),AGI(nvweather-zip.php,${ZIPCODE})
exten => s,n,NoOp(Wave file: ${TMPWAVE})
exten => s,n,Playback(${TMPWAVE})
exten => s,n,Hangup
Myk
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
could make the readfile part into a include conf file setting a specific PIAFASTERISKVER variable, then any of the piaf scripts and use that variable?
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
Both suggestions are good. Would you please post them into the bug ticket here. Your a registered developer on the project - and thats where the bulk of the notes are.
 

Lost Trunk

Guru
Joined
Aug 5, 2008
Messages
228
Reaction score
0
I'm not an expert on this but couldn't you also do something like

System(/usr/sbin/asterisk -rx "show version" > /tmp/version.txt)

...possibly with some additional piping and filtering to extract only the version number - I'm not much of a command line user so I'm not sure which command might be appropriate.

Then you could read the version.txt file to get what you need.
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
You could, but of course the command for asterisk 1.6.2 is "core show version", which means that you have to determine the asterisk version before knowing what command to query the version ??? ;-)

Now could be the time for the cliche'd "bangs head against wall" smiley but they make my teeth itch.

Joe
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
Im sure FreePbx has a variable loaded somewhere with the asterisk version already, but I cant find it. Cause I assume its what has written /etc/asterisk/version in the 1st place.....?
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
the ip-country and weather by airport code are prob broken for 1.6 also because of this - perty much anything that makes a AGI call to a external script is effected
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
You could, but of course the command for asterisk 1.6.2 is "core show version", which means that you have to determine the asterisk version before knowing what command to query the version ??? ;-)

Now could be the time for the cliche'd "bangs head against wall" smiley but they make my teeth itch.

Joe

this is true, but current version of 1.4.21.4 will use the core show version as well, along with the comma instead of the pipe fpr AGI calls, but 1.2 as far as I know uses only the old way.

but again, at what version in 1.4 did they change, so we still have to compensate for older 1.4.x trees.....
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
the ip-country and weather by airport code are prob broken for 1.6 also because of this - perty much anything that makes a AGI call to a external script is effected

Maybe, but I dont have modules for these.
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
How about this?

Code:
[noah-swift]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(TIMEOUT(digit)=7)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,swift("At the beep enter the five digit zip code for the weather report you wish to retrieve.")
exten => s,n,Read(ZIPCODE,beep,5)
exten => s,n,swift("Please hold a moment while we contact the National Weather Service for your report.")
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)
exten => s,n,GotoIf($["${VERSION}" = "Asterisk 1.6"]?agi16)
exten => s,n,AGI(nvweather-zip.php|${ZIPCODE})
exten => s,n(agi16),AGI(nvweather-zip.php,${ZIPCODE})
exten => s,n,NoOp(Wave file: ${TMPWAVE})
exten => s,n,Playback(${TMPWAVE})
exten => s,n,Hangup
 
[noah-flite]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(TIMEOUT(digit)=7)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Flite("At the beep enter the five digit zip code for the weather report you wish to retrieve.")
exten => s,n,Read(ZIPCODE,beep,5)
exten => s,n,Flite("Please hold a moment while we contact the National Weather Service for your report.")
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)
exten => s,n,GotoIf($["${VERSION}" = "Asterisk 1.6"]?agi16)
exten => s,n,AGI(nvweather-zip.php|${ZIPCODE})
exten => s,n(agi16),AGI(nvweather-zip.php,${ZIPCODE})
exten => s,n,NoOp(Wave file: ${TMPWAVE})
exten => s,n,Playback(${TMPWAVE})
exten => s,n,Hangup
Myk


Im really liking this approach.
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
the
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)

is the only surefire way I can figure out asterisk version so far.

I am sure freepbx has a populated variable somewhere already in the dialplan, but i cant find it yet. Am also assuming freepbx is making that version file as well. Its in all the boxes I have check on so far.

should prob modify the gotoif to check grab just the x.x part of the version and do a evail if it is 1.6 or greater for future reference...
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
yes, that is avail on which ever ver of 1.4.x when they implemented it, older versions of 1.4 don't support the core command

Code:
Asterisk 1.4.21.2 built by root @ pbx.local on a i686 running Linux on 2010-07-29 19:30:28 UTC
root@pbxcb:~ $ asterisk -rx "show version"     
Asterisk 1.4.21.2 built by root @ pbx.local on a i686 running Linux on 2010-07-29 19:30:28 UTC
The 'show version' command is deprecated and will be removed in a future release. Please use 'core show version' instead.

by using core command, still need to find out what specific 1.4.x to be able to use it on
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
the
exten => s,n,ReadFile(VERSION=/etc/asterisk/version,12)

is the only surefire way I can figure out asterisk version so far.

I am sure freepbx has a populated variable somewhere already in the dialplan, but i cant find it yet. Am also assuming freepbx is making that version file as well. Its in all the boxes I have check on so far.

should prob modify the gotoif to check grab just the x.x part of the version and do a evail if it is 1.6 or greater for future reference...

Yes - this seems to be the most reliable method - I dont think we have to worry about exaxctly which release supports both, as long as we support the native syntax for each ver.release.
 

MyKroFt

Guru
Joined
Oct 31, 2008
Messages
659
Reaction score
3
found it - defined in extensions_additional.conf in the [global] section

Code:
ASTVERSION = 1.6.2.9
so we can just test against that variable
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,159
Reaction score
5,192
This is another good example of what happens when you're always screwing around with syntax... makes it virtually impossible to write stable code. :eek:
 

Members online

No members online now.

Forum statistics

Threads
25,770
Messages
167,441
Members
19,181
Latest member
ejrubin
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top