Last change
on this file since 7ef9682 was bc5d5b2, checked in by njw <njw@…>, 16 years ago |
Initial Import
|
-
Property mode
set to
100755
|
File size:
1.5 KB
|
Rev | Line | |
---|
[bc5d5b2] | 1 | #!/usr/local/bin/ruby -w
|
---|
| 2 | #
|
---|
| 3 | #######################################################################
|
---|
| 4 | # A little script that copies imagefiles from your
|
---|
| 5 | # Sony Ericsson K700i mobilephone to <destination>
|
---|
| 6 | #######################################################################
|
---|
| 7 | #
|
---|
| 8 | #
|
---|
| 9 |
|
---|
| 10 | def usage
|
---|
| 11 | puts "usage: m2a.rb <destination>"
|
---|
| 12 | exit(-1)
|
---|
| 13 | end
|
---|
| 14 |
|
---|
| 15 | usage if ARGV.length != 1
|
---|
| 16 | $destination = ARGV[0]
|
---|
| 17 |
|
---|
| 18 | # SE K700i organizes the camera pictures in Bilder/camera_semc
|
---|
| 19 | BD_ADDR = "trebroN"
|
---|
| 20 | OBEX_DIR1 = "Bilder"
|
---|
| 21 | OBEX_DIR2 = "camera_semc"
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | def doCrudeObexAppComm
|
---|
| 25 | begin
|
---|
| 26 | cam = getObexIOObject
|
---|
| 27 | cam.puts "ls"
|
---|
| 28 | cam.close_write
|
---|
| 29 | lines = cam.readlines
|
---|
| 30 | cam = getObexIOObject
|
---|
| 31 | lines.each do |line|
|
---|
| 32 | line =~ /Bild\(\d+\).jpg/
|
---|
| 33 | #black-magic-ruby $& holds the match
|
---|
| 34 | if !$&.nil?
|
---|
| 35 | cam.puts "get"
|
---|
| 36 | cam.puts $&
|
---|
| 37 | cam.puts $destination+'/'+$&
|
---|
| 38 | puts "copy picture "+$&+" to to "+$destination
|
---|
| 39 | #delete picturea after copying? uncomment...
|
---|
| 40 | #doesn't work on my phone:(
|
---|
| 41 | #cam.puts "delete"
|
---|
| 42 | #cam.puts $&
|
---|
| 43 | end
|
---|
| 44 | end
|
---|
| 45 | rescue Exception => ex
|
---|
| 46 | puts(ex.to_s)
|
---|
| 47 | ensure
|
---|
| 48 | # TODO: ensure connection is closed
|
---|
| 49 | cam.puts "disconnect"
|
---|
| 50 | cam.close
|
---|
| 51 | end
|
---|
| 52 | end
|
---|
| 53 |
|
---|
| 54 | def getObexIOObject
|
---|
| 55 | cam = IO.popen("obexapp -a #{BD_ADDR} -C OPUSH", "w+")
|
---|
| 56 | cam.puts "cd #{OBEX_DIR1}"
|
---|
| 57 | cam.puts "cd #{OBEX_DIR2}"
|
---|
| 58 | return cam
|
---|
| 59 | end
|
---|
| 60 |
|
---|
| 61 | # start here
|
---|
| 62 | doCrudeObexAppComm
|
---|
Note:
See
TracBrowser
for help on using the repository browser.