
On Thu, Jun 21, 2012 at 4:08 PM, Thuo Wilson <lixton@gmail.com> wrote:
Well, still scratching my head and am heading somewhere; This is doing exactly what i need BUT reading one line at a time untill the 10th line, if i want more i add manually... This might help some1 someday! But if there is a way to perfect it please do so.....
#!/bin/bash
smsfile=email_to_sms `grep Subject /var/spool/mail/sms >> email_to_sms` if [[ -s $smsfile ]] ; then cat /dev/null > /var/spool/mail/sms sed -i 's/Subject: //g' $smsfile echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1 {print $1}' $smsfile` echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2 {print $1}' $smsfile` echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3 {print $1}' $smsfile` echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4 {print $1}' $smsfile` echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5 {print $1}' $smsfile` echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6 {print $1}' $smsfile` echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7 {print $1}' $smsfile` echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8 {print $1}' $smsfile` echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9 {print $1}' $smsfile` echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10 {print $1}' $smsfile` else echo "***********Sorry the SMS FILE "$smsfile" is empty.************" fi /etc/init.d/gammu-smsd start cat email_to_sms >> email_to_sms2 cat /dev/null > email_to_sms
Thi is a rework of your script, though I did not test it yet.. #!/bin/sh smsfile=email_to_sms spoolfile=/var/spol/mail/sms grep Subject "$spoolfile" >> "$smsfile" if [ -s "$smsfile" ]; then : > "$spoolfile" sed -e 's/Subject: //g' "$smsfile" | awk ' { if (NR > 10) exit print | "/usr/bin/gammu --sendsms TEXT " $1 }' else echo "***********Sorry the SMS FILE "$smsfile" is empty.************" fi gammu-smsd start cat "$smsfile" >> email_to_sms2 : > "$smsfile" Note: If you remove/comment out the " if (NR > 10) exit", then all lines in the file will get processed. -- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254733744121/+254722743223 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ I can't hear you -- I'm using the scrambler.