pan-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pan-users] Re: Command line use


From: Jack Cuyler
Subject: [Pan-users] Re: Command line use
Date: Wed, 13 Jun 2007 02:40:55 +0000 (UTC)
User-agent: Pan/0.131 (Ghosts: First Variation)

On Tue, 12 Jun 2007 10:25:40 -0700, Ted Sudtell wrote:

> Hello,
> I would like to use Pan from cron,  I have a satellite connection with a
> download limit 21 hrs a day.  12pm to 3am is open for unlimited
> download. I did a lookup in the archives and saw a few messages back in
> 2002. Does anyone know if this can be done?
> 
> Thanks

It's a rather new feature, but it's been working for a few months.  The 
syntax is:

pan headers:group.name --no-gui

It only problem I can find is if "group.name" doesn't exist, it will hang.

This is a script I've been using to update headers from a cron job.  You 
can give it one or more groups names as arguments, or it will update all 
subscribed groups if called with no arguments.  There are a few 
configurable options/variables toward the top.  Hopefully the comments 
make them self explanatory.  If you decide to use this, and you're 
reading this in pan, make sure you turn off wrapping when copying.


#!/bin/bash

USER=$(whoami)
PAN_HOME=${PAN_HOME:-"$HOME"/.pan2}
MYNAME=$(basename "$0")

# USER DEFINED
# Uncomment the first line to disable logging, or
# else set LOG_FILE to a file.
#LOG_FILE=
#LOG_FILE=${PAN_HOME}/cron_headers.$(date +%Y%m%d).log

# USER DEFINED
# Uncomment the first line to disable mailing logs
# to yourself, or else set MAIL to the client
# of your choice.
#MAIL=
#MAIL=mail
#MAIL=mailx

# Simple logging function.  Set $LOG_FILE (above)
# to nothing to disable logging.
log(){
        if [ -n "$LOG_FILE" ]; then
                echo "$(date +%Y%m%d%H%M):$@" >> "$LOG_FILE"
        else
                LOG="${LOG}
$(date +%Y%m%d%H%M):$@"
        fi
}

# Error and exit if newsrc isn't found.
if [ ! -f ${PAN_HOME}/newsrc-1 ]; then
        echo "${PAN_HOME}/newsrc-1 not found."
        exit 1
fi

log "Starting headers update."
# Get headers for each argument, or for all subscribed groups
# if no arguments.
if [ $# = 0 ]; then
        groups=$(grep ": " ${PAN_HOME}/newsrc-1 | cut -f1 -d:)
else
        groups="$@"
fi

for group in ${groups}; do
        pan headers:"$group" --no-gui
        if [ $? = 0 ]; then
                log "$group updated successfully."
        else
                log "$group failed to update."
        fi
done

log "End headers update."

# Mail a the log to $USER if $MAIL is defined
if [ -n "$MAIL" ] && [ -n "$LOG_FILE" ]; then
        cat "$LOG_FILE" | "$MAIL" -s \
        "Pan: headers have been updated" \
        -a "From: ${MYNAME}" $USER
elif [ -n "$MAIL" ] && [ -z "$LOG_FILE" ]; then
        echo "$LOG"| "$MAIL" -s \
        "Pan: headers have been updated" \
        -a "From: ${MYNAME}" $USER
fi



-- 
Cheers,
Jack

I SAW NOTHING UNUSUAL IN THE TEACHER'S LOUNGE
I SAW NOTHING UNUSUAL IN THE TEACHER'S LOUNGE
I SAW NOTHING UNUSUAL IN THE TEACHER'S LOUNGE
I SAW NOTHING UNUSUAL IN THE TEACHER'S LOUNGE

        Bart Simpson on chalkboard in episode 8F17





reply via email to

[Prev in Thread] Current Thread [Next in Thread]