Pass values from sheel or file to asterisk?

HI its me again !!! :smile:

i try to extract some value from a log file , try to pass it to asterisk and then just save it on asterisk db… so it would be like this

tail -n 1 /var/log/asterisk/full | cut -d | -f4 |cut -d / -f2

the result would be something like this
1010
then in some way i need to pass this value to asterisk, and after that just
do :
database put fromlog 110 1010

how can a do that ??? i can put that value after the tail in a file but then??..or if there is another easy way would be better

thanks for the future answere !!

Something like

myvar=System(tail -n 1 /var/log/asterisk/full | cut -d | -f4 |cut -d / -f2);

Then insert in to the db using whatever method you want… agi, put() etc

Sorry dont cath ya…but it would be something like this

exten => 800,n,set(myvar=System(tail -n 1 /var/log/asterisk/queue_log | cut -d | -f4 |cut -d / -f2))

or put it as global

[globals]
myvar=System(tail -n 1 /var/log/asterisk/queue_log | cut -d | -f4 |cut -d / -f2)

i put it on extension.conf
?? :unamused:

That’s correct.

mmm none of them work it ! :cry:

Hi What value are you trying to get from the log file. are you sure you cant get it internally, Not much isnt written to log that cant be got internally

Ian

Check out it work under shell …
[root@server asterisk]# tail -n 1 /var/log/asterisk/full| cut -d | -f4 |cut -d / -f2
spa400-0a024310
[root@server asterisk]#

:bulb:

Ok but what is it you are after is the channel UA or what ?

Perhaps if you showed the FULL line of the log file and then highlight the data you want, we may be able to assist more. personally I dont see why you are trying to extract it from the logfile.

Ian

check out the ful line

[root@server asterisk]# tail -n 1 /var/log/asterisk/full| cut -d | -f4 |cut -d / -f2
spa400-0a047df0
[root@server asterisk]# tail -n1 /var/log/asterisk/full
[Mar 5 10:06:27] VERBOSE[31599] logger.c: – SIP/spa400-0a047df0 answered SIP/122-b6a41618
[root@server asterisk]#

the fact is that i need to grab that data and try to pass it to asterisk, no matter what could be. :cry:

Hi

So you are you want the called channel ? the MAJOR flaw with what you are trying to do is that you cannot be sure that the line you read is the line that references the call. logging is a low priorty so if two calls answer at teh same time there is a change that the log will have the second calls data before teh first call looks at it or even some other data totaly inconnected…

I would look at getting the data via variables not trying to read from a logfile. its just not going to scale much beyond a test enviroment of a couple of phones.

Ian