# $number is like '+447123456789' # the end bit of the number. this seems to be used in the group_uid field -- no idea what for partialnumber=$(echo $number | sed -r 's/.*([0-9]{7})$/\1/') # $message is the message message=${message//\'/\'\'} #replace singlequotes with double-singlequotes for sqlite # build query query="insert into Events (service_id, event_type_id, storage_time, start_time, end_time, is_read, flags, bytes_sent, bytes_received, local_uid, local_name, remote_uid, free_text, group_uid, outgoing, mc_profile) values (3, 7, strftime('%s', 'now'), strftime('%s', 'now'), 0, 1, 0, 0, 0, 'ring/tel/ring', '<SelfHandle>', '$number', '$message', '$partialnumber', 1, 0);" echo "$query" | sqlite3 $HOME/.rtcom-eventlogger/el-v1.db