Start a minimized task with Windows 7 task planner
Use runApp.vbs:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """c:\whereever\whatever.exe"" ""c:\i.am\parameter.txt""",7
Cats in Space
via kaiburghardt
Nagios-Plugin to test if internet is reachable by querying some http-servers and hoping for HTTP-200-response
#!/bin/bash
# nagios_nattest.sh, used to test if internet is reachable by querying some http-servers and hoping for HTTP-200-response
# 2012-0321 pjs - initial version
#
# for your ping-list.txt:
# please use the following comman to generate checksum-file:
# # sha256sum ping-list.txt > ping-list.txt.sha256sum
#
DEBUG="0" # set to 1 if you want to see debug-messages
THRESHOLD_WARNING="80" # warning if less than 66% of the URLs are reachable
THRESHOLD_ERROR="50" # error if less than 10% are reachable
TEMP_DIR="`mktemp -d`"
FILENAME_PINGLIST="/root/ping-list.txt"
FILENAME_TEMP="ping-list.txt"
FILENAME_TEMP_SHA="ping-list.txt.sha256sum"
HOST="http://hostwithpinglist.example.com/"
URL_PINGLIST="${HOST}${FILENAME_TEMP}"
URL_PINGLIST_SHA="${HOST}${FILENAME_TEMP_SHA}"
######## change nothing beyond this point
WARNING=""
ERROR=""
cd $TEMP_DIR
# 1. retrieve update
curl -so $FILENAME_TEMP $URL_PINGLIST
curl -so $FILENAME_TEMP_SHA $URL_PINGLIST_SHA
if [ ! -e $FILENAME_TEMP ]; then
if [ $DEBUG -eq "1" ]; then echo "${HOST}${FILENAME_TEMP} could not be retrieved."; fi
WARNING="$WARNING - ${HOST}${FILENAME_TEMP} could not be retrieved"
fi
if [ ! -e $FILENAME_TEMP_SHA ]; then
if [ $DEBUG -eq "1" ]; then echo "${HOST}${FILENAME_TEMP_SHA} could not be retrieved."; fi
WARNING="$WARNING - ${HOST}${FILENAME_TEMP_SHA} could not be retrieved"
fi
# 2. verify update
sha256sum -c $FILENAME_TEMP_SHA > /dev/null 2>&1
if [ $? -eq 0 ]; then
if [ $DEBUG -eq "1" ]; then echo "Ping-List-Update retrieved successfully."; fi
cmp -s $FILENAME_TEMP $FILENAME_PINGLIST > /dev/null
if [ $? -eq 1 ]; then
rm $FILENAME_PINGLIST
mv $FILENAME_TEMP $FILENAME_PINGLIST
if [ $DEBUG -eq "1" ]; then echo "Ping-List updated."; fi
else
if [ $DEBUG -eq "1" ]; then echo "No Ping-List update needed."; fi
fi
else
if [ $DEBUG -eq "1" ]; then echo "Ping-List NOT updated (checksum mismatch)."; fi
WARNING="$WARNING - checksum mismatch (${HOST}${FILENAME_TEMP_SHA})"
fi
rm -r $TEMP_DIR
URLS=`cat $FILENAME_PINGLIST | grep -v \#`
COUNT_SUCCESS="0"
COUNT_ALL="0"
for URL in $URLS
do
COUNT_ALL=$(( $COUNT_ALL + 1 ))
RESPONSE_CODE=`curl -s -I $URL | grep HTTP | awk '{print $2}'`
if [ "$RESPONSE_CODE" -eq "200" ]
then
COUNT_SUCCESS=$(( $COUNT_SUCCESS + 1 ))
if [ $DEBUG -eq "1" ]; then echo "+" $URL; fi
else
if [ $DEBUG -eq "1" ]; then echo "-" $URL; fi
fi
done
WORKING_RATE="$(( $COUNT_SUCCESS * 100 / $COUNT_ALL ))"
if [ $DEBUG -eq "1" ]; then echo $WORKING_RATE "% working (" $COUNT_SUCCESS "out of" $COUNT_ALL ")"; fi
if [ $WORKING_RATE -lt $THRESHOLD_ERROR ]; then
ERROR="$ERROR - threshold error"
else
if [ $WORKING_RATE -lt $THRESHOLD_WARNING ]; then
WARNING="$WARNING - threshold warning"
else
# threshold OK
if [ $DEBUG -eq "1" ]; then echo "threshold OK"; fi
fi
fi
# output result
if [ "$ERROR" != "" ]; then
echo "CRITICAL -" $COUNT_SUCCESS "out of" $COUNT_ALL "URLs reached" $ERROR $WARNING
exit 2
fi
if [ "$WARNING" != "" ]; then
echo "WARNING -" $COUNT_SUCCESS "out of" $COUNT_ALL "URLs reached" $WARNING
exit 1
fi
echo "OK"
exit 0
Creative Thinking
directly print specific emails (read: “invoices”)
The goal of this project is to have printed all messages to a specific email-address. There are mails with a PDF file attached and just plain ASCII emails.
We use a GMail-mailbox here. Add one or more filters to tags the mails you want to be printed with the label “to print”.
Now you can use the bash-scripts below to get mails via IMAP (using getmail) and look for attached PDF files (using munpack). Then you can print either the mail itself (use muttprint or a2ps) or the PDF-attachment (use pdf2ps). Of course you can use cron to run the scripts periodically.
.getmail/getmailrc
[retriever]
type = SimpleIMAPSSLRetriever
server = DerServer
username = DerUsername
password = DasPasswort
mailboxes = ("to print", )
[destination]
type = Maildir
path = /home/autoprint/mail/
[options]
delete = false
read_all = false
message_log = /home/autoprint/mail.log
parse.sh
#!/bin/bash
if [ -e /tmp/autoprint ]
then
echo "/tmp/autoprint exists.. Stopping."
exit 1
fi
FILES=`ls ~/mail/new/`
for f in $FILES
do
mkdir /tmp/autoprint
FILENAME=`munpack -C /tmp/autoprint ~/mail/new/${f} | grep ".pdf" | awk '{print $1}'`
if [ -f /tmp/autoprint/$FILENAME ]
then
echo "pdf gefunden"
mv /tmp/autoprint/$FILENAME ~/print
# hier PDF drucken
else
echo "mail kopieren"
cp ~/mail/new/${f} ~/print
# hier Mail drucken
fi
rm -rf /tmp/autoprint
done