How to send fax from TCL script?

Version 1
    This document was generated from CDN thread

    Created by: Marat Rabidinov on 29-04-2011 06:02:20 AM
    Hi all.
    I need to send fax from tcl. I looked over faxmail-offramp script, but I didn't see anything about place a call to a remote fax.
     
      1
      2# Script Locked by: CiscoOfficial
      3# Script Version: 2.0.1.3
      4# Script Name: app_faxmail_onramp
      5# Script Lock Date: Tue Sep 30 15:13:36 2003
      6#
      7#------------------------------------------------------------------
      8# January 2000, Fary Aryaman
      9#
     10# Copyright (c) 2002 by cisco Systems, Inc.
     11# All rights reserved.
     12#
     13# Faxmail Onramp script for T.37 Store and Forward Fax
     14#------------------------------------------------------------------
     15#
     16# Script compatability matrix:
     17#
     18# IOS version compatability
     19# Any 12.2(0.x)T images where x > 19
     20#------------------------------------------------------------------
     21# January 2002 Nirmala Shukla
     22#
     23# A fix for DDts CSCdu73987 has been included. app_faxmail_onramp
     24# application should disconnect the call if acct/pin is not entered
     25# for reasonable number of reprompts.
     26#
     27# 09/16/2003 - Fix for DDTS CSCec19194 - Tcl syntax in proc cause script
     28# to abort while loading in 12.3(2)T
     29#-----------------------------------------------------------------------
     30
     31proc init { } {
     32    global callInfo
     33    global param
     34    global param1
     35    global destination
     36    global authen_methods
     37    global retryCnt
     38
     39    set callInfo(alertTime) -1
     40    set callInfo(fax) true
     41
     42    set param(interruptPrompt) true
     43    set param(abortKey) *
     44    set param(terminationKey) #
     45
     46    set param1(fax) true
     47    set param1(speech) true
     48    set param1(interruptPrompt) true
     49    set param1(abortKey) *
     50    set param1(terminationKey) #
     51    set param1(dialPlan) true
     52
     53    set authen_methods(ani) 1
     54    set authen_methods(dnis) 2
     55    set authen_methods(gateway) 3
     56    set authen_methods(redialer-id) 4
     57    set authen_methods(redialer-dnis) 5
     58    set authen_methods(prompt-user) 6
     59    set authen_methods(none) 0
     60
     61  if { [infotag get cfg_avpair_exists retry-count] } {
     62        set retryCnt [infotag get cfg_avpair retry-count]
     63    } else {
     64        set retryCnt 3
     65}
     66}
     67proc init_ConfigVars { } {
     68    global account
     69    global auCtrl
     70    global accCtrl
     71    global auMethod
     72    global args
     73    global authen_methods
     74    global destination
     75    global password
     76    global fcnt
     77    infotag set med_language 1
     78    set destination 0
     79    set account 0
     80
     81    # authentication and accounting disabled by default
     82
     83    set auCtrl 0
     84    set accCtrl 0
     85    set fcnt 0
     86
     87    if { [ infotag get cfg_avpair_exists authentication] } {
     88        set authenCtrl [ infotag get cfg_avpair authentication ]
     89    if { $authenCtrl == "enable" } {
     90        set auCtrl 1
     91    }
     92    }
     93    puts "\nAuthentication control is $auCtrl"
     94
     95    if { [ infotag get cfg_avpair_exists accounting] } {
     96        set accountCtrl [ infotag get cfg_avpair accounting ]
     97    if { $accountCtrl == "enable" } {
     98        set accCtrl 1
     99    }
    100    }
    101    puts "\nAccounting control is $accCtrl"
    102
    103    set auMethod 0
    104    if { [ infotag get cfg_avpair_exists authen-method] } {
    105        set auMethod [ infotag get cfg_avpair authen-method ]
    106    set auMethod $authen_methods($auMethod)
    107    }
    108    puts "\nAuthentication method is $auMethod"
    109
    110    if { [ infotag get cfg_avpair_exists password] } {
    111        set password [ infotag get cfg_avpair password ]
    112    } else {
    113        set password ""
    114    }
    115    puts "\nDefault password is $password"
    116
    117    if { [ infotag get cfg_avpair_exists accounting-list] } {
    118        set accountList [ infotag get cfg_avpair accounting-list ]
    119    } else {
    120
    121    # The default accounting list name
    122
    123        set accountList fax
    124    }
    125    puts "\Accounting method is $accountList"
    126
    127    set args "au-ctrl=[set auCtrl]"
    128    set args "[set args], acc-ctrl=[set accCtrl]"
    129    set args "[set args], au-method=[set auMethod]"
    130    set args "[set args], accounting-list=[set accountList]"
    131}
    132
    133proc act_Setup { } {
    134    global callInfo
    135    global destination
    136    global authenCtrl
    137    global auMethod
    138    global account
    139    global auCtrl
    140    global ANI
    141    global DNIS
    142    global authenList
    143
    144    init_ConfigVars
    145
    146    if { $auMethod == 0 } {
    147    if { $auCtrl == 1} {
    148        puts "\nAuthentication enabled but no method specified"
    149        set account ""
    150    }
    151    } elseif { $auMethod == 1 } {
    152    set account [ infotag get leg_ani ]
    153    } elseif { $auMethod == 2 } {
    154    set account [ infotag get leg_dnis ]
    155    } elseif { $auMethod == 3 } {
    156    set account [ infotag get cfg_gateway_id ]
    157    }
    158
    159    if { [ infotag get cfg_avpair_exists authen-list] } {
    160        set authenList [ infotag get cfg_avpair authen-list ]
    161    } else {
    162
    163        # The default authentication list name
    164
    165        set authenList fax
    166    }
    167
    168    set ANI [ infotag get leg_ani ]
    169    set DNIS [ infotag get leg_dnis ]
    170    if { [ infotag get leg_isdid ] } {
    171    set destination [ infotag get leg_dnis ]
    172    act_authenticate
    173    } else {
    174    leg setupack leg_incoming
    175
    176    if { [ infotag get cfg_avpair_exists access-method] } {
    177        set accessMethod [ infotag get cfg_avpair access-method ]
    178    } else {
    179
    180            # The default accessMethod
    181
    182        set accessMethod prompt-user
    183    }
    184
    185
    186    if { $accessMethod == "prompt-user" } {
    187        if { $auMethod == 6 } {
    188        act_account_collect
    189        fsm setstate ACCOUNT_COLLECT
    190        } else {
    191        act_authenticate
    192        }   
    193    } elseif { $accessMethod == "redialer" } {
    194        act_redialer_acct_collect
    195        fsm setstate REDIALER_ACCT_COLLECT
    196
    197            # FXS without destination number
    198    } elseif { $DNIS == "" } {
    199            act_dest_collect
    200        }
    201    }
    202}
    203
    204proc act_account_collect { } {
    205    global param
    206    global fcnt
    207    global retryCnt
    208
    209    if { $fcnt < $retryCnt } {
    210    set pattern(account) .+
    211    leg collectdigits leg_incoming param pattern
    212        if {$fcnt == 0} {
    213            media play leg_incoming _enter_card_num.au
    214        } else {
    215           media play leg_incoming _auth_fail_retry.au
    216        }
    217       incr fcnt
    218       fsm setstate GETACCOUNT
    219    } else {
    220
    221    media play leg_incoming flash:auth_failed.au
    222    fsm setstate CALLDISCONNECT
    223    }
    224   
    225}
    226proc act_redialer_acct_collect { } {
    227
    228    set param(terminationKey) #
    229    set param(interruptPrompt) true
    230    set pattern(accountAndPW) .+
    231    playtone leg_incoming tn_dial
    232    leg collectdigits leg_incoming param pattern
    233}
    234
    235proc act_dest_collect { } {
    236    global destination
    237    global param1
    238
    239    puts "\ndestination is $destination"
    240    if { $destination != 0 } {
    241    act_callsetup
    242    return
    243    }
    244    leg collectdigits leg_incoming param1
    245
    246    media play leg_incoming _enter_dest.au
    247
    248    fsm setstate DEST_COLLECT
    249}
    250
    251proc act_authenticate { } {
    252    global auMethod
    253    global account
    254    global auStatus
    255    global auCtrl
    256    global password
    257    global ANI
    258    global DNIS
    259    global authenList
    260
    261    if { ($auCtrl == 0) || ($auMethod == 0) } {
    262    set auStatus 1
    263    act_dest_collect
    264    return
    265    }
    266
    267    set info(authen-list) $authenList
    268    aaa authorize $account $password $ANI $DNIS leg_incoming -s $authenList
    269    fsm setstate AUTHORIZE
    270}
    271
    272proc act_authenticate_done { } {
    273    global callInfo
    274    global account
    275    global auStatus
    276
    277    set status [infotag get evt_status]
    278    puts "\nstatus is $status"
    279
    280    if { $status == "au_000" } {
    281    set auStatus 1
    282    act_dest_collect
    283    } else {
    284    set auStatus 0
    285    act_callsetup
    286    }
    287    return
    288}
    289
    290proc act_authorize_done { } {
    291    global callInfo
    292    global account
    293    global auStatus
    294
    295    set status [infotag get evt_status]
    296    puts "\nstatus is $status"
    297
    298    if { $status == "ao_000" } {
    299    set auStatus 1
    300    act_dest_collect
    301    } else {
    302    set auStatus 0
    303    act_callsetup
    304    }
    305    return
    306}
    307
    308proc act_callsetup { } {
    309    global callInfo
    310    global account
    311    global auStatus
    312    global destination
    313    global args
    314
    315    set args "[set args], au-status=[set auStatus]"
    316    set args "[set args], account=[set account]"
    317
    318    if { ([set auStatus] == 1) && ($destination != 0) } {
    319    set callInfo(accountNum) $account
    320    set callInfo(argstring) $args
    321    leg proceeding leg_incoming
    322    leg setup $destination callInfo leg_incoming
    323    } else {
    324    handoff appl [ infotag get leg_incoming] FAX_ON_VFC_ONRAMP_APP $args
    325    }
    326}
    327
    328proc act_DCDone { } {
    329    global callInfo
    330    global destination
    331    global DNIS
    332
    333    # matched dialplan
    334
    335    if { [ infotag get evt_status ] == "cd_004" } {
    336    set destination [infotag get evt_dcdigits]
    337    } else {
    338    set destination 0
    339    }
    340    if { $DNIS == "" } {
    341        set DNIS $destination
    342    }
    343    act_callsetup
    344}   
    345
    346proc act_pin_collect { } {
    347    global param
    348    global fcnt
    349
    350    set pattern(pin_num) .+
    351    leg collectdigits leg_incoming param pattern
    352    if {$fcnt == 0} {
    353    media play leg_incoming _enter_pin.au
    354    } else {
    355    media play leg_incoming _invalid_pin.au
    356        fsm setstate CALLDISCONNECT
    357        return
    358    }
    359
    360}
    361
    362proc act_get_account_dcdone {} {
    363    global account
    364
    365    set ev [infotag get evt_status]
    366    puts "\nget account status is $ev"
    367
    368    # matched pattern
    369
    370    if {$ev == "cd_005"} {
    371    set account [infotag get evt_dcdigits]
    372    fsm setstate PIN_COLLECT
    373        puts "\nAccount is $account"
    374        act_pin_collect
    375        return
    376    }
    377
    378    act_account_collect
    379    fsm setstate same_state
    380}
    381
    382proc act_get_pin_dcdone {} {
    383    global password
    384    global account
    385    global authenList
    386
    387    set ev [infotag get evt_status]
    388    puts "\nget account status is $ev"
    389
    390    # matched pattern
    391
    392    if {$ev == "cd_005"} {
    393    set password [infotag get evt_dcdigits]
    394    fsm setstate AUTHORIZE
    395        puts "\nAccount: $account  Password: $password"
    396    aaa authenticate $account $password -s $authenList
    397    return
    398    }
    399
    400    act_pin_collect
    401    fsm setstate same_state
    402}
    403
    404proc act_get_redialer_acct_dcdone {} {
    405    global callInfo
    406    global account
    407    global destination
    408    global auMethod
    409
    410    set ev [infotag get evt_status]
    411    puts "\nget account status is $ev"
    412
    413    # matched pattern
    414
    415    if {$ev == "cd_005"} {
    416    set acct [infotag get evt_dcdigits]
    417    puts "\n----------received account from redialer: ---$acct--- "
    418
    419    set destination [ infotag get leg_dnis ]
    420
    421    if { $auMethod == 4 } {
    422        set account [set acct]
    423    } elseif { $auMethod == 5 } {
    424        set account [set destination]
    425    }
    426
    427    set callInfo(destinationNum) $account
    428    puts "\nAccount is $account"
    429   
    430    set param(interruptPrompt) true
    431    set pattern(called) .+
    432    leg collectdigits leg_incoming param pattern
    433    fsm setstate REDIALER_DEST_COLLECT
    434    }
    435}
    436
    437proc act_get_redialer_dest_dcdone {} {
    438    global callInfo
    439    global destination
    440    global account
    441    global auMethod
    442
    443    set ev [infotag get evt_status]
    444    puts "\nget account status is $ev"
    445
    446    # matched pattern
    447
    448    if {$ev == "cd_005"} {
    449    set called [infotag get evt_dcdigits]
    450    puts "\n----------received called number from redialer: ---$called--- "
    451    set callInfo(destinationNum) $called
    452    fsm setstate AUTHORIZE
    453        set destination $called
    454        if { $auMethod == 5 } {
    455            set account $called
    456        }
    457     puts "\n----------dnis from redialer: ---$account--- "      
    458    act_authenticate
    459    }
    460}
    461
    462proc act_PCDone { } {
    463
    464#    if { [ infotag get evt_status ] != "connected" } {
    465#        call close
    466#        fsm setstate CALL_CLOSED
    467#    }
    468
    469#    puts "\nCall set up done"
    470
    471     call close
    472     fsm setstate CALL_CLOSED
    473}      
    474
    475proc act_Cleanup { } {
    476  
    477    call close
    478}
    479
    480init
    481
    482#----------------------------------
    483#   State Machine
    484#----------------------------------
    485
    486  set fsm(CALL_INIT,ev_setup_indication)               "act_Setup               SAMESTATE"
    487  set fsm(any_state,ev_disconnected)                   "act_Cleanup             SAMESTATE"
    488  set fsm(GET_ACCOUNT,ev_collectdigits_done)           "act_get_account_dcdone  SAMESTATE"
    489  set fsm(AUTHORIZE,ev_authenticate_done)              "act_authenticate_done   SAMESTATE"
    490  set fsm(AUTHORIZE,ev_authorize_done)                 "act_authorize_done      SAMESTATE"
    491  set fsm(DEST_COLLECT,ev_collectdigits_done)          "act_DCDone              CALL_SETTING"
    492
    493  set fsm(any_state,ev_setup_done)                     "act_PCDone              CALL_CLOSED"
    494#  set fsm(CALL_SETTING,ev_setup_done)                 "act_PCDone              CALLACTIVE"
    495
    496  set fsm(ACCOUNT_COLLECT,ev_collectdigits_done)       "act_get_account_dcdone  SAMESTATE"
    497
    498  set fsm(PIN_COLLECT,ev_collectdigits_done)           "act_get_pin_dcdone      SAMESTATE"
    499
    500#  set fsm(REDIALER_COLLECT,ev_collectdigits_done)     "act_get_redialer_dcdone SAMESTATE"
    501
    502  set fsm(REDIALER_ACCT_COLLECT,ev_collectdigits_done) "act_get_redialer_acct_dcdone SAMESTATE"
    503  set fsm(REDIALER_DEST_COLLECT,ev_collectdigits_done) "act_get_redialer_dest_dcdone SAMESTATE"
    504
    505  fsm define fsm CALL_INIT
    506
    507# Script Approval Signature: C/1f70

     
     
    Where can I see an example of sending fax from TCL script.

    Subject: RE: How to send fax from TCL script?
    Replied by: Raghavendra Gutty Veeranagappa on 29-04-2011 07:59:14 AM
    Hi Marat,

    please go through following link, given steps to confgure for fax services over ip applcation.

    http://www.cisco.com/en/US/docs/ios/12_3/vvf_c/cisco_ios_fax_services_over_ip_application_guide/t37.html

    Thanks,
    Raghavendra