You are not logged in.

#1 2009-11-16 13:13:24

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

[Solved] Really odd/unexplained bash script/ssmtp behavior

Huh, this one has got me.  This is a simple script I wrote to be sure that flash cookies are disabled.  The purpose of the script is to detect if flash cookies are enabled and then to warn me by sending me an email through ssmtp.  Here's the script:

#!/bin/bash
# flashprotect - disable flash cookies

# Text color variables
txtund=$(tput sgr 0 1)          # Underline
txtbld=$(tput bold)             # Bold
bldred=${txtbld}$(tput setaf 1) #  red
bldblu=${txtbld}$(tput setaf 4) #  blue
txtrst=$(tput sgr0)             # Reset
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}

home=/home/todd
adotest=$(readlink -f $home/.adobe)
mactest=$(readlink -f $home/.macromedia)

# Check if cache is nullified, else fix and warn
if [ $adotest == /dev/null ] && [ $mactest == /dev/null ]; then
    echo "$pass Flash cache is protected."
    else
    rm -r ~/.adobe 2&> /dev/null
    rm -r ~/.macromedia 2&> /dev/null
    ln -s /dev/null $home/.adobe
    ln -s /dev/null $home/.macromedia
    echo "$warn Flash cache was active!  ...Deleted."
    if [ $(whoami) == root ]; then
        echo "Flash cache was active!" | mail -s "Flash cache had been enabled!" toddrpartridge@gmail.com
    fi
fi

I put the script in an hourly cron job:

  00  *   *   *   *       /home/todd/.bin/others/flashprotect # h

And every hour though I'm getting this odd email:

from    root <toddrpartridge@gmail.com>
to    root
date    Mon, Nov 16, 2009 at 7:00 AM
subject    cron: /home/todd/.bin/others/flashprotect # h
mailed-by    gmail.com

[34m* [0;10m Flash cache is protected.

Wt....?  This is actually getting me a good laugh though it's got me completely stumped.

Any ideas?

Last edited by Gen2ly (2009-11-16 20:14:14)


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#2 2009-11-16 19:08:11

nh
Member
From: England
Registered: 2008-07-09
Posts: 45

Re: [Solved] Really odd/unexplained bash script/ssmtp behavior

What exactly is the problem?  Is it that the control characters "[34m* [0;10m" are not being interpreted as such in gmail?

Offline

#3 2009-11-16 19:14:50

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [Solved] Really odd/unexplained bash script/ssmtp behavior

Gen2ly,

cron is setup up by default to mail commands output.  hence the subject being cron: ... and the body being the scripts output upon a protected cache.

how you've set this up or how to disable it, i dunno.

that's not the mail from your mail command; it's just cron sending the output.

Last edited by brisbin33 (2009-11-16 19:53:33)

Offline

#4 2009-11-16 20:13:50

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: [Solved] Really odd/unexplained bash script/ssmtp behavior

Ah, of course.  Was thinking that cron would send mail only on error output.  Removing the successful echo line fix the problem.  Appreciate the help.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

Board footer

Powered by FluxBB