I’ve wrote this shell script that uses an SMS to post to Twitter. It is ment to be used as an Eventhander for SMS Server Tools, but it’s simple enough for stand alone usage with simple text files.
If used as an Eventhandler the arguments are “RECEIVED” and the path to the SMS file, add “eventhandler=/path/to/sms2twitter.sh” to your smsd.conf. Without SMS Server Tools you can also use a simple file for posting to twitter:
Create a file starting like this:
-
Phone: 0634567890
-
-
Your tweet in max. 140 characters
Then call this script with the path to your file:
-
sms2twitter.sh /path/to/file.txt
You will need to create a sqlite3 DB with this schema:
-
sqlite3 sms2twitter.db \
-
"CREATE TABLE account (phone, username, password, PRIMARY KEY(phone))"
For every Phone that you allow to post Tweets thru SMS you need to run:
-
sqlite3 sms2twitter.db \
-
"INSERT INTO account VALUES (‘phonenumber’, ‘username’, ‘password’)"
Lees meer…
Here is a bash script that uses kdialog to present a password prompt and tries to mount a crypt device. It interacts with the (k)ubuntu “cryptsetup” package.
-
-
#!/bin/bash
-
if [ -r /lib/cryptsetup/cryptdisks.functions ]; then
-
. /lib/cryptsetup/cryptdisks.functions
-
else
-
kdialog –title $(basename $0) –error "/lib/cryptsetup/cryptdisks.functions not found"
-
exit 1
-
fi
-
-
crypt_create (){
-
DLG_TITLE="Cryptsetup Dialog"
-
mountpoint=$(grep $MAPPER/$1 /etc/fstab | awk ‘{FS=" "}{print $2}’)
-
sudo cryptsetup status $1 > /dev/null
-
if [ $? -ne 0 ]; then
-
pwd=$(kdialog –title "$DLG_TITLE" –password "mapping $1 to device <$2>
-
-
Enter passphrase:")
-
if [ $? -ne 0 ]; then return 3; fi
-
if [ "$pwd" == "" ]; then
-
kdialog –title "$DLG_TITLE" –warningyesno "empty password, try again?" && {
-
crypt_create $1 $2
-
return 2
-
}
-
fi
-
echo "$pwd" | sudo cryptsetup create $1 $2
-
mount $mountpoint 2&>/dev/null|| {
-
sudo cryptsetup remove $1
-
kdialog –title "$DLG_TITLE" –warningyesno "cryptsetup create <$1> <$2> failed, try again?" && {
-
crypt_create $1 $2
-
return 2
-
}
-
return 0
-
}
-
else
-
if [ -z $3 ]; then
-
kdialog –yesno "$MAPPER/$CRYPT_NAME is active, do you want to deactivate?" && {
-
umount $mountpoint
-
sudo cryptsetup remove $1
-
}
-
fi
-
fi
-
return 1 #cryptdevice already setup
-
}
-
-
if [ -r $TABFILE ]; then
-
grep -Ev "^#" $TABFILE | while read line; do
-
cryptname=$(echo $line | awk ‘{print $1}’)
-
cryptdevice=$(echo $line | awk ‘{print $2}’)
-
crypt_create $cryptname $cryptdevice $1
-
done
-
exit 0
-
else
-
kdialog –title $(basename $0) –error "$TABFILE not readable"
-
exit 2
-
fi
-