I think Fionn's phone has done this a bit before.
If it is low on free memory then it gets very slow + flaky.
Drops calls, resets, ...
Need to free up memory by clearing off photos/videos/messages.
I had copied photos off it a week ago - bluetooth to laptop. But failed to delete them after copying. The delete just timedout. I manually transferred and deleted videos and reset the phone. This gave 2M free instead of about 1M. Then deleting and transferring photos wasn't going fast. Manually I copied a couple of files across but mostly ubuntu konqueror file browser window would hang/pulse for a bit then report error. So I called my bt-sync-mobile.sh script repeatedly and it transferred a few files each time and eventually also deleted all. With a small mod. Yays.
http://gaoithe.blogspot.com/2009/11/bt-sync-mobilesh-script-handle-files.html
Phone seemed much more stable. Took a good while after restart for messages to be readable so I guess message database is quite big and needs indexing/loading into memory.
nokia 3120. Can only access some of file system on bluetooth and we don't have a custom usb/other cable for phone of course. Pain. Bring on the generic (Euro?) standards for data transfer cables / power adaptors / IR TV/DVD/car controls / whatever!
http://gaoithe.blogspot.com/2009/11/bt-sync-mobilesh-script-handle-files.html
$ git diff torture/
diff --git a/torture/bin/bt-sync-mobile.sh b/torture/bin/bt-sync-mobile.sh
index 9a733d7..670999e 100755
--- a/torture/bin/bt-sync-mobile.sh
+++ b/torture/bin/bt-sync-mobile.sh
@@ -170,6 +170,7 @@ function wipe_existing_files_from_list () {
echo for now we check if file exists already and wipe from list
##file list to retrieve by eliminating ones already retrieved
FILESTOGET=
+ FILESTODEL="$FILES"
for F in $FILES ; do
F2=$(echo $F|sed 's/_SPACE_/ /g')
if [ "$OPTS_VERBOSE" != "" ] ; then
@@ -238,7 +239,7 @@ function track_the_files () {
# cleanup files matching certain patterns on mobile if they were successfully retrieved
# we could use -G earlier (get and delete)
function clean_the_files () {
- for F in $FILES ; do
+ for F in $FILESTODEL ; do
F=$(echo $F|sed 's/_SPACE_/ /g')
###if [[ -f bin/eirkey.pl && ( -n ${FG#wami-2} || -n ${F%gpx} ) ]] ; then echo yep; fi
diff --git a/torture/bin/run-bt-sync-mobile.sh b/torture/bin/run-bt-sync-mobile.sh
index 298ab8b..5e496ab 100755
--- a/torture/bin/run-bt-sync-mobile.sh
+++ b/torture/bin/run-bt-sync-mobile.sh
@@ -5,3 +5,4 @@ bt-sync-mobile.sh -c Pooky "C:/Data/Videos/"
# .amr files
#bt-sync-mobile.sh Pooky "C:/Data/Sounds/Digital/"
+#bt-sync-mobile.sh -c "Nokia 3120 fionnuala" "Images/"
$ meld torture/
$ git commit -m"bt-sync-mobile.sh need to delete already synced files which do not get in FILES (to transfer) var" torture/bin/bt-sync-mobile.sh torture/bin/run-bt-sync-mobile.sh
Created commit 021d6db: bt-sync-mobile.sh need to delete already synced files which do not get in FILES (to transfer) var
2 files changed, 3 insertions(+), 1 deletions(-)
Showing posts with label sync. Show all posts
Showing posts with label sync. Show all posts
Wednesday, 26 May 2010
Saturday, 14 November 2009
bt-sync-mobile.sh script handle files with spaces in names.
bt-sync-mobile.sh updated with a bit of grief to allow sync files with spaces in file names. Could not do it "properly" and get quoting/slashifying correct. Hacked s/ /_SPACE_/g when getting file list then iterate lists and s/_SPACE_/ / when needed.
Used to sync mobile sounds.
And photos, here's one photo synced:
http://www.facebook.com/home.php?ref=home#/photo.php?pid=30466015&id=1118555017
And here's one that got a bit washed out:
Here's the script:
Presumably cut&pasting it from here might not work ... depending ... oh well ...
See below below for script, embed from github:
#!/bin/bash
#INVOCATION:
#$ bt-sync-mobile.sh [device [dir]]
#$ bt-sync-mobile.sh Pooky 'C:\Data\Images\' 2>&1 |tee .btsync/bt_sync_images.log
#Stuff is synched to ~/.btsync/`echo $dir |sed 's/[\/ \\"]/_/g'`
#wami*.gpx and *.jpg files are cleared off device if synced successfully and mp4 or png
#
#REQUIREMENTS:
#linux with bluetooth hardware
#various bluetooth linux utils, these ubuntu packages:
#bluez bluez-utils(?) obexftp openobex-apps
#
# some of these come by default, and some are not needed, but this is on the system the script was tested on
#$ dpkg -l |egrep "bluez|hci|obex" |sed 's/ */ /g'
#ii bluez 4.32-0ubuntu4.1 Bluetooth tools and daemons
#ii bluez-alsa 4.32-0ubuntu4.1 Bluetooth audio support
#ii bluez-cups 4.32-0ubuntu4.1 Bluetooth printer driver for CUPS
#ii bluez-gnome 1.8-0ubuntu5 Bluetooth utilities for GNOME
#ii bluez-gstreamer 4.32-0ubuntu4.1 Bluetooth gstreamer support
#ii bluez-utils 4.32-0ubuntu4.1 Transitional package
#ii gnome-vfs-obexftp 0.4-1build1 GNOME VFS module for OBEX FTP
#ii libopenobex1 1.5-1 OBEX protocol library
#ii libopenobex1-dev 1.5-1 OBEX protocol library - development files
#ii obex-data-server 0.4.4-0ubuntu1 D-Bus service for OBEX client and server sid
#ii obexftp 0.19-7ubuntu2 file transfer utility for devices that use t
#ii openobex-apps 1.5-1 Applications for OpenOBEX
#ii python-bluez 0.16-1ubuntu1 Python wrappers around BlueZ for rapid bluet
#
#NOTES:
#The bluetooth connect seems to fail sometimes.
#Files with funny chars in name could cause a problem. maybe. () are okay
#Files to clear out are hardcoded.
#It's simple - just syncs files up if they don't exist on host.
#There are various other TODOs
#
### TODO: hey look at Images\_PAlbTN\ dir ! every thumbnail since year DOT! sneaky !
# nokia E65 phone
#
#I've thrown together an ugly script to automate sync (a dumb enough sync) of files from my phone.
#And made an ugly blog post about the ugly script also:
#http://gaoithe.livejournal.com/33541.html
#
#It would be nice to sync properly like rsync (i.e. check files size and date/times on host and device).
#It would be nice to use rsync itself! :)
#Possibly obexftp could be improved, commands like "get-if-changed, put-if-not-up-to-date", recursive ability.
#Hmm. Hmm.
#mount could mount some ugly thing + obexftp interface? then rsync away
# Hmmm.
#
# 14/11/2009 Fix allow spaces in file names.
# probably also allow spaces in dirs and device name
# for F in *.amr ; do echo F=$F; done
# for F in *.amr ; do echo F=$F; N=${F%%.amr}; if [[ ! -e $N.ogg ]] ; then ffmpeg -i $F $N.ogg; fi; done
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# for F in *.amr ; do echo F=$F; N=${F%%.amr}; if [[ ! -e $N.ogg ]] ; then ffmpeg-amr -i "$F" "$N.ogg"; fi; done
#
# f=Sound\ clip\(10\).ogg; n=${f%%.amr}; mv "$f" "${n}_DragonSoup.ogg"
# for f in DataSoundsDigital/Sound\ clip\({1,2}*\).ogg; do vlc "$f"; done
# for f in DataSoundsDigital/Sound\ clip\({1*,20,21,22,23}\).ogg; do n=${f%%.ogg}; mv "$f" "${n}_DragonSoup.ogg"; done
#
# for f in DataSoundsDigital/Sound\ clip\(*\).ogg; do vlc "$f"; done
# for f in *.flv; do n=${f%%.flv}; if [[ ! -e "$n.wav" ]] ; then ffmpeg -i "$f" "$n.wav"; fi; done
DEVICENAME="$1"
#echo all is $*
BTSYNCHOME=~/.btsync
# DEVICENAME can be blank (scans all devices)
HCISCAN=`hcitool scan |grep "$DEVICENAME" |grep -v ^Scanning `
#Scanning ...
# 00:1F:5D:BF:29:39 Nokia 3120 fionnuala
# 00:17:E5:EE:29:18 Pooky
#check for duplicates
DEVCOUNT=`echo "$HCISCAN" |wc -l`
HCISCAN_S=`echo "$HCISCAN" |sed 's/[\t ][\t ]*/ /g;s/^ *//;'`
BTADDR=`echo "$HCISCAN_S" |cut -d' ' -f1`
DEVNAME=`echo "$HCISCAN_S" |cut -d' ' -f2-`
#echo "DEVCOUNT=$DEVCOUNT HCISCAN=$HCISCAN
#BTADDR=$BTADDR DEVNAME=$DEVNAME"
if [[ $DEVCOUNT -ne 1 ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
Which device?
$HCISCAN
"
exit;
fi
echo "BTADDR=$BTADDR DEVNAME=$DEVNAME"
#sudo hcitool info $BTADDR
DIRTOSYNC="$2"
# TODO pass in dir/file to sync on cmd line in $2
if [[ -z $DIRTOSYNC ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
e.g. $0 \$BTADDR \"C:/Data/Images/\"
e.g. $0 $BTADDR \"C:/Data/Videos/\"
e.g. $0 42:54:41:44:44:52 \"C:/Data/Sounds/\"
"
DIRTOSYNC="C:/Data/"
#exit;
fi
mkdir -p $BTSYNCHOME
DIRTOSYNC_HASH=`echo "$DIRTOSYNC" |sed 's/[\/ \\"]/_/g'`
# cd to where we are getting files
mkdir -p $BTSYNCHOME/$DIRTOSYNC_HASH
cd /tmp
cd $BTSYNCHOME/$DIRTOSYNC_HASH
pwd
#obexftp -b $BTADDR -v -l ""
#obexftp -b $BTADDR -v -l "C:/"
echo DIRTOSYNC=$DIRTOSYNC DIRTOSYNC_HASH=$DIRTOSYNC_HASH
obexftp -b $BTADDR -v -l "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.list
echo get list of all files
echo TODO: parse xml safely/properly
#
#
#FILES=$(grep "
FILES=$(grep "
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.log
echo FILES=$FILES |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.log
## forget about first retrieve or not, just check files on each system
#if [[ -f $BTSYNCHOME/$DIRTOSYNC_HASH.success ]] ; then
#echo for second/.. retrieve just get differences
echo TODO: recurse into directories
echo TODO get updated files, now we get new files only
function wipe_existing_files_from_list () {
echo for now we check if file exists already and wipe from list
##file list to retrieve by eliminating ones already retrieved
FILESTOGET=
for F in $FILES ; do
#F=$(echo $F|sed 's/_SPACE_/ /g')
if [[ ! -f $F ]] ; then
FILESTOGET="$FILESTOGET $F"
fi
done
FILES="$FILESTOGET"
#diff $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
#mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
}
function get_the_files () {
if [[ ! -z $FILES ]] ; then
echo get the files
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.get
SP_Q=$(echo $FILES|grep _SPACE_)
if [[ "$SP_Q" != "" ]] ; then
# spaces in file names so must do them induhvidually
for F in $FILES; do
F=$(echo $F|sed 's/_SPACE_/ /g')
echo "obexftp get $F"
echo obexftp -b $BTADDR -v -c \"$DIRTOSYNC\" -g \"$F\"
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -g "$F" |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.get
done
else
echo "obexftp get $FILES"
echo obexftp -b $BTADDR -v -c \"$DIRTOSYNC\" -g $FILES
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -g $FILES |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.get
fi
# can obexftp do a dir? would be handy.
#obexftp -b $BTADDR -v -g "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.getdir
# also -G (get and delete) could be used for some files
fi
}
# TODO/half DONE track and check each file seperately
# TODO maybe if we got the file, store the associated line then in .success file
# use size/date in xml and on file system.
# ideally we want commands: GET[and remove] if newer/different
function track_the_files () {
#CHECKFILES=`echo $FILES |sed 's/ / && -f /g'`
#if [[ $CHECKFILES ]] ; then
# mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.success
for F in $FILES ; do
F=$(echo $F|sed 's/_SPACE_/ /g')
if [[ -f $F ]] ; then
# a file name which is part of others will cause problems
FILEINFO=`grep "> $BTSYNCHOME/$DIRTOSYNC_HASH.success
fi
done
}
## TODO cleanup all files on mobile retrieved this time or previous
## allows syncing as soon as possible but cleaning after longer (keep recent photos, traces, ...)
# cleanup files matching certain patterns on mobile if they were successfully retrieved
# we could use -G earlier (get and delete)
function clean_the_files () {
for F in $FILES ; do
F=$(echo $F|sed 's/_SPACE_/ /g')
###if [[ -f bin/eirkey.pl && ( -n ${FG#wami-2} || -n ${F%gpx} ) ]] ; then echo yep; fi
if [[ -f $F && ( -n ${F#wami-2*.gpx} || -n ${F#*.jpg} || -n ${F#*.mp4} || -n ${F#*.png} ) ]] ; then
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -k $F |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.clean
fi
done
}
wipe_existing_files_from_list
echo "files to get FILES=$FILES"
get_the_files
track_the_files
clean_the_files
Used to sync mobile sounds.
And photos, here's one photo synced:
http://www.facebook.com/home.php?ref=home#/photo.php?pid=30466015&id=1118555017
And here's one that got a bit washed out:
Here's the script:
Presumably cut&pasting it from here might not work ... depending ... oh well ...
See below below for script, embed from github:
#!/bin/bash
#INVOCATION:
#$ bt-sync-mobile.sh [device [dir]]
#$ bt-sync-mobile.sh Pooky 'C:\Data\Images\' 2>&1 |tee .btsync/bt_sync_images.log
#Stuff is synched to ~/.btsync/`echo $dir |sed 's/[\/ \\"]/_/g'`
#wami*.gpx and *.jpg files are cleared off device if synced successfully and mp4 or png
#
#REQUIREMENTS:
#linux with bluetooth hardware
#various bluetooth linux utils, these ubuntu packages:
#bluez bluez-utils(?) obexftp openobex-apps
#
# some of these come by default, and some are not needed, but this is on the system the script was tested on
#$ dpkg -l |egrep "bluez|hci|obex" |sed 's/ */ /g'
#ii bluez 4.32-0ubuntu4.1 Bluetooth tools and daemons
#ii bluez-alsa 4.32-0ubuntu4.1 Bluetooth audio support
#ii bluez-cups 4.32-0ubuntu4.1 Bluetooth printer driver for CUPS
#ii bluez-gnome 1.8-0ubuntu5 Bluetooth utilities for GNOME
#ii bluez-gstreamer 4.32-0ubuntu4.1 Bluetooth gstreamer support
#ii bluez-utils 4.32-0ubuntu4.1 Transitional package
#ii gnome-vfs-obexftp 0.4-1build1 GNOME VFS module for OBEX FTP
#ii libopenobex1 1.5-1 OBEX protocol library
#ii libopenobex1-dev 1.5-1 OBEX protocol library - development files
#ii obex-data-server 0.4.4-0ubuntu1 D-Bus service for OBEX client and server sid
#ii obexftp 0.19-7ubuntu2 file transfer utility for devices that use t
#ii openobex-apps 1.5-1 Applications for OpenOBEX
#ii python-bluez 0.16-1ubuntu1 Python wrappers around BlueZ for rapid bluet
#
#NOTES:
#The bluetooth connect seems to fail sometimes.
#Files with funny chars in name could cause a problem. maybe. () are okay
#Files to clear out are hardcoded.
#It's simple - just syncs files up if they don't exist on host.
#There are various other TODOs
#
### TODO: hey look at Images\_PAlbTN\ dir ! every thumbnail since year DOT! sneaky !
# nokia E65 phone
#
#I've thrown together an ugly script to automate sync (a dumb enough sync) of files from my phone.
#And made an ugly blog post about the ugly script also:
#http://gaoithe.livejournal.com/33541.html
#
#It would be nice to sync properly like rsync (i.e. check files size and date/times on host and device).
#It would be nice to use rsync itself! :)
#Possibly obexftp could be improved, commands like "get-if-changed, put-if-not-up-to-date", recursive ability.
#Hmm. Hmm.
#mount could mount some ugly thing + obexftp interface? then rsync away
# Hmmm.
#
# 14/11/2009 Fix allow spaces in file names.
# probably also allow spaces in dirs and device name
# for F in *.amr ; do echo F=$F; done
# for F in *.amr ; do echo F=$F; N=${F%%.amr}; if [[ ! -e $N.ogg ]] ; then ffmpeg -i $F $N.ogg; fi; done
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# for F in *.amr ; do echo F=$F; N=${F%%.amr}; if [[ ! -e $N.ogg ]] ; then ffmpeg-amr -i "$F" "$N.ogg"; fi; done
#
# f=Sound\ clip\(10\).ogg; n=${f%%.amr}; mv "$f" "${n}_DragonSoup.ogg"
# for f in DataSoundsDigital/Sound\ clip\({1,2}*\).ogg; do vlc "$f"; done
# for f in DataSoundsDigital/Sound\ clip\({1*,20,21,22,23}\).ogg; do n=${f%%.ogg}; mv "$f" "${n}_DragonSoup.ogg"; done
#
# for f in DataSoundsDigital/Sound\ clip\(*\).ogg; do vlc "$f"; done
# for f in *.flv; do n=${f%%.flv}; if [[ ! -e "$n.wav" ]] ; then ffmpeg -i "$f" "$n.wav"; fi; done
DEVICENAME="$1"
#echo all is $*
BTSYNCHOME=~/.btsync
# DEVICENAME can be blank (scans all devices)
HCISCAN=`hcitool scan |grep "$DEVICENAME" |grep -v ^Scanning `
#Scanning ...
# 00:1F:5D:BF:29:39 Nokia 3120 fionnuala
# 00:17:E5:EE:29:18 Pooky
#check for duplicates
DEVCOUNT=`echo "$HCISCAN" |wc -l`
HCISCAN_S=`echo "$HCISCAN" |sed 's/[\t ][\t ]*/ /g;s/^ *//;'`
BTADDR=`echo "$HCISCAN_S" |cut -d' ' -f1`
DEVNAME=`echo "$HCISCAN_S" |cut -d' ' -f2-`
#echo "DEVCOUNT=$DEVCOUNT HCISCAN=$HCISCAN
#BTADDR=$BTADDR DEVNAME=$DEVNAME"
if [[ $DEVCOUNT -ne 1 ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
Which device?
$HCISCAN
"
exit;
fi
echo "BTADDR=$BTADDR DEVNAME=$DEVNAME"
#sudo hcitool info $BTADDR
DIRTOSYNC="$2"
# TODO pass in dir/file to sync on cmd line in $2
if [[ -z $DIRTOSYNC ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
e.g. $0 \$BTADDR \"C:/Data/Images/\"
e.g. $0 $BTADDR \"C:/Data/Videos/\"
e.g. $0 42:54:41:44:44:52 \"C:/Data/Sounds/\"
"
DIRTOSYNC="C:/Data/"
#exit;
fi
mkdir -p $BTSYNCHOME
DIRTOSYNC_HASH=`echo "$DIRTOSYNC" |sed 's/[\/ \\"]/_/g'`
# cd to where we are getting files
mkdir -p $BTSYNCHOME/$DIRTOSYNC_HASH
cd /tmp
cd $BTSYNCHOME/$DIRTOSYNC_HASH
pwd
#obexftp -b $BTADDR -v -l ""
#obexftp -b $BTADDR -v -l "C:/"
echo DIRTOSYNC=$DIRTOSYNC DIRTOSYNC_HASH=$DIRTOSYNC_HASH
obexftp -b $BTADDR -v -l "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.list
echo get list of all files
echo TODO: parse xml safely/properly
#
#
#FILES=$(grep "
FILES=$(grep "
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.log
echo FILES=$FILES |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.log
## forget about first retrieve or not, just check files on each system
#if [[ -f $BTSYNCHOME/$DIRTOSYNC_HASH.success ]] ; then
#echo for second/.. retrieve just get differences
echo TODO: recurse into directories
echo TODO get updated files, now we get new files only
function wipe_existing_files_from_list () {
echo for now we check if file exists already and wipe from list
##file list to retrieve by eliminating ones already retrieved
FILESTOGET=
for F in $FILES ; do
#F=$(echo $F|sed 's/_SPACE_/ /g')
if [[ ! -f $F ]] ; then
FILESTOGET="$FILESTOGET $F"
fi
done
FILES="$FILESTOGET"
#diff $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
#mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
}
function get_the_files () {
if [[ ! -z $FILES ]] ; then
echo get the files
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.get
SP_Q=$(echo $FILES|grep _SPACE_)
if [[ "$SP_Q" != "" ]] ; then
# spaces in file names so must do them induhvidually
for F in $FILES; do
F=$(echo $F|sed 's/_SPACE_/ /g')
echo "obexftp get $F"
echo obexftp -b $BTADDR -v -c \"$DIRTOSYNC\" -g \"$F\"
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -g "$F" |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.get
done
else
echo "obexftp get $FILES"
echo obexftp -b $BTADDR -v -c \"$DIRTOSYNC\" -g $FILES
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -g $FILES |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.get
fi
# can obexftp do a dir? would be handy.
#obexftp -b $BTADDR -v -g "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.getdir
# also -G (get and delete) could be used for some files
fi
}
# TODO/half DONE track and check each file seperately
# TODO maybe if we got the file, store the associated line then in .success file
# use size/date in xml and on file system.
# ideally we want commands: GET[and remove] if newer/different
function track_the_files () {
#CHECKFILES=`echo $FILES |sed 's/ / && -f /g'`
#if [[ $CHECKFILES ]] ; then
# mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
date >> $BTSYNCHOME/$DIRTOSYNC_HASH.success
for F in $FILES ; do
F=$(echo $F|sed 's/_SPACE_/ /g')
if [[ -f $F ]] ; then
# a file name which is part of others will cause problems
FILEINFO=`grep "
fi
done
}
## TODO cleanup all files on mobile retrieved this time or previous
## allows syncing as soon as possible but cleaning after longer (keep recent photos, traces, ...)
# cleanup files matching certain patterns on mobile if they were successfully retrieved
# we could use -G earlier (get and delete)
function clean_the_files () {
for F in $FILES ; do
F=$(echo $F|sed 's/_SPACE_/ /g')
###if [[ -f bin/eirkey.pl && ( -n ${FG#wami-2} || -n ${F%gpx} ) ]] ; then echo yep; fi
if [[ -f $F && ( -n ${F#wami-2*.gpx} || -n ${F#*.jpg} || -n ${F#*.mp4} || -n ${F#*.png} ) ]] ; then
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -k $F |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.clean
fi
done
}
wipe_existing_files_from_list
echo "files to get FILES=$FILES"
get_the_files
track_the_files
clean_the_files
Wednesday, 2 September 2009
automatic sync mobile photos, map traces
Let's all sing the "let's automate" song!
Incidentally started new job with Intune http://www.intunenetworks.com Monday.
Finished with Sun http://www.sun.com Friday!
Kids all started back to school Tue.
script created just now: bt-sync-mobile.sh
TODO: cron job to daily sync phone
Incidentally started new job with Intune http://www.intunenetworks.com Monday.
Finished with Sun http://www.sun.com Friday!
Kids all started back to school Tue.
script created just now: bt-sync-mobile.sh
TODO: cron job to daily sync phone
#!/bin/bash
#INVOCATION:
#$ bt-sync-mobile.sh [device [dir]]
#$ bt-sync-mobile.sh Pooky 'C:\Data\Images\' 2>&1 |tee .btsync/bt_sync_images.log
#Stuff is synched to ~/.btsync/`echo $dir |sed 's/[\/ \\"]/_/g'`
#wami*.gpx and *.jpg files are cleared off device if synced successfully
#
#REQUIREMENTS:
#linux with bluetooth hardware
#various bluetooth linux utils, these ubuntu packages:
#bluez bluez-utils(?) obexftp openobex-apps
#
# some of these come by default, and some are not needed, but this is on the system the script was tested on
#$ dpkg -l |egrep "bluez|hci|obex" |sed 's/ */ /g'
#ii bluez 4.32-0ubuntu4.1 Bluetooth tools and daemons
#ii bluez-alsa 4.32-0ubuntu4.1 Bluetooth audio support
#ii bluez-cups 4.32-0ubuntu4.1 Bluetooth printer driver for CUPS
#ii bluez-gnome 1.8-0ubuntu5 Bluetooth utilities for GNOME
#ii bluez-gstreamer 4.32-0ubuntu4.1 Bluetooth gstreamer support
#ii bluez-utils 4.32-0ubuntu4.1 Transitional package
#ii gnome-vfs-obexftp 0.4-1build1 GNOME VFS module for OBEX FTP
#ii libopenobex1 1.5-1 OBEX protocol library
#ii libopenobex1-dev 1.5-1 OBEX protocol library - development files
#ii obex-data-server 0.4.4-0ubuntu1 D-Bus service for OBEX client and server sid
#ii obexftp 0.19-7ubuntu2 file transfer utility for devices that use t
#ii openobex-apps 1.5-1 Applications for OpenOBEX
#ii python-bluez 0.16-1ubuntu1 Python wrappers around BlueZ for rapid bluet
#
#NOTES:
#The bluetooth connect seems to fail sometimes.
#Files with funny chars in name could cause a problem. maybe. () are okay
#Files to clear out are hardcoded.
#It's simple - just syncs files up if they don't exist on host.
#There are various other TODOs
DEVICENAME=$1
#echo all is $*
BTSYNCHOME=~/.btsync
# DEVICENAME can be blank (scans all devices)
HCISCAN=`hcitool scan |grep "$DEVICENAME" |grep -v ^Scanning `
#Scanning ...
# 00:1F:5D:BF:29:39 Nokia 3120 mmfa
# 00:17:E5:EE:29:18 Pooky
#check for duplicates
DEVCOUNT=`echo "$HCISCAN" |wc -l`
HCISCAN_S=`echo "$HCISCAN" |sed 's/[\t ][\t ]*/ /g;s/^ *//;'`
BTADDR=`echo "$HCISCAN_S" |cut -d' ' -f1`
DEVNAME=`echo "$HCISCAN_S" |cut -d' ' -f2-`
#echo "DEVCOUNT=$DEVCOUNT HCISCAN=$HCISCAN
#BTADDR=$BTADDR DEVNAME=$DEVNAME"
if [[ $DEVCOUNT -ne 1 ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
Which device?
$HCISCAN
"
exit;
fi
echo "BTADDR=$BTADDR DEVNAME=$DEVNAME"
#sudo hcitool info $BTADDR
DIRTOSYNC=$2
# TODO pass in dir/file to sync on cmd line in $2
if [[ -z $DIRTOSYNC ]] ; then
echo "usage: $0
e.g. $0 42:54:41:44:44:52 \"C:/Data/\"
e.g. $0 \$BTADDR \"C:/Data/Images/\"
e.g. $0 $BTADDR \"C:/Data/Videos/\"
e.g. $0 42:54:41:44:44:52 \"C:/Data/Sounds/\"
"
DIRTOSYNC="C:/Data/"
#exit;
fi
mkdir -p $BTSYNCHOME
DIRTOSYNC_HASH=`echo "$DIRTOSYNC" |sed 's/[\/ \\"]/_/g'`
#obexftp -b $BTADDR -v -l ""
#obexftp -b $BTADDR -v -l "C:/"
echo DIRTOSYNC=$DIRTOSYNC DIRTOSYNC_HASH=$DIRTOSYNC_HASH
obexftp -b $BTADDR -v -l "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.list
# cd to where we are getting files
mkdir -p $BTSYNCHOME/$DIRTOSYNC_HASH
cd /tmp
cd $BTSYNCHOME/$DIRTOSYNC_HASH
pwd
echo get list of all files
echo TODO: parse xml safely/properly
#
#
FILES=`grep "echo FILES=$FILES
## forget about first retrieve or not, just check files on each system
#if [[ -f $BTSYNCHOME/$DIRTOSYNC_HASH.success ]] ; then
#echo for second/.. retrieve just get differences
echo TODO: recurse into directories
echo TODO get updated files, now we get new files only
function wipe_existing_files_from_list () {
echo for now we check if file exists already and wipe from list
##file list to retrieve by eliminating ones already retrieved
FILESTOGET=
for F in $FILES ; do
if [[ ! -f $F ]] ; then
FILESTOGET="$FILESTOGET $F"
fi
done
FILES="$FILESTOGET"
#diff $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
#mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
}
function get_the_files () {
if [[ ! -z $FILES ]] ; then
echo get the files
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -g $FILES |tee $BTSYNCHOME/$DIRTOSYNC_HASH.get
# can obexftp do a dir? would be handy.
#obexftp -b $BTADDR -v -g "$DIRTOSYNC" |tee $BTSYNCHOME/$DIRTOSYNC_HASH.getdir
# also -G (get and delete) could be used for some files
fi
}
# TODO/half DONE track and check each file seperately
# TODO maybe if we got the file, store the associated line then in .success file
# use size/date in xml and on file system.
# ideally we want commands: GET[and remove] if newer/different
function track_the_files () {
#CHECKFILES=`echo $FILES |sed 's/ / && -f /g'`
#if [[ $CHECKFILES ]] ; then
# mv $BTSYNCHOME/$DIRTOSYNC_HASH $BTSYNCHOME/$DIRTOSYNC_HASH.success
for F in $FILES ; do
if [[ -f $F ]] ; then
# a file name which is part of others will cause problems
FILEINFO=`grep "> $BTSYNCHOME/$DIRTOSYNC_HASH.success
fi
done
}
## TODO cleanup all files on mobile retrieved this time or previous
## allows syncing as soon as possible but cleaning after longer (keep recent photos, traces, ...)
# cleanup files matching certain patterns on mobile if they were successfully retrieved
# we could use -G earlier (get and delete)
function clean_the_files () {
for F in $FILES ; do
###if [[ -f bin/eirkey.pl && ( -n ${FG#wami} || -n ${F%gpx} ) ]] ; then echo yep; fi
if [[ -f $F && ( -n ${F#wami*.gpx} || -n ${F#*.jpg} ) ]] ; then
obexftp -b $BTADDR -v -c "$DIRTOSYNC" -k $F |tee -a $BTSYNCHOME/$DIRTOSYNC_HASH.clean
fi
done
}
wipe_existing_files_from_list
echo files to get FILES=$FILES
get_the_files
track_the_files
clean_the_files
Sunday, 24 May 2009
palm sync jpilot - on ubuntu gutsy - needed udev and /etc/modules tweaks
Oh no! Palm worked seamlessly with linuxes for a while.
(and other usb sync just by setting device "usb:" as the thing to sync.)
Now ...
The bad old messy config days are back (hopefully momentarily - I'm briefly stuck on gutsy for a bit on home pc).
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"
$ uname -a
Linux xx 2.6.20-16-generic #2 SMP Tue Feb 12 05:41:34 UTC 2008 i686 GNU/Linux
To get palm sync working (with jpilot):
1. add visor to list in /etc/modules
sudo vi /etc/modules
sudo modprobe visor # to load module just for now without restarting
2. Make (or add to 10-custom.rules the below KERNEL=="ttyUSB*" entry (and rm entry from 60-symlinks.rules
BUS=="usb", SYSFS{product}=="*[vVisor]*", KERNEL=="ttyUSB[13579]", NAME="pilot",\
GROUP="dislout", MODE="0660"
2.1
sudo /etc/init.d/udev restart
3. some tests
pilot-xfer -p /dev/ttyUSB0 -l # doesn't work? works?
sudo pilot-xfer -p /dev/ttyUSB0 -l
udevinfo --query=all --name=/dev/ttyUSB0
4.And argh I ran sudo jpilot and did a sync (as root) The group setting was wrong so jpilot as normal user couldn't sync.
# fix ownerships (be careful with find ... -exec chown or chown -R in general, ...
# did I ever tell you about the time I killed a server with a recursive chown?
find /home/jamesc/.jpilot/ -user root -exec chown jamesc:jamesc {} \;
5. add group dialout for your user
sudo usermod -a -G dialout `whoami`
5.1 login again then check new group is enabled for your user
groups
6. FINALLY
jpilot
#hotsync button on palm first, then hotsync button in application
http://ubuntuforums.org/archive/index.php/t-418979.html j-pilot problems in Feisty
http://barnson.org/node/1556 Hotsync Palm Centro on Ubuntu Gutsy
http://www.linuxquestions.org/questions/linux-hardware-18/has-anyone-synced-a-palm-tx-with-linux-397038/?highlight=pda+sync
(and other usb sync just by setting device "usb:" as the thing to sync.)
Now ...
The bad old messy config days are back (hopefully momentarily - I'm briefly stuck on gutsy for a bit on home pc).
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"
$ uname -a
Linux xx 2.6.20-16-generic #2 SMP Tue Feb 12 05:41:34 UTC 2008 i686 GNU/Linux
To get palm sync working (with jpilot):
1. add visor to list in /etc/modules
sudo vi /etc/modules
sudo modprobe visor # to load module just for now without restarting
2. Make (or add to 10-custom.rules the below KERNEL=="ttyUSB*" entry (and rm entry from 60-symlinks.rules
BUS=="usb", SYSFS{product}=="*[vVisor]*", KERNEL=="ttyUSB[13579]", NAME="pilot",\
GROUP="dislout", MODE="0660"
2.1
sudo /etc/init.d/udev restart
3. some tests
pilot-xfer -p /dev/ttyUSB0 -l # doesn't work? works?
sudo pilot-xfer -p /dev/ttyUSB0 -l
udevinfo --query=all --name=/dev/ttyUSB0
4.And argh I ran sudo jpilot and did a sync (as root) The group setting was wrong so jpilot as normal user couldn't sync.
# fix ownerships (be careful with find ... -exec chown or chown -R in general, ...
# did I ever tell you about the time I killed a server with a recursive chown?
find /home/jamesc/.jpilot/ -user root -exec chown jamesc:jamesc {} \;
5. add group dialout for your user
sudo usermod -a -G dialout `whoami`
5.1 login again then check new group is enabled for your user
groups
6. FINALLY
jpilot
#hotsync button on palm first, then hotsync button in application
http://ubuntuforums.org/archive/index.php/t-418979.html j-pilot problems in Feisty
http://barnson.org/node/1556 Hotsync Palm Centro on Ubuntu Gutsy
http://www.linuxquestions.org/questions/linux-hardware-18/has-anyone-synced-a-palm-tx-with-linux-397038/?highlight=pda+sync
Subscribe to:
Posts (Atom)
