Try at your own risk. I am assuming you know how to use twitter and twidge. Just some example scripts to experiment with:
Possible command to enter into twitter:
echo Hello world!
robot
———
###################################
# twitter control
#
#=================================
# daffynitions
# ——————————–
username=”[accountname]“
datafile1=”inlist”
datafile2=”joblist”
datafile3=”jobsdone”
a=1
#===========================================
# code
#———————————————
# get data
twidge -c twidgetest lsrecent -su > $datafile1
# strip username
sed -i ‘s/ //g’ $datafile1
# reverse file order
tac $datafile1 > $datafile2
# do commands in order
while read line
do injob=$line
echo ./dojob $injob > job
./job $1 $2 $3 $4 $5 $6 $7 $8 $9
done > $datafile3
#===================================
# End.
####################################
job
—-
./dojob
dojob
——-
command=”$1″
comment=”Job #$$”
hdr “$comment” “$command” “$USER”
$1 $2 $3 $4 $5 $6 $7 $8 $9
ftr “$comment” “$command” “$USER”
hdr
———–
echo “#————————————————————#”
echo ” COMPANY NAME: $1″
echo ” $3 is running: $2″
echo “#————————————————————#”
ftr
———
echo “#————————————————————#”
echo ” COMPANY NAME: $1″
echo ” $3, your job: $2 is done.”
echo “#————————————————————#”
original robot
————————
#!/bin/bash###################################
# twitter control
#
#=================================
# code
# ——————————–
datafile=”todolist”
twidge -c twidgetest lsrecent -su > $datafile
sed -i ‘s/ //g’ $datafile
while read line
do injob=$line
echo ./tdojob $injob > job
./job $1 $2 $3 $4 $5 $6 $7 $8 $9
done < $datafile
#===================================
# End.
####################################
#Get Recent Direct Messages sent to directmessage_account
echo `twidge lsdmarchive -us` | grep directmessage_account >> /path/to/todo.txt
#Remove sender/recipiant information since I like to keep
sed -i 's/<twitterusername> <directmessage_account> //g' /path/to/todo.txt
#Remove blanklines to keep todo.txt formated right
sed -i '/^$/d' /path/to/todo.txt
#Search for keyword "dnes" and if it is there send a direct message to myself with the things that are due the next day and if not say "Not Found"
if grep -q "dnes" "/path/to/todo.txt" ; then
grep `date --date '1 day' '+%m%d%y'` "/path/to/todo.txt" | sed 's/ /_/g' | xargs twidge dmsend twitterusername && sed -i 's/dnes//g' /path/to/todo.txt
else
echo "Not found"
fi
Using cron to run programs on a schedule
cron is a Linux system process that will execute a program at a preset time. To use cron you must prepare a text file that describes the program that you want executed and the times that cron should execute them. Then you use the crontab program to load the text file that describes the cron jobs into cron.
Here is the format of a cron job file:
[min] [hour] [day of month] [month] [day of week] [program to be run]
where each field is defined as
[min] Minutes that program should be executed on. 0-59. Do not set as * or the program will be run once a minute.
[hour] Hour that program should be executed on. 0-23. * for every hour.
[day of month] Day of the month that process should be executed on. 1-31. * for every day.
[month] Month that program whould be executed on. 1-12 * for every month.
[day of week] Day of the week. 0-6 where Sunday = 0, Monday = 1, …., Saturday = 6. * for every day of the week.
[program] Program to be executed. Include full path information.Here are some examples:
0,15,30,45 * * * * /usr/bin/foo
Will run /usr/bin/foo every 15 minutes on every hour, day-of-month, month, and day-of-week. In other words, it will run every 15 minutes for as long as the machine it running.
10 3 * * * /usr/bin/foo
Will run /usr/bin/foo at 3:10am on every day.
10 * 1 * * /usr/bin/foo
Will run /usr/bin/foo at 12:10am on the first day of the month.
10 * * 1 * /usr/bin/foo
Will run /usr/bin/foo at 12:10am on the first month of the year.
10 14 * * 1 /usr/bin/foo
Will run /usr/bin/foo at 2:10pm on every Monday.
There are more options for these. See man man crontab -S 5.
You must use crontab to load cron jobs into cron. First create a text file that uses the above rule to describe the cron job that you want to load into cron. But before you load it, type crontab -l to list any jobs that are currently loaded in crontab.
If none are listed, then it is safe to load your job. Example. If you wanted to run /usr/local/bin/foo once a day at 3:10am, then create a text file
10 3 * * * /usr/bin/foo
Save it as foo.cron. Then type crontab foo.cron. Check to see if it was loaded by typing crontab -l. It should display something like this:
# DO NOT EDIT THIS FILE – edit the master and reinstall.
# (ipwatch.cron installed on Thu Nov 18 11:48:02 1999)
# (Cron version — $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
10 3 * * * /usr/bin/fooIf you want to edit the cron job, then edit foo.cron and then remove the existing cron job (crontab -r) and load it again (crontab foo.cron). You can have multiple jobs. Just put each different one on a seperate line in foo.cron.
contab jobs will run under the user that was in effect when you loaded the job in crontab.
See man cron, man crontab and man crontab -S 5 for more information.