iPhone and Linux

Saturday, November 7, 2009

Send copied text from iPhone to Linux desktop final

I tweaked the script enough to finish out the subject. I think it's pretty foolproof. Set up the script from my last post on the phone and use this script on the computer.

Note, I switched from xsel to xclip to put the contents into the computer's clipboard. xsel had problems taking standard input but xclip does so reliably.

#! /bin/sh
cd /path/to/plist/directory
file=com.hitoriblog.pasteboardstacker.plist
link=$(awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"")}1{print $RS;exit}') $file

# send the text to the clipboard
echo $link | xclip

# If the text is a link, this will create
# an html file which you've pre-bookmarked in Firefox
if
echo "$link" | head -1 | grep http > /dev/null
then
cd /path/to/html/file/dir
echo -n '<html>
<head>
<title>Reverse Prowling</title>
<meta http-equiv="REFRESH" content="0;url=' > iLink.html
echo "$link" >> iLink.html
echo '></HEAD>
<BODY>
Redirecting to $link...
</BODY>
</HTML>' >> iLink.html

else
# if the text is not a link, this will
# display the text in the html file
# which you bookmarked in Firefox.
# It will appear as plain text when Firefox opens it
echo "$link" | sed 'N;s/\n/<br>/g;P;D;' | tr -d  > iLink.html
fi

Blog Archive