find /folder -type f -mtime +30 -exec rm -rf {} \;
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo $$ $USER \
"$(history 1)" >> ~/.bash_eternal_history'
Installation
Once you have plugged the USB Data cable and the T230 phone, you may have:
root@smsserver:~# lsusb
Bus 001 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 001: ID 0000:0000
root@fr-c400-0257-l:~# ls -la /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 2007-03-22 10:17 /dev/ttyUSB0
root@smsserver:~#
You can test your configuration using minicom
root@smsserver:~# minicom -s
-s is for minicom setup on launch. You may configure the serial port to /dev/ttyUSB0 and the speed to 9600 8N1.
Welcome to minicom 2.2
OPTIONS: I18n
Compiled on Mar 7 2007, 15:10:03.
Port /dev/ttyUSB0
Press CTRL-A Z for help on special keys
AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
OK
AT&C1
OK
ATM0
OK
ATDT1234
NO CARRIER
ATM0
OK
AT+CPIN?
+CPIN: READY
OK
AT+CMGF=1
OK
AT+CMGS
ERROR
AT+CMGS="06XXXXXXXX"
> Hello World
+CMGS: 0
OK
gnokii settings
Edit the /etc/gnokiirc file:
port = /dev/ttyUSB0
[...]
model = AT
# model = 6510
[...]
use_locking = no
#use_locking = yes
[...]
serial_baudrate = 9600
# serial_baudrate = 19200
The use_locking setting has been modified as it may happen that I send SMS to more than one people at a time. The solution would be to use smsd…
From Mail to SMS
As we are using postfix and procmail, root user may not be used!
Let’s create a itroot user that will be the recipient of email notification to be turned into SMS.
Create a .procmailrc file for this user. A convention will be used for notification emails. The subject will contain [SMS] and only the subject of the email will be transfered as an SMS:
DEFAULT=/var/spool/mail/itroot
MAILDIR=$HOME/Mail
:0
* ^Subject:.*\[SMS\].*
| cat - | awk -F":” ‘$1 == “Subject” { for(i=2; i <=$NF; i++) $(i-1) = $i; print $0 }’ | sudo /usr/bin/gnokii –sendsms 06XXXXXXXX >> /var/log/SMS.log 2>&1
As you can see, due to permissions issue, itroot as been allowed to invoke gnokii using sudo without password. This implies the following line in /etc/sudoers:
itroot ALL = NOPASSWD: /usr/bin/gnokii
More over, a log file has been created with write permission for itroot user: /var/log/SMS.log". This log file will allow you to make sure that gnokii is doing its job
.bashrc:
mygrants()
{
mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}
mygrants --host=prod-db1 --user=admin --password=secret | grep rails_admin | mysql --host=staging-db1 --user=admin --password=secret
mygrants --password=xxx> /mysql.grant
#!/bin/bash
LAMEOPTS="-V 1"
for FILE in *.wav ; do
OUTNAME="${FILE%%.wav}.mp3"
lame $LAMEOPTS "$FILE" "$OUTNAME"
done
find . -mtime 0 # find files modified between now and 1 day ago
# (i.e., within the past 24 hours)
find . -mtime -1 # find files modified less than 1 day ago
# (i.e., within the past 24 hours, as before)
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
find . -mmin +5 -mmin -10 # find files modified between
# 6 and 9 minutes ago
cat /usr/local/bin/run-in-new-tab
#! /bin/bash
window=”$(xdotool search –class gnome-terminal | head -1)”
xdotool windowfocus $window
xdotool key shift+Up
xdotool type “$*”
xdotool key Return
#! /bin/bash
ssh $1 -l root "cat /etc/*-release||cat /etc/slackware-version&& dmidecode |grep 'Product Name'&&uname -a&&cat /proc/cpuinfo|egrep 'processor|model name'&&free -m"
#! /bin/bash
for i in `ls /home/`
find /home/$i/Maildir/*/* -type f -size +8192k -mtime +0 -exec grep -il "^Subject: test subject" {} \; -exec rm -f {} \;
done