Hamster-Script Version 1

by Obbe-Jan Bakker

"hs1", Extension: ".hsc"

Please note:

These old-style scripts will be removed in a future version. It is better not to use them any more and to use the new hs2-Scripts hsc_main.

Purpose:

The built-in Hamster-Scripts provide an easy-to-use method for starting common tasks.

Commands:

quit

Stops execution of script.

restart

Restarts script from beginning.

call "scriptname.hsc"

Loads and executes the given script. After the sub-script has finished, the parent script is continued after the "call"-line.

wait.delay milliseconds

Waits the given amount of milliseconds (1/1000 seconds).

Example:

wait.delay 5000

wait.until timepoint1 timepoint2 timepoint3 ...

Waits until one of the given timepoints. The timepoints have to be in format "hh.mm".

Example:

wait.until 02.00 08.00 12.00 18.00 21.00

wait.idle

Waits until all active tasks (like purging, pulling news, sending mails etc.) have finished.

Example:

wait.idle

mail.pull ["ServerList"]

Starts the thread, which first fetches new mails from the mailservers and then sends out mails (if any).

If you omit ServerList or set it to an empty string (""), all POP3- and SMTP-servers defined in Hamster may be used. Otherwise, transfer is restricted to the given servers.

If used, the ServerList has to consist of a semicolon-separated (" ; ") list of servernames. The servernames have to be in the same format as displayed in the Hamster-settings (i.e. servername + " , " + port).

Example:

mail.pull

Example:

mail.pull "mail.aaa.com,pop3;mail.bbb.com,pop3;mail.aaa.com,smtp"

fetchmail Server Port User Pass DestUser

Starts a thread, which fetches mails from the given POP3-server (Server, Port).

If User and Pass are given, they will be used to login to the server, if they are both empty, the password-setting for the given server is used. Furthermore, one of the stored "general-purpose"-passwords can be used here to avoid noting it in clear-text in the script (User="$(number)", Pass="").

If DestUser is given, fetched mails will be stored in the mailbox of this user, "admin"-mailbox is used otherwise. The name may optionally be followed by a comma and an identifier, which determines the filter-section to use for the mails fetched with this commands (default is global filters only, i.e. "[*]"-section in MailfFilt.hst).

Examples:

fetchmail "pop3.serv.er" "" "" "" ""

fetchmail "pop3.serv.er" "pop3" "john.doe" "secret" "john"

fetchmail "pop3.serv.er" "10110" "$7" "" "jane"

fetchmail "pop3.serv.er" "pop3" "$7" "" "admin,myfilters"

sendmail Server Port FromSelection

Starts a thread, which sends mails to the given SMTP-server (Server, Port).

If no FromSelection is given, all mails waiting for delivery are sent. If a selection is given (regular expression), only mails with a matching Envelope-From are sent to this server.

Examples:

sendmail "smtp1.serv.er" "smtp" "john\.doe@serv\.er"

sendmail "smtp2.serv.er" "" ""

news.post ["ServerList"]

Starts the thread, which posts new articles (if any).

If ServerList is set to an empty string (""), all NNTP-servers defined in Hamster may be used. Otherwise, transfer is restricted to the given servers (see mail.pull for details on the ServerList format).

news.pull ["Serverlist"]

Starts the threads, which pull new articles from newsservers.

If ServerList is set to an empty string (""), all NNTP-servers defined in Hamster may be used. Otherwise, transfer is restricted to the given servers (see mail.pull for details on the ServerList format).

news.purge [PurgeOptions]

Starts a purge-thread (i.e. the deletion of old data).

The bit-oriented parameter PurgeOptions describes, which old data should be deleted (bit0=1=articles, bit1=2=history-entries, bit2=4=killfile-log, bit3=8=mailhistory-entries). If you omit this value, all types of old data will be "purged".

Example: news.purge

Example: news.purge 15

news.rebuildhistory

Starts a thread, which deletes the current history-file (".\Groups\History.dat") and rebuilds it by adding the Message-IDs of all articles stored in Hamster.

Note: This may take some time with thousands of articles, so it should only be used, if it's really necessary! Be sure to wait until Hamster is idle again (wait.idle) after calling this function!

news.rebuildgloballists

Starts a thread, which rebuilds some lists needed by Hamster (see "Menu: File / Rebuild global lists" for details).

setlogin "Identifier" "Username" "Password"

Temporarily sets username and password for the given Identifier, which can be either the name of a RAS-connection or the name of a news-/mail-server. "Temporarily" means, that this setting is not saved to a file but is kept in memory until Hamster is closed again.

If username and/or password is set to a single question-mark ("?"), Hamster will ask for the value when it's needed.

Furthermore, one of the stored "general-purpose"-passwords can be selected here to avoid noting it in clear-text in the script.

Example:

setlogin "RAS-connection" "DoeJohn" "Secret!"
setlogin "news.xxx.com" "DoeJane" "42"
setlogin "ser.verna.me" "$11" ""

ras.dial "ConnectionID" ["Username" ["Password"]]

This function establishes the RAS-connection named ConnectionID.

The username and/or password can be set to empty strings (""). In this case, the setlogin-setting (if any) or the values stored in Hamster are used to establish the connection.

If dialing fails, the script will be stopped.

Example:

ras.dial "RAS-connection" "DoeJohn" "Secret!"
ras.dial "RAS-connection"

ras.hangup

Closes the RAS-connection established by rasdial.

Example: ras.hangup

msgbox "message"

Displays the given message.

Example: msgbox "Script finished!"

start.wait "command and parameters"

Starts an external program with the given parameters. The script is paused until the external program has finished.

Example: start.wait "before-dial.bat"

start.nowait "command and parameters"

Like start.wait, but Hamster does not wait until the external program has finished. The script is continued immediately.

Example: start.nowait "after-connected.bat"

message msg-number [parameter]

Initiates some Hamster-functions, which are normally available and accessed by its menu-items.

Msg-number Parameter Purpose
1 none Exit Hamster
2 none Reset counters and log-display
3 0 = stop, 1= start Start/Stop local NNTP-server
4 0 = stop, 1 = start Start/Stop local POP3-server
5 0 = stop, 1 = start Start/Stop local SMTP-server
6 0 = hide, 1 = show Hide/show main-window
7 0 = hide, 1 = show Hide/show tray-icon
8 none Menu: Online/Stop all tasks

Example: message 2

Example: message 3 0

Example:

wait.idle

# purge
# wait.idle

ras.dial "name of ras-connection"

mail.pull
news.post
wait.idle

news.pull
wait.idle

ras.hangup


Unable to open file