|
-
October 24th, 2004, 12:04 PM
#1
small, useful scripts
Hi
Here on AO, quite a few creative minds hang around.
Hence, I had the following idea:
I think a lot of us use some tiny scripts on a daily basis -
scripts which (at least ) you think are "killer"-scripts
ie are amazingly useful and elegant and ..., you know.
These could be scripts showing all shares on your LAN,
making use of nmap and other tools to create an extended
fingerprinting, whatever - and you want to present
them to us.
There is no such a thing like a criterion which script you
can share with us, however it would be nice if it is <4kb
(without comments) and written by yourself. You can also
assume that we are omnipotent ie have all programs, tools
and services available.
Note: it is the idea which is important, not the actual
implementation.
My contribution:
Motivation: Writing sms on a cell phone is cumbersome, and it
costs money. Crucial server notification mails are somewhere in your
mailbox, while you are enjoying your cocktail at the beach.
Description: Friends can send me short emails, which will be
sent to my cell phone as a sms (can be extended to server
notifications etc. and hence is security related).
This is done by including a "[SMS]" in the subject.
Requirements:
- procmail[1]. Excellent tutorial, here on AO[2].
- email-sms-service (by your cell-phone provider, ISP, ...). In my case: it's free.
procmail-block:
Code:
:0 HB
* ^Subject:.*\[SMS\]
{
#create a email-copy anyway in your mailbox
:0 c
/var/spool/mail/yourname
#create a a file in your procmail directory, e.g. ~/mail/pm
:0 c
|cat >/home/yourname/mail/pm/tmp.dat
#start a script in your procmail directory, e.g. ~/mail/pm
:0
|/home/yourname/mail/pm/sms.sh
}
shell script sms.sh:
Code:
#!/bin/bash
#cell phone info
my_number=1234567890
my_roamer=sms.myprovider.com
#maximal message length
max_message=110
#header delimiter (check yourself how your email-headers ends)
header_end="version=2.64"
#switch to the procmail directory
cd /home/yourname/mail/pm
#prepare info short message (subject and sender)
cat tmp.dat |grep Subject >tmp.sms
cat tmp.dat |grep From: >>tmp.sms
tail -c$max_message tmp.sms > tmp.sms.cut
#send the info short message (maybe identify yourself, depending on your local settings)
mail $my_number@$my_roamer < tmp.sms.cut > /dev/null
#a short message with just the tail of the file (not a good idea due to the possible existence of signatures)
#tail -c$max_message tmp.dat >tmp.sms.cut
#a short message send the first $max_message chars of the body (better choice, but "end of header" has to be checked from time to time)
cut_here=`grep -n $header_end tmp.dat | awk -F: '{print $1}' |head -1`
length_of_tmp=`wc -l tmp.dat | awk '{print $1}'`
cut_here=$(($length_of_tmp-$cut_here))
cat tmp.dat |tail -$cut_here >tmp.sms
head -c$max_message tmp.sms > tmp.sms.cut
#send the body short message (maybe identify yourself, depending on your local settings)
mail $my_number@$my_roamer < tmp.sms.cut > /dev/null
#clean up
rm tmp.dat
rm tmp.sms
rm tmp.sms.cut
Remarks:
Here, one email generates two messages: A subject-from message and one message based on the "body".
You could of course split the whole email into blocks and send several short messages, but be careful:
what happens if a friend of yours sends you a 2MB pdf-file...
I hope, that some of you can contribute to this thread.
It's always astonishing, which ideas are floating around on
this very planet earth.
Cheers
[1] http://www.icewalkers.com/Linux/Soft.../procmail.html
or cygwin: http://linux.rz.ruhr-uni-bochum.de/d...ease/procmail/
[2] http://www.antionline.com/showthread...hreadid=237207
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|