The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Internet Explorer is infected - small windows keep popping up milhan Windows & DOS: Issues & Discussions 17 09-06-2009 03:00 PM
cron job starts new cron proccess ron76 SUN Solaris 3 05-12-2008 02:07 AM
CRON usage for CRON job skyineyes UNIX for Dummies Questions & Answers 1 01-17-2008 10:17 AM
AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log Keith Johnson AIX 0 01-09-2008 08:32 PM
Cron : you are not authorized to use cron. Sorry. tt155 UNIX for Advanced & Expert Users 1 07-06-2005 11:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-11-2006
pau pau is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 39
Fetchmal email notif. on your prompt (pop, imap, etrn, odmr) [fixed]

Maybe this can help you (I'm refering to the previous post)

This is my question:
=============

1- I am using fetchmail
2- fetchmail allows you to "check" but not "fetch" with the -c flag
3- I thought I'd write a script to check for email, so that I get a text message
on my terminal when I get an email (because it's IMAP)

This is the script:

Code:
#!/usr/bin/env zsh

if echo `fetchmail -c -f ~path/to/my/fetchmailrc`| grep -q 'message'; then
  exit
else

missatge=$(echo `fetchmail -c -f ~path/to/my/fetchmail/fetchmailrc` | gawk '{print "you have "$2" "$3" waiting, my dear..."}')

echo -e "\033[34m\033[1m$missatge"

fi

This is my cronjob:


Code:
0-59/1 * * * * $HOME/bin/fetchmailnotification.sh

I have tested the script and it works just right.

However the cronjob is not showing anything. I thought it could be the > /dev/null or the > /dev/null 2>&1 if you want no e-mail ever.

I've tried removing these > but nothing

I was expecting to be prompted with the notification in my terminal whenever (after checking, say, once per minute, as stated in the cronjob) an email arrives but nothing...

any hint?

thanks

Pau

Last edited by pau; 02-03-2007 at 04:59 PM..
  #2 (permalink)  
Old 12-11-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Cronjobs do not have any terminals associated with them. You cannot interact with a cronjob. Infact, the very purpose of cronjobs is to run without any manual intervention.

So do not expect any pop-ups or prompts from your cron job. Cron does not work that way.
  #3 (permalink)  
Old 12-12-2006
pau pau is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 39
ok... nice to learn new things...

I though cron would just run the script as it is and behave as I would expect bit it doesn't...

Do you have a solution then to run the script, say, every 20 minutes?
  #4 (permalink)  
Old 12-12-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Quote:
Originally Posted by blowtorch
Cronjobs do not have any terminals associated with them. You cannot interact with a cronjob. Infact, the very purpose of cronjobs is to run without any manual intervention.

So do not expect any pop-ups or prompts from your cron job. Cron does not work that way.
That's right. Anyway you could try something like:

Code:
echo "whatever" | write userX pts/X

Obviously you need to "guess" the terminal, but you can get that info from "who"...

Regards.
  #5 (permalink)  
Old 12-12-2006
pau pau is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 39
Hi grial,

that's a promising thing indeed!

now my who yields


Code:
elachistos| who                                                                                                                              
pau      :0           2006-12-12 11:43
pau      pts/0        2006-12-12 11:44 (:0.0)
pau      pts/1        2006-12-12 12:29 (:0.0)
pau      pts/2        2006-12-12 13:54 (:0.0)
pau      pts/4        2006-12-12 13:58 (:0.0)

because I have opened 4 tabs on a terminal...

mmmh... I guess I could define a variable called pts and do a grep on "who" to have sent the message to all terminals... let me try it

thanks for the hint (I wasn't aware of write, by the way! nice BSD tool!)
  #6 (permalink)  
Old 12-12-2006
pau pau is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 39
Mmmh... there's a little problem... write is verbose


Code:
elachistos|                                                                                                                                  
Message from pau@elachistos on pts/2 at 14:20 ...
^[[34m^[[1mhola
EOF

and it doesn't understand the colour encoding (well, that's not very important, but I don't really like the "Message from blabla" and "EOF" ...

from the man it seems it's not possible to make it silent...
  #7 (permalink)  
Old 12-12-2006
pau pau is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 39
bump...

any heeeelp!!! please somebody help meeeee

Well... I'd be also happy if somebody could point out a command line email notification system which can deal with IMAP
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0