Advertisement
Guest User

Untitled

a guest
Feb 27th, 2013
1,224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. AMI_HOST=127.0.0.1
  4. AMI_PORT=5038
  5. AMI_USER=test
  6. AMI_PASS=test
  7.  
  8. CALLERID='"Petr Pyatochkin" <23450392089>'
  9. CALL_CONTEXT=from-local-dialer
  10. TARGET_CONTEXT=conf
  11.  
  12. FAILED_LIST=failed.txt
  13.  
  14. :> ${FAILED_LIST}
  15.  
  16. for num in $*; do
  17.     res_str=$(cat <<EOF| nc ${AMI_HOST} ${AMI_PORT} | grep -E '^Message:\ Originate'
  18. Action: Login
  19. Username: ${AMI_USER}
  20. Secret: ${AMI_PASS}
  21. Events: off
  22.  
  23. Action: Originate
  24. Channel: Local/${num}@${CALL_CONTEXT}/n
  25. CallerID: ${CALLERID}
  26. Context: ${TARGET_CONTEXT}
  27. Priority: 1
  28. Async: false
  29.  
  30. Action: Logoff
  31.  
  32. EOF
  33. )
  34.     res_code=$?
  35.  
  36.     if [ ${res_code} -ne 0 -o "$(echo ${res_str} | grep failed)" ]; then
  37.         echo ${num} >> ${FAILED_LIST}
  38.     fi
  39.  
  40. done
  41.  
  42. cat ${FAILED_LIST} | mail -s Ne_Dozvon testmail@example.com
  43.  
  44. rm -f ${FAILED_LIST}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement