User:Bdfoster

From FreeSWITCH Wiki
Jump to: navigation, search

Welcome to bdfoster's page

Welcome to my FreeSWITCH! wiki user page. I'll try to update this area often with random things that probably aren't appropriate for documentation but are freeswitch related. I'll also be placing here some things that I need to be able to remember but might be done differently than what examples in the documentation show.

Examples

Example of printing a fax to a network printer. Yes, I know I convert the fax to PDF before sending it, for some reason it doesn't like it when I print as a .ps or .tif(f). Anyway, if you don't have to convert to a .pdf, you don't need to.

#!/bin/sh
# printfax.sh

fax_location="$1"
uuid="$2"
fax_success="$3"
cid_name="$4"
cid_number="$5"
remote_id="$6"
result_txt="$7"
date="${date}"
ecm_req="${9}"
ecm_used="${10}"
total_pages="${8}"
loc_time=`date`
utc_time=`date -u`
txfr_rate="${11}"
rec_pages="${12}"

if [ "$1" = "" ]
  then
    echo "No file given!"
    exit 1
  fi


if [ "${fax_success}" = "1" ]
  then
    fax_success="SUCCESSFUL"
  else
    fax_success="UNSUCCESSFUL"
  fi

if [ "${fax_success}" = "SUCCESSFUL" ]
  then
    convert "$1" "${1}.pdf"
    if [ "$?" != "0" ]
      then
       echo "Conversion to PDF failed"
      fi
  fi

if [ "${ecm_req}" = "1" ]
  then
    ecm_req="YES"
  else
    ecm_req="NO"
  fi

if [ "${ecm_used}" = "on" ]
  then
    ecm_used="YES"
  else
    ecm_req="NO"
  fi


echo "<html>
<body>

<h1>FAX RECEIVED</h1>
<hr />

<h1 style="font-family:verdana">Fax Status: "${fax_success}"</h1>
<h3 style="font-family:verdana">From: "${cid_name}" "${cid_number}"</h3>
<h3 style="font-family:verdana">Remote ID: "${remote_id}"</h3>
<h3 style="font-family:verdana">Local Timestamp: "${loc_time}"</h3>
<h3 style="font-family:verdana">UTC Timestamp: "${utc_time}"</h3>
<h3 style="font-family:verdana">Received Pages: "${rec_pages}"</h3>
<h3 style="font-family:verdana">Total Pages: "${total_pages}"</h3>
<h2 style="font-family:verdana">Diagnostic Information:</h2>
<h3 style="font-family:verdana">UUID: "${uuid}"</h3>
<h3 style="font-family:verdana">Result Message: "${result_txt}"</h3>
<h3 style="font-family:verdana">Transfer Rate: "${txfr_rate}"</h3>
<h3 style="font-family:verdana">Error Correction Requested: "${ecm_req}"</h3>
<h3 style="font-family:verdana">Error Correction Used: "${ecm_used}"</h3>
<hr />
</body>
</html>" > results_${uuid}.html

html2ps results_${uuid}.html > results_${uuid}.ps
rm results_${uuid}.html
if [ "${fax_success}" = "SUCCESSFUL" ]
  then
    lp  "${1}.pdf"  "results_${uuid}.ps"
    rm "${fax_location}.pdf" "results_${uuid}.ps"
  else
    echo "results_${uuid}.txt"
    lp "results_${uuid}.ps"
    rm "results_${uuid}.ps"
 fi