Call record name problem

Discussion in 'General' started by javapaul, Jul 24, 2009.

  1. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    Hello, I'm having a small file name problem, the name format for calls goes something like this q200-20090722-112545-1248279944.1 (for queue calls) and IN-7020-1248284171.86 (for extension calls), been reading all over and from one of Mr Dicko's post i found out about the script i can add to the recording (not sure if is gonna help with my problem), but the problem I'm having is that i need to change this file format name so i can see the phone number on the file name.

    Any response would be appreciated
     
  2. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    coincidentally I just posted:

    http://www.elastix.org/index.php?option ... t=10#31251

    the mysql query I speak about will return among other things that info.

    Just to get you started, send a ${UNIQUEID} that might be 1248456029.6055 (and is embedded in the ${CALLFILENAME} ) to:

    /usr/bin/mysql -u root -peLaStIx.2oo7 -N -B -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst FROM cdr WHERE uniqueid = 1248456029.6055"|sed -s s'/\\s/_/g'


    and the string generated might look something like:
    2009-07-24_10:20:29_From:_2125551212_To:_710

    so a "one-liner" that you can put in the box on the general settings page
    Code:
    mv ^{MIXMON_DIR}/^{CALLFILENAME}.^{MIXMON_FORMAT}  ^{MIXMON_DIR}/`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst FROM cdr WHERE uniqueid = ^{UNIQUEID}"|sed -s s'/\\s/_/g'`.^{MIXMON_FORMAT} >> ^{MIXMON_DIR}/error.txt
    
    might be all you need. (adjust seasoning to taste), if the error.txt file ever shows any content then you blew it!!.


    hope that helps

    (I would suggest you use ln(link) instead of mv(rename) to create a hardlink (and that can be wherever you want on the filesystem) might be less impactful on the other bits of Elastix/FreePBX as to their call monitoring pages. A side effect, beneficial or otherwise,is that even though the original recording is "deleted" the link remains for auditing)
     
  3. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    Ok ill try it out next week, thanks a lot Dicko.
     
  4. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    ok i added the line but it didnt work, i use the ln at the begining but it didnt work either this is what im getting from the CLI log

    Code:
     == Executing [ln /OUT-6013-1248876586.6151.wav  /`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = "|sed -s s'/\s/_/g'`.wav >>]
    
    question whats pelastix.2007 for u dicko? sorry im really new about this altough i know some about db queries.

    Thanks in advance!!!
     
  5. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Quote:

    ln /OUT-6013-1248876586.6151.wav /`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = "|sed -s s'/s/_/g'`.wav >>



    If you used the ^{MIXMON_DIR} it should be in the "recording location" box , (use the default /var/spool/asterisk/monitor to start with).

    the ^{UNIQUEID} is resolving to nothing , check the calling parameters again.

    You are redirecting it nowhere (>> ?) that will cause a problem.

    eLaStIx.2oo7 is the standard password for root on 127.0.0.1, I doubt that it should be changed for numerous reasons.

    but you have enough for diagnostics try from bash:

    /usr/bin/mysql -u root -peLaStIx.2oo7 -N -B -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = 1248876586.6151"

    [edit]

    it was my error you need to use ^ not $ to send to a shell. (I edited the original post)
     
  6. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    ok after runing that query i got this
    Code:
    2009-07-29 09:09:46     From:   6013    To:     8900909 .wav
    
    wich is the correct info for that call :) ok,
    now on the run script box it wont let me add the entire line u gave me so have this in there

    Code:
    mv ^{MIXMON_DIR}/^{CALLFILENAME}.^{MIXMON_FORMAT}  ^{MIXMON_DIR}/`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = ${UNIQUEID}"|sed -s s'/\s/_/g'`.
    i removed ${MIXMON_FORMAT} >> ^${MIXMON_DIR}/error.txt thinking it just a log file but still didnt work, i was reading about your recording script on that related post of you and its really good stuff, just didnt quite get it.

    Thanks again
     
  7. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    :) :)

    remove three unnecessary characters, dupe spaces, maybe From: == F: and To: == T: until you can add the wav ( ^{MIXMON_FORMAT} ) at the end, or just parameterize the needed variables and send to a script
     
  8. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    theres the problem i dont understand how to send it to a scrip file, should it be something like this

    1. create a .sh file (example.sh)
    2. inside the file add the following lines
    Code:
    #!/bin/bash
    /usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = ${UNIQUEID}"|sed -s s'/\s/_/g'`.
    
    and on the run script box

    Code:
    /var/lib/asterisk/bin/example.sh ^{UNIQUEID} ^{MIXMON_DIR} ^{CALLFILENAME} ^{MIXMON_FORMAT} >> /var/spool/asterisk/monitor/error.txt
    perhaps im totally wrong and dont know what the hell im talking about but let me know thanks dicko!!
     
  9. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Perhaps you don't know what the hell you are talking about right now, but a short visit with a good bash script tutorial as to parameter replacement and you will :) :) :)

    basically call the script with the needed ^{*} parameters

    example.sh ^{UNIQUEID} ^{CALLFILENAME} . . .

    the are available inside your script as $1 $2 etc.

    . . . WHERE uniqueid = ${UNIQUEID} . . .
    would be

    . . . WHERE uniqueid = $1 . . .

    etc.

    Time to go fishing my friend B)

    hint 1: get rid of the error redirection, that would be better handled in your script

    hint 2: Don't forget to make the script executable

    hint 3: watch where your lines break in the bash script (copy and paste can get you in trouble on this software)

    (sh is arguably a preferable shell for the script than bash)
     
  10. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    ok gonna take your advice, and start reading about scripting so but right now i would like just to use the 1 liner.

    for the run script box i put the following

    Code:
    mv ^{MIXMON_DIR}/^{CALLFILENAME}.^{MIXMON_FORMAT}  ^{MIXMON_DIR}/`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = ^{UNIQUEID}"|sed -s s'/\s/_/g'`.^{MIXMON_FORMAT}
    in the CLI log i get this

    == Executing [mv /OUT-6073-1248884403.6396.wav /`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst,'.wav' FROM cdr WHERE uniqueid = 1248884403.6396"|sed -s s'/\s/_/g'`.wav]

    and the format still the same OUT-6073-1248884403.6396.wav

    any ideas or should i start reading a good bash scripting tutorial :) thanks again!!!
     
  11. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Still no directory ( ^{MIXMON_DIR} ) , did you add

    /var/spool/asterisk/monitor

    in the "recording location" box as I suggested?
    . . .'.wav' . . . is spurious in your mysql query as you then append '.^{MIXMON_FORMAT}' (which is '.wav' of course) to the returned string.

    Personally I find google quite useful when I'm looking for things B)
    dicko
     
  12. javapaul

    Joined:
    Jul 1, 2009
    Messages:
    99
    Likes Received:
    0
    :woohoo: THANKS A LOT DICKO, i totally forgot to put /var/spool/asterisk/monitor/ on the recording location Thanks a lot!!!!! it worked!
     
  13. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Your Welcome.

    That's the glory of all this open source stuff, you can do almost anything you want.

    Keep exploring
     
  14. jhansen858

    Joined:
    Jul 23, 2010
    Messages:
    11
    Likes Received:
    0
  15. garvey2003

    Joined:
    Sep 15, 2010
    Messages:
    3
    Likes Received:
    0
    I know this has not been on for a while and im new but just getting into elastix.
    this seems to do what I want.

    I understand the sql part as i've used sql for an age but the problem im having is when I apply your script it changes the file as it should but the file name turns into some weird bunch of letters like 2U0KL4~R.WAV

    Im adding this to the run after field
    Code:
    mv ^{MIXMON_DIR}/^{CALLFILENAME}.^{MIXMON_FORMAT}  ^{MIXMON_DIR}/`/usr/bin/mysql -u root -peLaStIx.2oo7 -N -B  -D asteriskcdrdb -e "SELECT calldate,'From:',src,'To:',dst FROM cdr WHERE uniqueid = ^{UNIQUEID}"|sed -s s'/\\s/_/g'`.^{MIXMON_FORMAT}  >> ^{MIXMON_DIR}/error.txt
    
    I do not get an error.txt file either. reading the line of code I I see you are saying move file A to File B with SQL items as the file name if error log.

    Any suggestions?

    I will say, im enjoying this. its been awhile since i've done something interesting :woohoo:
     

Share This Page