#!/usr/bin/perl # #This script is intended to use obex to transfer files to and from my #cell phone, a Samsung MyShot (yes, I know it has a more accurate model #number, but I'm writing this thing after having given up on sleep for the night) use strict; use warnings; use Tk; use vars qw($file $mw $phoneAddr); #Set the bluetooth address of the phone $phoneAddr="Phone BT Address"; $mw=new MainWindow(-title=>"FoneFiles"); $file=$mw->Entry(); my $fileButton=$mw->Button(-text=>"Get File to Push",-command=>\&getFile); my $getPutFrame=$mw->Frame(); my $getButton=$getPutFrame->Button(-text=>"Get",-command=>\&getGo); my $putButton=$getPutFrame->Button(-text=>"Put",-command=>\&putGo); #Main window geometry $file->pack(); $fileButton->pack(); $getPutFrame->pack(); $getButton->pack(-side=>"left"); $putButton->pack(-side=>"left"); #sub to pick file to push to phone. I didn't write one to pick a file to get #from the phone because it would work with my phone even if I did. sub getFile { my $filename=$mw->getOpenFile(); $file->configure(-text=>$filename); } #sub to get file from phone sub getGo { my $varFile=$file->get(); $varFile=~s/\ /\\ /; my $notice=$mw->Toplevel(-title=>"Getting"); my $lab=$notice->Label(-text=>"Getting file from your phone. Please wait")->pack; $mw->update; $notice->update; #obexftp is a command line obex utility. #This line will use the obex push protocol to get a file from the phone `obexftp -b $phoneAddr --nopath --get $varFile`; destroy $notice; } #sub to send a file to the phone sub putGo { my $varFile=$file->get(); $varFile=~s/\ /\\ /; my $notice=$mw->Toplevel(-title=>"pushing"); my $lab=$notice->Label(-text=>"Pushing file to your phone. Please wait")->pack; $mw->update; $notice->update; #This command uses obex push to push a file to the phone `obexftp -b $phoneAddr --nopath --put $varFile`; destroy $notice; } MainLoop;