A question for the AWK wizards

Murray Taylor MTaylor at bytecraft.com.au
Tue Jul 25 11:44:33 UTC 2006


Hi all,

I have a shell script which is called with an arbitrary 
message argument. Punctuation excludes * ? & | > < chars.

It processes it via an AWK command line 'script' and dumps the 
result in a file for the SMS sender...

Nice and simple.

Except that the AWK script seems to duplicate the last character or two
in the message. Everything else in the 200 odd lines of shell scripts
surrounding this function run just fine, and this bit runs too, 
but this tiny thing is _VERY_ annoying.

The shell code is listed below.

Please teach me what bit I missed .... (C and TCL are my forte, not AWK)

cheers
mjt

------------------8<------------------------------
# sourced into other scripts that need to SMS
# !! 4 space indents, NOT tabs !!
#
# generate the sms message
# the awk code forces the message to be < 160 chars
sendsms() {
    msg=$1

    case ${sms_enable} in
    [Yy][Ee][Ss])
        for phone in ${phonelist}
        do
            tmpfile=`mktemp -t sms`
            echo ${phone} >> ${tmpfile}
            ${AWK} '{ printf "%-0.159s", $0 }' >> ${tmpfile} << EOF2
`echo $msg`
EOF2

            mv ${tmpfile} ${gsmspool_dir}
        done
        ;;
    *)
        ;;
    esac
}
------------------8<------------------------------

Murray Taylor

Special Projects Engineer
Bytecraft Systems

P: +61 3 8710 2555
F: +61 3 8710 2599
D: +61 3 9238 4275
E: mtaylor at bytecraft.com.au 


--

"Any intelligent fool can make things bigger and more complex... It
takes a
touch of genius - and a lot of courage to move in the opposite
direction."
--Albert Einstein 

---------------------------------------------------------------
The information transmitted in this e-mail is for the exclusive
use of the intended addressee and may contain confidential
and/or privileged material. Any review, re-transmission,
dissemination or other use of it, or the taking of any action
in reliance upon this information by persons and/or entities
other than the intended recipient is prohibited. If you
received this in error, please inform the sender and/or
addressee immediately and delete the material. 

E-mails may not be secure, may contain computer viruses and
may be corrupted in transmission. Please carefully check this
e-mail (and any attachment) accordingly. No warranties are
given and no liability is accepted for any loss or damage
caused by such matters.
---------------------------------------------------------------

***This Email has been scanned for Viruses by MailMarshal.***


More information about the freebsd-questions mailing list