Re: Help for a Hamster beginner

Andrew Paterson <[email protected]>
Newsgroups gmane.network.hamster
Message-ID <[email protected]>
Hello Cyn,

As you can probably tell, this question gets asked fairly frequently but,
as your situation matches my own, here is a script that will do the job. It
is put together from various examples that I have found (some come with
Hamster, some from this mailing list) so I cannot claim any originality!
Modify the parameters to suit your situation and then put the script
pathname on the command-line when you run Hamster. The easiest way is to
set up a shortcut which you can put in the Start Menu or on the desktop.

Here is the script with appropriate comments:

=================================================

#!hs2
#!load hamster.hsm

########################################################################
# Script     : AutomaticPull.hsc
# Description: Script which automatically pulls the latest messages from
#              the News servers at set time intervals.
# Maintainer : Andrew Paterson <[email protected]>
# Version    : 2000-07-13
########################################################################

# First make sure that Hamster is new enough to run this script
HamRequireVersion( "1.3.18.0", True )

# ----------------------------------------------------------------------

# Wait for all current processes to stop
HamWaitIdle

# ----------------------------------------------------------------------

# Dialup-settings - set these to null strings if not applicable
var( $RASDIAL_CONNECTION, $RASDIAL_USERNAME, $RASDIAL_PASSWORD )
$RASDIAL_CONNECTION = ""     # Name of RAS-conn; "" = disable dialing
$RASDIAL_USERNAME   = ""     # Username for RAS-conn; "" = use
Hamster-setting
$RASDIAL_PASSWORD   = ""     # Password for RAS-conn; "" = use
Hamster-setting

# Purge-settings
var( $PURGE_BEFORE_TRANSFER )
$PURGE_BEFORE_TRANSFER = False  # True = enable purging

# ----------------------------------------------------------------------

# Purging
if( $PURGE_BEFORE_TRANSFER )
   print( "Purging ..." )
   HamPurge
   HamWaitIdle
endif

# ----------------------------------------------------------------------

# Set up the schedule
# The following runs the "getnews" subroutine every 30 minutes
# from 08:00 to 20:00 on Monday to Friday (1111100).

AtClear
AtAdd( getnews, "08:00", "20:00", "1111100", 30, true )
AtExecute
quit

sub getnews

# ----------------------------------------------------------------------

# Dialing
var( $RASERR )
if( $RASDIAL_CONNECTION<>"" )
   print( "Dialling ..." )
   $RASERR = HamRasDial( $RASDIAL_CONNECTION, $RASDIAL_USERNAME,
$RASDIAL_PASSWORD )
   if( $RASERR<>0 )
      Error( "Error dialling ", $RASDIAL_CONNECTION, "! RAS-Error=",
$RASERR )
   endif
endif

# ----------------------------------------------------------------------

# Set up post and pull news message tasks (all servers)
HamNewsJobsClear

# Uncomment this to post newsgroup messages as well as pull
# HamNewsJobsPostDef

HamNewsJobsPullDef

# Post/pull messages to/from news server(s)
print( "Pulling news items..." )
HamNewsJobsStart

# Wait until all transfer-threads have finished
HamWaitIdle

# ----------------------------------------------------------------------

# Hanging up
if( $RASDIAL_CONNECTION<>"" )
   print( "Hanging up ..." )
   HamRasHangup
endif

# ----------------------------------------------------------------------

print( "Processing complete." )
endsub

=================================================

That is it! Obviously, you can remove the dialup (RAS) parts but they do
not come into play if the $RASDIAL_CONNECTION variable is null. As you can
see, I didn't bother.

HTH,

Andrew.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.