We have moved to a new Sailfish OS Forum. Please start new discussions there.
1 | initial version | posted 2014-08-22 18:50:00 +0200 |
Here is a script to save SMS (text) messages on a Jolla mobile.
You can choose to name the script anything you like (for example, "sms-dump"). You can save the output to a text file by redirecting the output (for example, "sms-dump > sms-with-mom.txt").
NOTE: This is a wiki page. Please feel free to contribute documentation, bug fixes, and any other improvements to this script.
#!/bin/bash
# A script to dump text messages
# Don't let root run this
if [ ${USER} == "root" ]; then
echo "Please run as regular user."
exit 1
fi
# Check for a phone number as a command line argument
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the name if provided
if [ $# -gt 1 ]; then
name=$2
else
name=$1
fi
# Use timestamps to create unique filenames
datetime=`date +"%Y%m%d-%H%M%S"`
tempname=/tmp/sms-${datetime}.txt
# Get the text message data from the phone's database
sql="SELECT direction, startTime, freeText FROM Events WHERE remoteUid LIKE '%$1' AND type=2;"
sqlite3 ~/.local/share/commhistory/commhistory.db "$sql" > ${tempname}
while read line; do
# Check for the desired format...
format=`echo ${line} | sed -e 's/^[12]|.*//'`
if [[ -z ${format} ]]; then
# Get the name of the person who's texting
fromwhom=`echo ${line} | cut -d '|' -f 1`
if [ ${fromwhom} -eq "1" ]; then
fromwhom=$name
else
fromwhom="Me"
fi
# Convert the Unix timestand to a human readable format
unixtime=`echo ${line} | cut -d '|' -f 2`
datetime=`date -d@${unixtime} "+%Y-%m-%d %H:%M"`
# Get the actual text message
message=`echo ${line} | cut -d '|' -f 3`
# Copy all the information into a new file
echo "${fromwhom} (${datetime}): ${message}"
else
# ...Otherwise just copy the line.
echo "${line}"
fi
done < ${tempname}
# Delete the temporary file
rm -f ${tempname}
sms-dump <phone-number> [Name]
sms-dump 4565551234 John # Example
2 | No.2 Revision |
Here is a script to save SMS (text) messages on a Jolla mobile.
You can choose to name the script anything you like (for example, "sms-dump"). You can save the output to a text file by redirecting the output (for example, "sms-dump > sms-with-mom.txt").sms-with-mom.txt"). Make the file executable ("chmod 755 sms-dump"). A convenient place to save it is in "/home/nemo/bin", which is already in the default path.
NOTE: This is a wiki page. Please feel free to contribute documentation, bug fixes, and any other improvements to this script.
#!/bin/bash
# A script to dump text messages
# Don't let root run this
if [ ${USER} == "root" ]; then
echo "Please run as regular user."
exit 1
fi
# Check for a phone number as a command line argument
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the name if provided
if [ $# -gt 1 ]; then
name=$2
else
name=$1
fi
# Use timestamps to create unique filenames
datetime=`date +"%Y%m%d-%H%M%S"`
tempname=/tmp/sms-${datetime}.txt
# Get the text message data from the phone's database
sql="SELECT direction, startTime, freeText FROM Events WHERE remoteUid LIKE '%$1' AND type=2;"
sqlite3 ~/.local/share/commhistory/commhistory.db "$sql" > ${tempname}
while read line; do
# Check for the desired format...
format=`echo ${line} | sed -e 's/^[12]|.*//'`
if [[ -z ${format} ]]; then
# Get the name of the person who's texting
fromwhom=`echo ${line} | cut -d '|' -f 1`
if [ ${fromwhom} -eq "1" ]; then
fromwhom=$name
else
fromwhom="Me"
fi
# Convert the Unix timestand to a human readable format
unixtime=`echo ${line} | cut -d '|' -f 2`
datetime=`date -d@${unixtime} "+%Y-%m-%d %H:%M"`
# Get the actual text message
message=`echo ${line} | cut -d '|' -f 3`
# Copy all the information into a new file
echo "${fromwhom} (${datetime}): ${message}"
else
# ...Otherwise just copy the line.
echo "${line}"
fi
done < ${tempname}
# Delete the temporary file
rm -f ${tempname}
sms-dump <phone-number> [Name]
sms-dump 4565551234 John # Example
3 | No.3 Revision |
Here is a script to save SMS (text) messages on a Jolla mobile.
You can choose to name the script anything you like (for example, "sms-dump"). You can save the output to a text file by redirecting the output (for example, "sms-dump > sms-with-mom.txt"). Make the file executable ("chmod 755 sms-dump"). A convenient place to save it is in "/home/nemo/bin", which is already in the default path.
NOTE: This is a wiki page. Please feel free to contribute documentation, bug fixes, and any other improvements to this script.
#!/bin/bash
# A script to dump text messages
# Don't let root run this
if [ ${USER} == "root" ]; then
echo "Please run as regular user."
exit 1
fi
# Check for a phone number as a command line argument
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the name if provided
if [ $# -gt 1 ]; then
name=$2
else
name=$1
fi
# Use timestamps to create unique filenames
datetime=`date +"%Y%m%d-%H%M%S"`
tempname=/tmp/sms-${datetime}.txt
# Get the text message data from the phone's database
sql="SELECT direction, startTime, freeText FROM Events WHERE remoteUid LIKE '%$1' AND type=2;"
sqlite3 ~/.local/share/commhistory/commhistory.db "$sql" > ${tempname}
while read line; do
# Check for the desired format...
format=`echo ${line} | sed -e 's/^[12]|.*//'`
if [[ -z ${format} ]]; then
# Get the name of the person who's texting
fromwhom=`echo ${line} | cut -d '|' -f 1`
if [ ${fromwhom} -eq "1" ]; then
fromwhom=$name
else
fromwhom="Me"
fi
# Convert the Unix timestand to a human readable format
unixtime=`echo ${line} | cut -d '|' -f 2`
datetime=`date -d@${unixtime} "+%Y-%m-%d %H:%M"`
# Get the actual text message
message=`echo ${line} | cut -d '|' -f 3`
# Copy all the information into a new file
echo "${fromwhom} (${datetime}): ${message}"
else
# ...Otherwise
# ...Fallback, just copy the line.
entire original line
echo "${line}"
fi
done < ${tempname}
# Delete the temporary file
rm -f ${tempname}
sms-dump <phone-number> [Name]
sms-dump 4565551234 John # Example
4 | No.4 Revision |
Here is a script to save SMS (text) messages on a Jolla mobile.
You can choose to name the script anything you like (for example, "sms-dump"). You can save the output to a text file by redirecting the output (for example, "sms-dump > sms-with-mom.txt"). Make the file executable ("chmod 755 sms-dump"). A convenient place to save it is in "/home/nemo/bin", which is already in the default path.
NOTE: This is a wiki page. Please feel free to contribute documentation, bug fixes, and any other improvements to this script.
#!/bin/bash
# A script to dump text messages
# Don't let root run this
if [ ${USER} == "root" ]; then
echo "Please run as regular user."
exit 1
fi
# Check for a messages to stdout
#
# Usage:
# sms-dump <phone-number> [Name]
#
# phone-number : A phone number (example: 4565551234)
#
# Name : (Option) The contact's name, as a it will appear in the output.
# If not provided then it will use the phone number.
# My name, as it will appear in the output
me="Me"
# The database with the SMS messages
sql_database="/home/nemo/.local/share/commhistory/commhistory.db"
# The SQL command line argument
if [ $# -lt to select which messages to retrieve
# direction : Who sent the message, can be 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the name if provided
if [ $# -gt 1 ]; then
name=$2
else
name=$1
fi
# Use timestamps to create unique filenames
datetime=`date +"%Y%m%d-%H%M%S"`
tempname=/tmp/sms-${datetime}.txt
# Get the (them) or 2 (me)
# startTime : When the message was sent
# freeText : The text message data from the phone's database
sql="SELECT of the actual message
# remoteUid : The contact's phone number
# type : Messages are of type 2
sql_command="SELECT direction, startTime, freeText FROM Events WHERE remoteUid LIKE '%$1' AND type=2;"
# Don't let root run this
if [ $UID -eq 0 ]; then
echo "Do not run as root."
exit 1
fi
# Check for a phone number as a command line argument
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the contact's name, if provided
if [ $# -gt 1 ]; then
contact="$2"
else
contact="$1"
fi
# Get the message data from the phone's database
# Parse each line and print it, nice and pretty
sqlite3 ~/.local/share/commhistory/commhistory.db "$sql" > ${tempname}
"$sql_database" "$sql_command" | while read line; do
# Check for the desired format...
format=`echo ${line} $line | sed -e 's/^[12]|.*//'`
's/^[12]|[0-9].*|.*/CORRECTFORMAT/'`
if [[ -z ${format} ]]; [ "$format" == "CORRECTFORMAT" ]; then
# Get the name of the person who's texting
fromwhom=`echo ${line} $line | cut -d '|' -f 1`
if [ ${fromwhom} $fromwhom -eq "1" 1 ]; then
fromwhom=$name
fromwhom="$contact"
else
fromwhom="Me"
fromwhom="$me"
fi
# Convert the Unix timestand timestamp to a human readable format
unixtime=`echo ${line} $line | cut -d '|' -f 2`
datetime=`date -d@${unixtime} "+%Y-%m-%d %H:%M"`
# Get the actual text message
message=`echo ${line} $line | cut -d '|' -f 3`
# Copy all the information into a new file
echo "${fromwhom} "$fromwhom (${datetime}): ${message}"
$message"
else
# ...Fallback, just copy the entire original line
echo "${line}"
"$line"
fi
done < ${tempname}
# Delete the temporary file
rm -f ${tempname}
done
sms-dump <phone-number> [Name]
sms-dump 4565551234 John # Example
5 | No.5 Revision |
Here is a script to save SMS (text) messages on a Jolla mobile.
You can choose to name the script anything you like (for example, "sms-dump"). You can save the output to a text file by redirecting the output (for example, "sms-dump > sms-with-mom.txt"). Make the file executable ("chmod 755 sms-dump"). A convenient place to save it is in "/home/nemo/bin", which is already in the default path.
NOTE: This is a wiki page. Please feel free to contribute documentation, bug fixes, and any other improvements to this script.
#!/bin/bash
# A script to dump text messages to stdout
#
# Usage:
# sms-dump <phone-number> [Name]
#
# phone-number : A phone number (example: 4565551234)
#
# Name : (Option) The contact's name, as it will appear in the output.
# If not provided then it will use the phone number.
# My name, as it will appear in the output
me="Me"
# The database with the SMS messages
sql_database="/home/nemo/.local/share/commhistory/commhistory.db"
# The SQL command to select which messages to retrieve
# direction : Who sent the message, can be 1 (them) or 2 (me)
# startTime : When the message was sent
# freeText : The text of the actual message
# remoteUid : The contact's phone number
# type : Messages are of type 2
sql_command="SELECT direction, startTime, freeText FROM Events WHERE remoteUid LIKE '%$1' AND type=2;"
# Don't let root run this
if [ $UID -eq 0 ]; then
echo "Do not run as root."
exit 1
fi
# Check for a phone number as a command line argument
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <phone-number> [Name]"
exit 1
fi
# Set the contact's name, if provided
if [ $# -gt 1 ]; then
contact="$2"
else
contact="$1"
fi
# Get the message data from the phone's database
# Parse each line and print it, nice and pretty
sqlite3 "$sql_database" "$sql_command" | while read line; do
# Check for the desired format...
format=`echo $line | sed -e 's/^[12]|[0-9].*|.*/CORRECTFORMAT/'`
if [ "$format" == "CORRECTFORMAT" ]; then
# Get the name of the person who's texting
fromwhom=`echo $line | cut -d '|' -f 1`
if [ $fromwhom -eq 1 ]; then
fromwhom="$contact"
else
fromwhom="$me"
fi
# Convert the Unix timestamp to a human readable format
unixtime=`echo $line | cut -d '|' -f 2`
datetime=`date -d@${unixtime} "+%Y-%m-%d %H:%M"`
# Get the actual text message
message=`echo $line | cut -d '|' -f 3`
# Copy all the information into a new file
echo "$fromwhom (${datetime}): $message"
else
# ...Fallback, just copy the line
echo "$line"
fi
done
sms-dump <phone-number> [Name]
sms-dump 4565551234 John # Example