#!/bin/bash # # obexnote by MartinG 2004-07-14 # # (based on some script I found posted on the web in some # language that I do not understand.) # For sending notes to mobile phones using obexftp over IR or BlueTooth # # Feel free to improve this script - but please be kind and mail me # a copy: gronslet (that funny schnabel) gmail.com # VER=0.31 myname=`basename $0` if [ $# -eq 0 ]; then echo -e "ObexNote by MartinG. Version: $VER" echo -e " Usage: $myname myPureTextFile.txt" echo -e "\tExample: $myname note1.txt" echo -e " If the first argument is \"-\" input is read from STDIN" echo -e "\tExample: echo There is no God | $myname -" echo -e "\tExample: cat bible.txt | $myname -" exit 1 fi; file=$1 name=`basename $1 .txt` # Safety first... Use a random number in temporary files if for some # odd reason multiple copies run at the same time... R=$RANDOM if [ $1 == "-" ]; then tee /tmp/tmp-irnote$R >/dev/null file=/tmp/tmp-irnote$R name="" fi; notetmpfile=/tmp/NOTE-$R- vnttmpfile=/tmp/note-$R.vnt ## A note can have max 500 letters, therefore splitting to 420 ## leaving room for headers split -b 420 $file $notetmpfile NUMBER="1" for j in $(ls $notetmpfile*) ; do VAR="$NUMBER $name" echo "BEGIN:VNOTE " > $vnttmpfile echo "VERSION:1.1 " >> $vnttmpfile echo "BODY: $(for i in $(cat $j ) ; do VAR="$VAR $i"; done; echo $VAR) " >> $vnttmpfile echo "DCREATED:$(date +%Y%m%dT%H%M00 ) " >> $vnttmpfile echo "LAST-MODIFIED:$(date +%Y%m%dT%H%M00 ) " >> $vnttmpfile echo "CLASS:PUBLIC " >> $vnttmpfile echo "X-IRMC-LUID:000001000000 " >> $vnttmpfile echo "END:VNOTE " >> $vnttmpfile # Archive note: echo Archiving note to $HOME/notes/$name$NUMBER.vnt cp $vnttmpfile $HOME/notes/$name$NUMBER.vnt # This is where the note is being sent over IR (Or BlueTooth or whatever)... echo Sending note... #btctl put 1 /tmp/nota.vnt obexftp -p $vnttmpfile echo "Message part $NUMBER" echo "====================================================" echo "====================================================" cat $j echo "" echo "====================================================" echo " Press Accept Note on mobile device, " echo " then press Enter to transfer next part - if any. " echo "====================================================" read NADA let NUMBER=$NUMBER+1 rm $vnttmpfile done echo Cleaning up... rm -f $notetmpfile* # Remove pipe temp file: rm -f /tmp/tmp-irnote$R echo done.