tag:blogger.com,1999:blog-36568675367665376042024-03-08T01:33:22.607-05:00A Common HadesiPhone and LinuxJMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comBlogger48125tag:blogger.com,1999:blog-3656867536766537604.post-88962402763002361322010-09-06T11:02:00.007-04:002010-09-06T22:32:30.010-04:00Over 100 million language files deleted?Over at xsellize.com, the user lll2for3lll, who posted the language file script there and zipped it for download, <a href="http://xsellize.com/topic/50783-langpack-remove-unused-languages-from-ipodiphone/page__st__400__p__472072#entry4720726,255">reported</a> that the <a href="http://a-common-hades.blogspot.com/2010/02/final-script-for-deleting-iphone.html">long version</a> has been downloaded 2,834 times and the <a href="http://a-common-hades.blogspot.com/2010/01/simpler-language-pack-deletion-script.html">short version</a> 3,421 times, for a total of 6,255 downloads from the xsellize forum alone. I think that only counts the latest version that was uploaded there in March.<br /><br />I've also had 15,000 hits to that one page on this blog. Then there are people who have gotten it from other forums, the two or three places where it's been translated into other languages and the people who tell me they've ran it on 30 phones.<br /><br />So I'll add a conservative 5,000 people who have downloaded and used the script through means other than xsellize.<br /><br />Users usually report that the script deletes 4,000 to 5,000 language <span style="font-weight:bold;">directories</span>, but I'll use a more conservative figure of 3,500 because I never had a lot of apps installed and that's what it deleted on mine. <br /><br />So from those stats, I'm going to go out on a limb and say that I'm responsible for deleting over 40 million directories from iPhones all over the world. <br /><br />If I remember correctly, there are usually anywhere from two to five or more files in those directories. If we assume a conservative 2.5 files per directory, that's 100 million files.<br /><br />I'm like a virus.<br /><br />In reality, I just wrote a script that a few thousand people used, which isn't a big deal, but it's kind of humbling to think I did 100 million of anything. If I had a dollar for every file deleted...JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-58307661327905493642010-04-11T22:57:00.001-04:002010-04-11T22:59:24.862-04:00N1 BlogFor anyone who may be interested, I've finally started a blog for the Nexus One called <a href="http://a-more-common-hades.blogspot.com/">A More Common Hades</a>.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-35501708026027310042010-03-19T19:43:00.003-04:002010-03-19T19:56:20.080-04:00Nexus OneI did it. I bought a Nexus One. I've only had a few minutes to play with it so far and my initial impression of the interface is that it makes the iPhone feel clunky and boring. I don't know if it will be an iPhone killer, but there's a lot to like about this phone.<br /><br />I plan to continue this blog because I enjoy hacking around on the iPhone. I'll probably start a different blog for the N1.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img249.imageshack.us/img249/7670/quickshottrtz.png"><img style="cursor:pointer; cursor:hand;width: 320px; height: 480px;" src="http://img249.imageshack.us/img249/7670/quickshottrtz.png" border="0" alt="" /></a><br />Taken with my iPhone. I'm going to go out on a limb and say the N1's 5MP camera with flash could probably have done better than my old 3G.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-91454925309551159602010-03-18T23:32:00.002-04:002010-03-19T00:06:24.089-04:00Script for looking up language codesShhh, don't tell anyone but I've made a secret post. It's a simple script to look up language codes, but it's 1100 lines long. The script is one simple grep command, the other 1100 lines are just languages and codes. <br /><br />I made the post date Jan 1 2009 so it would go straight to the archive and not take up the front page. It can be found <a href="http://a-common-hades.blogspot.com/2009/01/language-code-lookup-script.html">here</a>.<br /><br />It may be useful to anyone running my iPhone language deleting script who runs across an unknown language code.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-70454044038755423512010-03-03T23:17:00.003-05:002010-03-03T23:42:51.042-05:00whereisAnother simple script to replace the missing whereis command on the iPhone.<br /><pre>#! /bin/sh<br />if<br />ls /usr/bin/$1 2>/dev/null<br />then echo >/dev/null<br />elif<br />ls /usr/local/bin/$1 2>/dev/null<br />then echo >/dev/null<br />elif<br />ls /usr/sbin/$1 2>/dev/null<br />then echo >/dev/null<br />elif<br />ls /sbin/$1 2>/dev/null<br />then echo >/dev/null<br />elif<br />ls /bin/$1 2>/dev/null<br />then echo >/dev/null<br />else <br />echo "$1 not found in /bin /sbin /usr/bin /usr/sbin /usr/local/bin"<br />fi<br /></pre>Too bad an if statement needs a then statement to go with it. Since <span style="font-style:italic;">ls</span> has it's own output, there's no reason to duplicate it so it's easier to use the <span style="font-style:italic;">ls</span> output and do an empty <span style="font-style:italic;">then</span> command. The result works, but it just looks dumb. Here's a shorter version. It will list all the files. If any are not found, the error goes to /dev/null.<pre>#! /bin/sh<br />ls /usr/bin/$1 /usr/local/bin/$1 /usr/sbin/$1 /sbin/$1 /bin/$1 2>/dev/null</pre>But that won't give you a "not found" message. So let's take that and put it in a variable. If the variable is not empty, it will echo the variable, which is the non-error output from the <span style="font-style:italic;">ls</span> command. If it ends up empty, the -n test will fail so the && command is skipped and the || command executes.<pre>#! /bin/sh<br />test=$(ls /usr/bin/$1 /usr/local/bin/$1 /usr/sbin/$1 /sbin/$1 /bin/$1 2>/dev/null)<br />[ -n "$test" ] && echo $test || echo "$1 not found in /bin /sbin /usr/bin /usr/sbin /usr/local/bin"</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-85763381156115287282010-02-28T00:46:00.003-05:002010-02-28T01:29:51.424-05:00Whatis it, man?The "man" command is used to read UNIX manual pages and "whatis" gives you a brief description of a command taken from the NAME field of the man page. The iPhone lacks both commands, but these work ok.<br /><br />man:<pre>#! /bin/sh<br />links -dump http://unixhelp.ed.ac.uk/CGI/man-cgi?${1} | grep -A 1000 NAME | sed 's/^[ \t]*//'</pre>I actually like that because it's easier to grep the output, but adding a pipe to "less" more accurately approximates the real command. You could probably roll the grep into the sed command, but that's one of those things where I don't mind spending an extra one-thousandth of a second execution time to keep from having to craft a better sed one-liner.<br /><br />whatis: <pre>#! /bin/sh<br />links -dump http://unixhelp.ed.ac.uk/CGI/man-cgi?${1} | grep "\- " | head -1 | sed 's/^[ \t]*//'</pre>Let's test it.<pre># whatis ifconfig<br />ifconfig [] (8) - configure a network interface<br /># ./my_whatis ifconfig<br />ifconfig - configure a network interface<br />#</pre>Close enough.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-20383096491125819232010-02-24T23:18:00.004-05:002010-02-24T23:23:17.066-05:00How prettyI've never fooled around with colors in the shell before.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_huGo2gduRDI/S4X6gKWi9hI/AAAAAAAAAJA/5_rq6JMXzKI/s1600-h/colors.png"><img style="cursor:pointer; cursor:hand;width: 331px; height: 400px;" src="http://2.bp.blogspot.com/_huGo2gduRDI/S4X6gKWi9hI/AAAAAAAAAJA/5_rq6JMXzKI/s400/colors.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5442031155188790802" /></a><br /><br /><pre>#! /bin/sh<br />echo "Colors:"<br />tput setaf 0; echo "Black = tput setaf 0 $(tput sgr0) <--- that was black (tput setaf 0)"<br />tput bold ; tput setaf 0; echo "DarkGrey = tput bold ; tput setaf 0" ; tput sgr0<br />tput setaf 7; echo "LightGrey = tput setaf 7" ; tput sgr0<br />tput bold ; tput setaf 7 ; echo "White = tput bold ; tput setaf 7" ; tput sgr0<br />tput setaf 1 ; echo "Red = tput setaf 1" ; tput sgr0<br />tput bold ; tput setaf 1 ; echo "LightRed = tput bold ; tput setaf 1" ; tput sgr0<br />tput setaf 2 ; echo "Green = tput setaf 2" ; tput sgr0<br />tput bold ; tput setaf 2 ; echo "LightGreen = tput bold ; tput setaf 2" ; tput sgr0<br />tput setaf 3 ; echo "Brown = tput setaf 3" ; tput sgr0<br />tput bold ; tput setaf 3 ; echo "Yellow = tput bold ; tput setaf 3" ; tput sgr0<br />tput setaf 4 ; echo "Blue = tput setaf 4" ; tput sgr0<br />tput bold ; tput setaf 4 ; echo "LightBlue = tput bold ; tput setaf 4" ; tput sgr0<br />tput setaf 5 ; echo "Purple = tput setaf 5" ; tput sgr0<br />tput bold ; tput setaf 5 ; echo "Pink = tput bold ; tput setaf 5" ; tput sgr0<br />tput setaf 6 ; echo "Cyan = tput setaf 6" ; tput sgr0<br />tput bold ; tput setaf 6 ; echo "LightCyan = tput bold ; tput setaf 6" ; tput sgr0<br />tput sgr0 ; echo "Normal = tput sgr0" ; tput sgr0<br />echo<br />echo "Backgrounds:"<br />tput setab 0 ; echo -n "BlackBG = tput setab 0" ; tput setab 0 ; echo<br />tput setab 7 ; tput setaf 0; echo -n "LightGreyBG = tput setab 7" ; tput sgr0 ; tput setab 0 ; echo # used black text<br />tput setab 1 ; echo -n "RedBG = tput setab 1" ; tput setab 0 ; echo<br />tput setaf 0 # switch to black text for these<br />tput setab 2 ; echo -n "GreenBG = tput setab 2" ; tput setab 0 ; echo<br />tput setab 3 ; echo -n "BrownBG = tput setab 3" ; tput setab 0 ; echo<br />tput setab 4 ; echo -n "BlueBG = tput setab 4" ; tput setab 0 ; echo<br />tput setab 5 ; echo -n "PurpleBG = tput setab 5" ; tput setab 0 ; echo<br />tput setab 6 ; echo -n "CyanBG = tput setab 6" ; tput setab 0 ; echo<br />tput sgr0 # back to normal text</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-43042354212024836052010-02-22T00:10:00.023-05:002010-12-29T23:26:25.235-05:00Final script for deleting iPhone language packsThis will probably be the final script for deleting language packs on the iPhone. As I have said before, it is a <span style="font-style: italic;">pain</span> to keep up with the ever-changing languages. This started out as a script I threw together in an hour or two just because I was curious if I could write a self-referential script that listed the languages and allowed people to pick the ones to remove, but has become something popular that needs maintaining, and the developers who create the language packs don't seem to have any guidelines for naming them. As the languages changed, the older script got longer and asked the user more and more questions. This one changes that and makes it easier for me to maintain.<br /><br />Although many things look the same, this version has many changes. There are some performance improvements, although they may not be evident since it's an interactive script. It will also end itself if it doesn't find anything to delete and, overall, it just "flows" better.<br /><br />The most noticeable improvement is the interaction with the user. It will only ask about the languages which it finds on the system and it will only ask once for each language. So if it finds 6 differently named Spanish directories and 2 Germans, it will only ask if you want to delete Spanish and German. The user no longer has to answer yes or no for every single code for every single language.<br /><br />It has 35 languages built in because that's what Apple says the iPhone supports, but most people won't have that many installed. I've included every language code I've found over the past couple of months for those 35 languages as well as every possibility a total of 270. It will also present unrecognized languages to the user if that language is not found in those 270.<br /><br />I will no longer maintain my <a href="http://a-common-hades.blogspot.com/2009/12/script-for-deleting-iphone-language.html">original script</a> as this one does everything that one did and does it in a way that is less hassle for the user.<br /><br />After this is out for a week or two and I make sure there aren't any bugs in the script, I'm considering my foray into iPhone languages finished. I will update this script with new languages and it would help greatly if people send me their log files (the info is in the script) but I simply don't have the time to do anything more.<br /><br />My <a href="http://a-common-hades.blogspot.com/2010/01/simpler-language-pack-deletion-script.html">stripped down</a> version for deleting everything except English will never be obsolete (unless Apple changes how languages are used) and, if that's the only language you want, would be simpler to use and will remove every language except English whether it is recognized or not.<br /><br /><span style="font-weight: bold;">Requirements.</span><br />Jailbroken iPhone/iTouch OS 3.x. <span style="font-weight: bold;">Or 4.x. Several users have recently used this successfully on OS 4.0.</span><br /><br />This script uses basic BASH shell builtins and unix core utilities. Both are installed by default when you install MobileTerminal on the iPhone. It's possible that you can install them separately, I don't know, but I suggest installing MobileTerminal and also recommend using MobileTerminal to execute the script and iFile to get the script on the phone.<br /><br />I would love to use more powerful tools like sed or awk and cut this script down to a fraction of the length, but I'd rather have it use minimal dependencies.<br /><br /><span style="font-weight: bold;">How to use.</span><br />View this page on your iPhone.<br /><br />Copy everything from "<span style="font-style: italic;">#! /bin/sh</span>" to "<span style="font-style: italic;"># end of script</span>"<br /><br />If you have Safari downloading enabled on your phone, click <a href="http://www.mediafire.com/?1y2jnh2qmvz">here</a> and download it directly to your phone. (having trouble with mediafire, please redownload if you downloaded in the past few minutes)<br /><br />Or, create a new text file on the phone with iFile. You can name it anything, but I will use langpack2.sh as an example. You can do this anywhere, but for simplicity, I suggest creating it in /var/mobile (a.k.a. /private/var/mobile)<br /><br />Paste the script into the text file and save it.<br /><br />Open MobileTerminal, cd to the directory where langpack2.sh is located and type <span style="font-style: italic;">chmod 755 langpack2.sh</span> and hit enter, then type <span style="font-style: italic;">./langpack2.sh</span> to run it.<br /><br />There are other ways to do this but I'm a Linux guy and I don't have a Mac and use Windows about twice a year so I can't recommend anything else.<br /><br />Windows can screw up the formatting of the text if it isn't transferred to the phone a certain way and I'm not going to research how to do it. I've never touched a Mac, so I can't help there either. One thing we all have in common is the phone and the two iPhone apps iFile and MobileTerminal are the recommended way to run this script. Using this method, it can be downloaded and executed while you're walking down the street, no computer needed.<br /><br />Linux users should have no problem saving it on their computer, ssh'ing it to the phone and running it there. I did most of the testing in a Linux terminal with ssh, but MobileTerminal is still the one foolproof way to run it.<br /><br />Another method to get this script using nothing but the phone is to install lynx from Cydia then run this command:<pre>lynx -width=500 -dump http://tinyurl.com/356wmua | grep -B 182 "end of script$" > langpack2.2.sh</pre>That will grab the text from this page and put it in the file called langpack2.2.sh.<br /><br />You may also be interested in <a href="http://a-common-hades.blogspot.com/2009/01/language-code-lookup-script.html">this script</a> for identifying unrecognized language codes.<br /><br /><span style="font-style: italic;">(May 17) I've gotten some hits from a couple of sites which have translated the text of the script to <a href="http://www.ipod-forum.de/ipod-touch-und-iphone/jailbreak/19813-tut-iphone-ipod-schneller-machen/?s=a78a92bbad672db93324845146be57661d70b8df#post154968">German</a> and <a href="http://vabe.hu/nem-hasznalt-nyelvi-fajlok-torlese/#more-104">Hungarian</a>, which may be useful for anyone speaking those languages.</span><br /><br /><span style="font-style: italic;">(Dec 29 2010) Several users have reported that the script fails to recognize <span style="font-weight: bold;">vi.lproj</span>. This is Vietnamese and can be deleted if you don't need Vietnamese. The script looks for vi.lproj and worked fine for months, but started missing it all of a sudden. My iPhone is a gaming device for my daughter and is still on 3.1 and I have no plans to update it to the latest firmware so I will probably never fix this problem.</span><br /><br /><br /><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><img alt="Creative Commons License" style="border-width: 0pt; width: 80px; height: 15px;" src="http://i.creativecommons.org/l/by-nc-nd/3.0/us/80x15.png" /></a><br /><span dc="http://purl.org/dc/elements/1.1/" property="dc:title">Langpack2</span> by <span cc="http://creativecommons.org/ns#" property="cc:attributionName">Fubaya</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License</a>.<br />Based on a work at <a dc="http://purl.org/dc/elements/1.1/" href="http://a-common-hades.blogspot.com/2010/02/final-script-for-deleting-iphone.html" rel="dc:source">a-common-hades.blogspot.com</a>.<br /><pre>#! /bin/sh<br /># Apr 15 2010<br /># Langpack2 by Fubaya. Licensed under CC "by-nc-nd"<br /># more info: http://creativecommons.org/licenses/by-nc-nd/3.0/us/<br /><br /><br />##### root test #####<br /># won't go any farther unless you're uid=0<br />[ `id -u` != 0 ] && exec echo "Oops, you need to be root to run this script"<br /><br /><br />##### hello, get ready, search for languages #####<br />clear; echo -e "\n\n--Langpack2- by Fubaya ($(echo 'ijdqas@gqail.coq' | tr q m))--<br />--http://a-common-hades.blogspot.com--\n" | tee langpack.log<br />echo -e "Let's delete a few thousand language packs.<br />You will have several chances to back out<br />before anything is deleted but if you want<br />to stop at any time just type $(tput bold; tput setaf 3)q$(tput sgr0).\n<br />If you want to see how it runs without<br />making any changes, just answer no when it<br />asks you which languages to delete.\n<br />Searching for language packs. Please wait...\n"<br /><br /># set interrupt to "q"<br />tset -Q -i q<br /><br /># clear out old temp files, if any, create new<br />rm -f .*_fubaya; touch {.alllist,.langlist,.deletelist,.rmlist,.yeslist}_fubaya<br /><br /># update database, search for lproj, grep directories,<br /># filter out english, filter out strange "Scanner911" app languages, put rest in alllist<br />updatedb && locate lproj | grep -E lproj$ | grep -v -i -E '(English|\/en|.en.l|blue.lproj|camo.lproj|classic.lproj|desert.lproj|modern.lproj)' > .alllist_fubaya<br /><br /># make sure alllist isn't empty, get basename of files, grep again just to be sure they're directories<br /># sort and get uniq names and now we have a list of all unique languages on the phone.<br />[[ -s .alllist_fubaya ]] && cat .alllist_fubaya | xargs -n1 basename | grep -E lproj$ | sort | uniq > .langlist_fubaya<br />##### end section #####<br /><br /><br />##### core function #####<br /># process languages, ask user to delete<br />language ()<br />{<br /># $* is all arguments to the "language" lines. If any of those appear in langlist...<br />if echo $* | grep -q -i -f .langlist_fubaya<br />then<br /><br /># then start a loop to require yes or no<br />while [[ "$choice" != 'y' ]] && [[ "$choice" != 'n' ]] <br /><br /># ask "delete the first argument, yes or no?"<br />do read -p "Delete: $(tput bold; tput setaf 3)${1%.*}$(tput sgr0) - y or n? " choice; done<br /><br /># if yes<br />if [ $choice = "y" ]<br />then<br /># put that language's formal name in yeslist<br />echo ${1%.*} >> .yeslist_fubaya<br /><br /># put that language's whole line in rmlist, replacing spaces with newlines<br />echo $* | tr ' ' '\n' >> .rmlist_fubaya<br /><br /># confirm the choice<br />echo "${1%.*} will be deleted";<br /><br /># if no, echo (that language's formal name) will be kept<br />else echo "${1%.*} will be kept"; fi<br /><br /># log the language and choice<br />echo "known $1: $choice" >> langpack.log<br /><br />unset choice # clear the variable because I'm too lazy to use a new one<br />echo # spacer<br />fi<br />}<br /><br />language Albanian.lproj alb.lproj sqi.lproj sq.lproj sq-sq.lproj sq_sq.lproj sq_al.lproj sq-al.lproj<br />language Amharic.lproj amh.lproj am.lproj am-am.lproj am_am.lproj<br />language Arabic.lproj ara.lproj ar.lproj ar-ar.lproj ar_ar.lproj ar_eg.lproj ar_sa.lproj<br />language Armenian.lproj arm.lproj hye.lproj hy.lproj hy_hy.lproj hy-hy.lproj<br />language Bulgarian.lproj bul.lproj bg.lproj bg_bg.lproj bg-bg.lproj<br />language Catalan.lproj ca.lproj cat.lproj ca_ca.lproj ca-ca.lproj ca_es.lproj<br />language Chinese.lproj chi.lproj zho.lproj zh.lproj zh-zh.lproj zh_zh.lproj zh-hans.lproj zh_hans.lproj zh-hant.lproj zh_hant.lproj zh_cn.lproj zh-cn.lproj zh-hk.lproj zh_hk.lproj zh-tw.lproj zh_tw.lproj<br />language Croatian.lproj hrv.lproj hr.lproj hr-hr.lproj hr_hr.lproj<br />language Czech.lproj cze.lproj ces.lproj cs.lproj cs-cs.lproj cs_cs.lproj cs-cz.lproj cs_cz.lproj cz.lproj cz_cz.lproj cz-cz.lproj<br />language Danish.lproj dan.lproj da.lproj da-da.lproj da_da.lproj da_dk.lproj da-dk.lproj<br />language Dutch.lproj dum.lproj dut.lproj nld.lproj nl.lproj nl-nl.lproj nl_nl.lproj<br />language Estonian.lproj est.lproj et.lproj et_ee.lproj et-ee.lproj<br />language Finnish.lproj fin.lproj fi.lproj fi-fi.lproj fi_fi.lproj<br />language French.lproj fra.lproj fre.lproj fr.lproj fr-fr.lproj fr_fr.lproj fr_ca.lproj fr-ca.lproj fr_fr.lproj fr-fr.lproj<br />language German.lproj deu.lproj ger.lproj de.lproj de-de.lproj de_de.lproj<br />language Greek.lproj gre.lproj ell.lproj el.lproj el-el.lproj el_el.lproj el_gr.lproj el-gr.lproj gr_el.lproj gr-el.lproj<br />language Gujarati.lproj guj.lproj gu.lproj gu_in.lproj<br />language Hebrew.lproj heb.lproj he.lproj he-he.lproj he_he.lproj he_il.lproj he-il.lproj hi_in.lproj hi-in.lproj<br />language Hindi.lproj hin.lproj hi.lproj hi_hi.lproj hi-hi.lproj<br />language Hungarian.lproj hun.lproj hu.lproj hu-hu.lproj hu_hu.lproj<br />language Icelandic.lproj ice.lproj isl.lproj is.lproj is_is.lproj is-is.lproj<br />language Indonesian.lproj ind.lproj id.lproj id-id.lproj id_id.lproj<br />language Iranian.lproj ira.lproj fa.lproj per.lproj fa_ir.lproj fa-ir.lproj fa-fa.lproj<br />language Italian.lproj ita.lproj it.lproj it-it.lproj it_it.lproj<br />language Japanese.lproj ja.lproj ja-ja.lproj ja_ja.lproj ja_jp.lproj ja-jp.lproj jp_jp.lproj jp-jp.lproj jpn.lproj<br />language Korean.lproj kor.lproj ko.lproj ko-ko.lproj ko_ko.lproj<br />language Latvian.lproj lav.lproj lv_lv.lproj<br />language Lithuanian.lproj lit.lproj lt.lproj lt-lt.lproj lt_lt.lproj<br />language Macedonian.lproj mk.lproj mac.lproj mk_mk.lproj mk-mk.lproj<br />language Malay.lproj may.lproj ms.lproj ms-ms.lproj ms_ms.lproj ms_my.lproj<br />language Norwegian.lproj nor.lproj nob.lproj nno.lproj nn_nn.lproj nn-nn.lproj no.lproj no-no.lproj no_no.lproj nb.lproj nb_nb.lproj nb-nb.lproj no_nb.lproj no-nb.lproj nb_no.lproj nb-no.lproj nn_no.lproj nn-no.lproj nn_nb.lproj nn-nb.lproj nb_nn.lproj nb-nn.lproj<br />language Panjabi.lproj pa.lproj pan.lproj pa_pa.lproj pa-pa.lproj pa_in.lproj pa-in.lproj<br />language Polish.lproj pol.lproj pl.lproj pl-pl.lproj pl_pl.lproj<br />language Portuguese.lproj por.lproj pt.lproj pt-pt.lproj pt_pt.lproj pt-br.lproj pt_br.lproj<br />language Romanian.lproj rup.lproj rum.lproj ron.lproj ro.lproj ro-ro.lproj ro_ro.lproj<br />language Russian.lproj rus.lproj ru.lproj ru-ru.lproj ru_ru.lproj<br />language Serbian.lproj sr.lproj sr-sr.lproj sr_sr.lproj sr_rs.lproj<br />language Slovak.lproj slk.lproj slo.lproj sk.lproj sk-sk.lproj sk_sk.lproj<br />language Slovenian.lproj slv.lproj sl.lproj sl-sl.lproj sl_sl.lproj sl_si.lproj sl-si.lproj<br />language Spanish.lproj spa.lproj sp.lproj sp-sp.lproj sp_sp.lproj es.lproj es_es.lproj es-es.lproj es_mx.lproj es_us.lproj es_419.lproj<br />language Swedish.lproj swe.lproj sv.lproj sv-sv.lproj sv_sv.lproj sv-se.lproj sv_se.lproj<br />language Thai.lproj tha.lproj th.lproj th-th.lproj th_th.lproj<br />language Turkish.lproj tur.lproj tr.lproj tr-tr.lproj tr_tr.lproj<br />language Ukrainian.lproj ukr.lproj uk.lproj uk_uk.lproj uk-uk.lproj uk_ua.lproj uk-ua.lproj<br />language Vietnamese.lproj vi.lproj vn.lproj vi-vi.lproj vi_vi.lproj vn-vn.lproj vn_vn.lproj vi_vn.lproj vi-vn.lproj vn-vi.lproj vn_vi.lproj<br />##### end section #####<br /><br />##### look for unrecognized languages #####<br /># for every entry in langlist<br />for i in $(cat .langlist_fubaya)<br />do<br /># if that lproj doesn't appear in this script<br />if ! cat $0 | grep -q -i $i<br />then<br /><br /># start a loop to require yes or no<br />while [[ $choice != 'y' ]] && [[ $choice != 'n' ]]; do<br /><br /># ask "delete that unrecognized language pack, yes or no?"<br />read -p "Delete: $(tput bold; tput setaf 3)${i}$(tput sgr0) (unrecognized) - y or n? " choice<br />done<br /><br /># if yes, confirm and put it in rmlist and yeslist<br />if [ $choice = "y" ]; then echo "$i will be deleted"<br />echo $i | tee -a .rmlist_fubaya .yeslist_fubaya > /dev/null<br /><br /># if no, confirm<br />else echo "${i} will be kept"; fi<br /><br /># log language and choice<br />echo "unknown: $i $choice" >> langpack.log<br />unset choice<br />fi<br />done<br />##### end section #####<br /><br /><br />##### finalize, confirm or quit #####<br /># use rmlist to extract all directories to be deleted from alllist, put them in deletelist<br />grep -i -f .rmlist_fubaya .alllist_fubaya > .deletelist_fubaya<br /><br /># if that failed, it's because there's nothing to delete. Dump out.<br />[ "$?" -ne "0" ] && rm -f .*_fubaya && exec echo "<br />Nothing to delete. Either I didnt find<br />any to delete or you answered no to<br />everything. See ya later."<br /><br /># otherwise, display all languages that are going to be deleted<br />echo -------------------------------------<br />tput bold; tput setaf 3; tr '\n' ' ' < .yeslist_fubaya<br />echo; tput sgr0<br />echo -------------------------------------<br />unset choice<br /><br /># start a loop to require yes or no, ask to final confirmation<br />while [[ "$choice" != 'y' ]] && [[ "$choice" != 'n' ]]; do<br />echo "This is your last chance. Are you sure<br />you want to delete the languages listed?"<br />read -p "Type y or n: " choice<br />done<br />##### end section #####<br /><br />##### delete, clean up, good-bye #####<br /># if yes<br />if [ $choice = "y" ]<br />then<br /><br /># say "please wait" and loop through deletelist file, removing directories<br />echo -e "Please wait while I delete the chosen language packs...\n"<br />while read file<br />do rm -rf "$file"<br />done < .deletelist_fubaya<br /><br /># count how many directories were in deletelist<br />num=$(grep -c ^ .deletelist_fubaya)<br /><br /># remove temp files<br />rm -f .*_fubaya<br /><br /># long goodbye<br />echo -e "$num language pack directories have been<br />deleted. A log file has been created at<br />`pwd`/langpack.log.<br />My contact information is at the top of<br />the log file and if you encountered any<br />unrecognized languages, I would appreciate<br />you emailing me that file so that I may keep<br />up with the ever-changing languages.\n<br />The only other thing left is me, this<br />script located at `pwd`/`basename $0`." <br />read -p "Do you want me to delete myself - y or n? " choice<br />[ $choice = "y" ] && echo "Deleting myself...blarg.. I'm dead" && exec rm $0<br />echo "Phwew, Thank you! I'm too young to die. I'll be here at `pwd`/`basename $0` if you need me."<br />##### end section #####<br /><br />##### if DONT delete, then clean up and good-bye #####<br /># if user said no to final confirmation, remove temp file and exit<br />else<br />rm -f .*_fubaya<br />echo "Ok, I wont delete anything. If you made a mistake, just run me again."<br />fi<br />##### end section #####<br /># end of script<br /><br /></pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-22135238723738086722010-02-14T21:29:00.005-05:002010-02-14T22:31:58.965-05:00Using ssh to bypass iPhone's launch timeout on the flyI don't think this particular method is of much use, but it may be worth knowing in a pinch. <br /><br />The iPhone has a launch timeout built into the system. When an app launches, it isn't supposed to start processing data right away, it is simply supposed to load whatever it needs then make a C++ call to the system saying it finished launching. This call is aptly named <span style="font-style:italic;">applicationDidFinishLaunching</span>. If the system doesn't get that call, it assumes the app failed to launch and kills it.<br /><br />The same thing happens when you launch a shell script from a <a href="http://a-common-hades.blogspot.com/2009/10/launching-scripts-from-springboard-icon.html">SpringBoard icon</a>. This script will not work:<pre>#! /bin/sh<br />uiopen start<br />sleep 10s<br />uiopen ten<br />sleep 10s<br />uiopen twenty<br />sleep 10s<br />uiopen thirty</pre>This is meant to pop up a notification every ten seconds but after approximately 18 seconds, the system kills it because it did not receive the <span style="font-style:italic;">applicationDidFinishLaunching</span> call.<br /><br />Some jailbreak apps have a way around this. I emailed BigBoss a few months ago and asked if he knew of a way around the launch timeout with a script, and he pointed me to the method SBSettings uses. SBSettings does not actually launch itself, it instead uses a small shell script to launch the real SBSettings executable:<pre>SBSettings=$(dirname "$0")<br />exec "${SBSettings}"/SBSettings</pre>What this does is pretty simple. The script uses the first line to find itself on the system, the second line launches SBSettings, which it expects to find in the same directory. It launches with the <span style="font-style:italic;">exec</span> command, which replaces the current shell with whatever exec executes.<br /><br />Unfortunately, I had already tried this and could never get it to work with a shell script. I've also tried every other method I could think of to background a script such as using the standard "&" tacked on to the command or trying the disown command. These would probably work in MobileTerminal, but nothing seemed to work when launching a script from SpringBoard.<br /><br />You may be able to use launchd to run a longer script, but I wanted to do it on the fly. I only had one long script I wanted to use and simply gave up on it and forgot about it until an unlikely answer came to me while working on an unrelated problem. Why not see what happens when you ssh in to localhost and run the script? <br /><br />Well, you can't simply ssh in and run the command or the ssh pipe will stay open. This is a feature of OpenSSH used to avoid a <a href="http://www.snailbook.com/faq/background-jobs.auto.html">race condition</a>. To background it, you have to redirect sdtin, stdout and stderr to a file or, as I used here, to /dev/null.<pre>slogin -i ~/.ssh/KEY localhost '/Applications/test.app/test_ </dev/null >/dev/null 2>&1 &'</pre>To my surprise, that actually works. This command can be put in /Applications/test.app/test and launched from SpringBoard. It will then ssh to localhost and successfully launch and background test_, which can run as long as it wants.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-8413354751401400302010-02-11T00:40:00.003-05:002010-02-11T01:26:56.273-05:00Forum grabberI use various methods to visit forums. If I'm at my computer, I use a browser, obviously. On my iPhone, I use a forum app named Kaytri a lot, but I visit a couple of forums that have very low thread counts and I thought it would be nice to get a "daily digest" of all the new subjects to see if there is anything interesting.<br /><br />This can be done pretty easily with links or lynx and their -dump switch, but they both split the subject line and have so much additional output, that it was simpler to start from scratch.<br /><br />Starting with wget spitting out the raw html in quiet mode, I looked at the code to a couple forums and found that most use "thread_title" in their html, so it's just a matter of grepping "thread_title" and filtering out the tags with sed and (optionally) aligning the text to the left with sed also.<pre>wget -q -O - <span style="font-style:italic;">[FORUM]</span> | grep thread_title | sed -e 's#<[^>]*>##g' -e 's/^[ \t]*//'</pre>One possibility for using this is to get a daily forum update by putting the output in a file, comparing it with an older version, and sending yourself only the new content.<pre>cd /path/to/tmpfile/directory<br /><span style="font-style:italic;">[wget command]</span> > .b<br />newcontent=$(cat .b | grep -v -f .a)<br /># if there is new content, do something with it<br /># email it to yourself, send a push notification, etc<br />[ -n "$newcontent" ] && <span style="font-style:italic;">[do something with $newcontent]</span><br />mv .b .a</pre>This can be useful for both fast and slow paced forums to watch for new subjects, then you can decide whether to visit them and jump into the argument or not.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-55277750655578783152010-02-07T16:41:00.004-05:002010-02-07T17:11:45.661-05:00Minimal video encoding for iPhoneThere are countless ways of encoding video for the iPhone, but this is the command I normally use. I don't watch many videos on the phone and my goal is usually to create a video with a small size that doesn't strain the system too much to run. A lower bitrate, 20.98 framerate and 320x240 resolution (which is used on the iPod) would be terrible for watching a hi-def movie, but works great for most videos.<br /><br /><pre>ffmpeg -i infile -f mp4 -vcodec mpeg4 -b 200k -aspect 4:3 -r 20.98 -s 320x240 -acodec libfaac -ar 48000 outfile</pre><br /><br />The only videos I routinely watch are of The Daily Show, so this little script encodes and renames them from <br /><span style="font-style:italic;">The.Daily.Show.2010.02.04.Rep.Anthony.Weiner.HDTV.XviD.avi</span> to <span style="font-style:italic;">TDS-02.04.mp4</span><br /><br /><pre>#! /bin/sh <br />for i in `ls *.avi`<br />do <br />name=TDS-$(echo $i | cut -c 21-25).mp4<br />ffmpeg -i $i -f mp4 -vcodec mpeg4 -b 200k -aspect 4:3 -r 20.98 -s 320x240 -acodec libfaac -ar 48000 $name<br />done</pre>If you happen to use Prowl and want a notification when it is finished...<pre>num=$(ls | grep mp4 | wc -l)<br />dir=$(pwd)<br />url=https://prowl.weks.net/publicapi/add<br />app="Pod converter"<br />desc="Finished converting $num Daily Shows in $dir"<br />curl -k $url -F apikey=XXX -F application=$app -F description=$desc</pre>... or want to transfer them with ssh (using <a href="http://a-common-hades.blogspot.com/2009/12/ssh-tricks-and-security.html">ssh keys</a>):<pre>mkdir mp4s<br />mv *.mp4 ./mp4s<br />scp -r -i ~/.ssh/SSH_FILENAME /path/to/mp4s mobile@IP:/var/mobile</pre>Tweak it a bit and you can have a basic method for encoding and automatically syncing your favorite videos while you sleep.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-5570625324906693782010-01-31T21:59:00.010-05:002010-02-04T00:07:47.493-05:00Simpler iPhone language pack deletion scriptMy <a href="http://a-common-hades.blogspot.com/2009/12/script-for-deleting-iphone-language.html">earlier script</a> is a pain. It works fine but I'm not happy with it because it's too much work keeping up with iPhone developers and their screwy names for the language packs. <br /><br />For some reason, fr.lproj and French.lproj weren't good enough, so there's some fr_FR.lproj popping up, and not only for French, but a variety of languages. The ISO language code for Spanish is "es," so the language pack should be either "Spanish" or "es," but now I'm seeing "sp", "sp_es" and "es_ES." "Sp" isn't an recognized code for any language.<br /><br />For a script that essentially greps a list of 60 languages in the old format, I don't want to have to add another 30 to deal with these new names popping up. It's easy to add them to the list, but without rewriting the script, it means the user has to be asked "yes or no" for even more languages.<br /><br />I never thought it would become a project I had to maintain anyway. I will rewrite it so that it's flexible and can handle new languages on it's own, and to lessen the number of times the user has to say yes to each language, but here is a simpler script to use for the time being.<br /><br />Since most people want to remove everything except English and Japanese anyway, this simple script will do that. It only asks one question "Do you want to delete everything except English and Japanese?" and if you say yes, it does it. It won't have any problem with new language codes because it gets a list of all languages, filters out English and Japanese and deletes everything that is left. Simple. Almost as simple as my very <a href="http://a-common-hades.blogspot.com/2009/11/deleting-iphone-language-packs.html">first</a> post on the subject.<br /><br />Enjoy.<br /><br /><pre>#! /bin/sh<br /># Thu Feb 4 2010<br />if [ `id -u` != 0 ]; then echo "Oops, you need to be root to run this script"; exit 0; fi<br />while [[ $choice != 'y' ]] && [[ $choice != 'n' ]]<br />do<br />echo "Do you want to delete all language packs <br />except English and Japanese (for emoji<br />keyboards)? <br />y or n?"<br />read choice<br />done<br />if [[ $choice = 'y' ]]; then<br />echo "Please wait while I delete the chosen <br />language packs. This may take a minute <br />or two..."<br />updatedb && locate lproj | grep -E lproj$ | grep -v -i ja | grep -v -i English | grep -v -i \/en > .deletelist_fubaya<br />while read file; do rm -rf "$file"; done < .deletelist_fubaya<br />num=$(cat .deletelist_fubaya | wc -l)<br />rm .deletelist_fubaya<br />echo <br />echo "$num language pack directories deleted"<br />fi<br />[[ $choice = 'n' ]] && echo "Ok, I won't delete anything."; exit 0<br /># end of script</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-67499997178388498282010-01-29T18:44:00.005-05:002010-02-07T00:44:33.131-05:00Copy and paste in MobileTerminalI've been using this "paste" script for a long time, but put off creating anything to copy as I didn't have much of a need. I finally got interested when it came up on a forum last night. Here is the first draft of working copy and paste.<br /><br />Both scripts require PasteBaordStacker because, as I have mentioned before, it stores everything as plain text and I've never gotten around to deciphering Apple's PasteBoard. <br /><br />Paste also requires awk. The awk line may be familiar, it has been so useful it's probably in half the scripts on this blog. Copy uses sed, but I think sed is already installed on a jailbroken iPhone.<br /><br /><span style="font-style:italic;">Edit Feb 7 2010: added the sed lines to convert the characters</span> <, >, and & <span style="font-style:italic;">which get automatically encoded.</span><br /><br /><span style="font-weight:bold;">Paste</span><br /><pre>#! /bin/sh<br />file=/var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist<br />awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"");print;exit}' $file | sed '<br />s/&lt;/</g<br />s/&gt;/>/g<br />s/&amp;/\&/g'</pre><br /><br /><span style="font-weight:bold;">Copy</span><br /><pre>#! /bin/sh<br />in=$(cat -)<br />text=$(echo '<string>'"$in"'</string>')<br />file=/var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist<br />sed -i "7i\\<br />$text" $file</pre><br /><br />Usage:<br />Paste can be used in a variety of ways, but there are two standard methods that are most useful. 1) You can type "<span style="font-style:italic;">paste</span>" on the command line and it will output the last thing you copied on the system. 2) You can use it in a subshell to paste an argument to another program. Example, copy a link to a file in Safari then type <span style="font-style:italic;">wget $(paste)</span> in Terminal. Since the subshell is executed first, the resulting command that is executed is <span style="font-style:italic;">wget www.example.com/file.txt</span><br /><br />Copy is a little rough. Since I used PasteBoardStacker, that means text isn't copied directly into the Apple PasteBoard. You have to select the text in PasteBoardStacker first, which is done by double tapping the status bar, then tapping the text you want from the pop-up list. It takes an extra step but it's still a good way to copy text from Terminal, and other than directing the output to a file, opening it and copying, it's the only way I am aware of. Copy handles piped input so if you run this command: <span style="font-style:italic;">echo "Hello world" | copy</span>, you can then select "Hello world" in PasteBoardStacker and paste into another app.<br /><br />Copy also requires you to escape some special characters with a backslash. <span style="font-style:italic;">echo "Hello world!" | copy</span> won't work because the shell will try to interpret the exclamation point. <span style="font-style:italic;">echo "Hello world\!" | copy</span> is what you need to use. <span style="font-style:italic;">Edit: D'oh, this was a poor example because it's normal shell behavior and not related to copy, but the sed line in copy still can't handle some characters like "<"without escaping.</span>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-88344247000175662782010-01-22T17:37:00.006-05:002010-02-07T00:47:16.288-05:00iPhone/Linux "Network Printing"This hack may be useful if you have a non-network printer attached to your Linux box and want to print text remotely from your iPhone.<br /><br />There are actually several ways to accomplish this. You can simply create a text file and scp that file to your linux box, or pipe it over ssh then execute a print command, but neither worked right for me. The first requires you to create the text file, put something in it, save, then send to print. As for the second method, I can't get text to pipe over ssh from my phone like it should, and even if I could, I'm not certain it would work with slogin and ssh keys. Nothing seemed to work for me, so I went with tapping an icon to automatically print the clipboard contents. This way, you don't have to fool with any files, and if you do want to print a file, you can open it, copy the text, and print it.<br /><br />Requirements:<br />On the iPhone, you need PasteBoardStacker and ssh (preferrably set up with ssh keys). PasteBoardStacker is used because it's easy to get the plain text from it and I've never gotten around to decoding the Apple pasteboard. Maybe I'll tackle that one someday.<br /><br />On your Linux box, you need a to be able to print from the command line, which should already be possible as long as your printer works. In my example, I also use enscript to format the text before piping the text to the lpr print command. Enscript should be present on most systems, and I can't imagine anyone actually prints text that isn't word wrapped.<br /><br />Here is the script that goes on the phone. If you want to run it by tapping an icon on SpringBoard, you need to set up <a href="http://a-common-hades.blogspot.com/2009/12/ssh-tricks-and-security.html">ssh keys</a> and follow <a href="http://a-common-hades.blogspot.com/2009/10/launching-scripts-from-springboard-icon.html">these directions</a>. If you want to run it from MobileTerminal and type your ssh password in every time, change the scp line to "scp ispool USER@IP:/PATH/TO/PUT/FILE." This script can be named anything you like. <span style="font-style:italic;">(Update: I changed the first command, which was really long, to make two shorter lines)</span><br /><pre>#! /bin/sh<br />cd /var/mobile<br />file=/var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist<br />text=$(awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"");print;exit}' $file | sed '<br />s/&lt;/</g<br />s/&gt;/>/g<br />s/&amp;/\&/g') <br />echo $text | tr -d  > ispool<br />scp -i ~/.ssh/KEYFILE ./ispool USER@IP:/PATH/TO/PUT/FILE<br />rm ispool<br />ssh USER@IP iprint</pre><br />This goes on the Linux box and is called "iprint." If you want to name it something else, change "iprint" on the last line of the previous script to the new name. This uses enscript, but that's optional and you can change that whole line to "cat ispool | lpr" if you like.<br /><br /><pre>#! /bin/sh<br />cd /PATH/TO/FILE<br />cat ispool | enscript -h -B -1 --word-wrap --media=A4<br />rm ispool</pre><br />Or, if you would like a Prowl notification of the print job...<br /><pre>#! /bin/sh<br />cd /PATH/TO/FILE<br />cat ispool | enscript -h -B -1 --word-wrap --media=A4> tmpspool 2>&1<br />job=$(cat ispool)<br />output=$(cat tmpspool)<br />rm ispool tmpspool<br />curl -k https://prowl.weks.net/publicapi/add -F apikey=xxxxx -F application="Print job:" -F description="$output $job"</pre><br /><br /><span style="font-style:italic;">Update: I found that piping over ssh does work as it should. I don't know why it wasn't working for me the other day, except maybe because I was figuring out this whole print thing at 2 in the morning. That's what happens when you lay in bed and think "I'd like to print this out but don't want to get up." Anyway, this script can be ran on the phone to print the contents of the clipboard. I still like the above method because it allow me to get the output via Prowl notification, but this is simpler:</span><br /><pre>#! /bin/sh<br />file=/var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist<br />text=$(awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"");print;exit}' $file<br /><br />echo $text | tr -d  | slogin -i ~/.ssh/KEYFILE USER@IP lpr</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-19604233474211096582009-12-13T23:06:00.005-05:002009-12-13T23:09:30.599-05:00Need more room on your iPhone's root partition?I always move all my fonts after every update. It frees up about 100mb of space.<pre>mv /System/Library/Fonts /private/var/ && ln -s /private/var/Fonts /System/Library/Fonts</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-22407969004895761892009-12-12T00:44:00.005-05:002009-12-14T21:28:18.216-05:00Script for disabling some iPhone launch daemons<pre>#! /bin/sh<br /><br /># test for root<br />if [ `id -u` != 0 ]; then echo "Oops, you need to be root to run this script"; exit 0; fi<br /><br />echo "Made by fubaya using description of the daemons by jdys_1991 at http://modmyi.com/forums/file-mods/682255-speed-up-your-iphone-ipod-removing-launch-daemons.html. <br />Press enter to continue..."<br />read<br /><br />echo "This script only works on daemons listed as "Safe", "Conditional", or "Jailbreak" by jdys_1991 on the modmyi forum post. It will list them one by one and ask if you want to disable them by moving them to /var/mobile/LaunchDaemonsBackup. <br />Press enter to continue..."<br />read<br /><br />script=$0<br />mkdir /var/mobile/LaunchDaemonsBackup<br />backupdir=/var/mobile/LaunchDaemonsBackup/<br />daemondir=/System/Library/LaunchDaemons/<br />ls $daemondir > .daemonlist<br /><br />###################################################<br />function daemon {<br /># edited Dec-12 to send unnecessary output to /dev/null<br />if echo $1 | grep -i -f .daemonlist > /dev/null<br />then<br />echo -------------------------------------<br />echo $1 | grep -i "# $1" $script<br />echo<br /># edited Dec-12 to change "delete" to "disable"<br />echo "Do you want to disable $1?" y or n?<br />echo -------------------------------------<br />read choice<br /># edited Dec-12 to add confirmation that file was moved<br />[ $choice = "y" ] && mv $daemondir$1 $backupdir && echo "$1 successfully disabled"<br />[ $choice = "n" ] && echo "$1 not disabled"<br />fi<br />}<br />daemon com.apple.DumpPanic.plist<br />daemon com.apple.ReportCrash.DirectoryService.plist<br />daemon com.apple.ReportCrash.Jetsam.plist<br />daemon com.apple.ReportCrash.SafetyNet.plist<br />daemon com.apple.ReportCrash.SimulateCrash.plist<br />daemon com.apple.ReportCrash.plist<br />daemon com.apple.CrashHousekeeping.plist<br />daemon com.apple.aslmanager.plist<br />daemon com.apple.syslogd.plist<br />daemon com.apple.powerlog.plist<br />daemon com.apple.stackshot.server.plist<br />daemon com.apple.tcpdump.server.plist<br />daemon com.apple.iqagent.plist<br />daemon com.apple.mobile.profile_janitor.plist<br />daemon com.apple.chud.chum.plist<br />daemon com.apple.chud.pilotfish.plist<br />daemon com.apple.AddressBook.plist<br />daemon com.apple.accessoryd.plist<br />daemon com.apple.apsd.plist<br />daemon com.apple.dataaccess.dataaccessd.plist<br />daemon com.apple.datamigrator.plist<br />daemon com.apple.racoon.plist<br />daemon com.apple.MobileInternetSharing.plist<br />daemon com.apple.aggregated.plist<br />daemon com.apple.AOSNotification.plist<br />daemon com.apple.AdminLite.plist<br />daemon com.bigboss.sbsettingsd.plist<br />daemon com.imalc.insomnia.plist<br />daemon com.mxweas.MxT2d.plist<br />daemon com.saurik.Cydia.Startup.plist<br />daemon org.nodomain.scrobbled.plist<br />###################################################<br />rm .daemonlist<br />num=$(ls $backupdir | wc -l)<br />echo <br />echo "$num daemons have been moved to $backupdir. Please reboot for changes to take effect. Do you want me to <br />delete myself? y or n?"<br />read choice<br />[ $choice = "y" ] && echo "Deleting myself..." && sleep 1.5 && echo "blarg.. I'm dead" && exec rm $0<br />echo "Phwew, Thank you! I'm too young to die. I'll be here at `pwd`/`basename $0` if you need me."<br />###################################################<br /># Safe Daemons - These can be deleted by any user, with no adverse effects on the device<br /># com.apple.DumpPanic.plist (Safe)- Dumps crashes for evaluation by Apple.<br /># com.apple.ReportCrash.plist (Safe)- Collects data about what caused a crash, what programs were running at the time, etc.<br /># com.apple.ReportCrash.DirectoryService.plist (Safe)- Collects data about what caused a crash, what programs were running at the time, etc.<br /># com.apple.ReportCrash.Jetsam.plist (Safe)- Collects data about what caused a crash, what programs were running at the time, etc.<br /># com.apple.ReportCrash.SafetyNet.plist (Safe)- Collects data about what caused a crash, what programs were running at the time, etc.<br /># com.apple.ReportCrash.SimulateCrash.plist (Safe)- Collects data about what caused a crash, what programs were running at the time, etc.<br /># com.apple.CrashHouseKeeping.plist (Safe)- Also deals with crashes.<br /># com.apple.aslmanager.plist (Safe)- This daemon manages system logs.<br /># com.apple.syslogd.plist (Safe)- Logs system events.<br /># com.apple.powerlog.plist (Safe)- This is used to monitor any incompatibilities with 3rd party chargers.<br /># com.apple.stackshot.server.plist (Safe)- This daemon's function is currently unknown, but removing it has no adverse effects on one's device. Some more information can be found here, although the page is quite technical and isn't very useful to an end-user.<br /># com.apple.tcpdump.server.plist (Safe)- This daemon is apparently used to dump traffic on a network. Removing this daemon has no adverse effects on one's device.<br /># com.apple.iqagent.plist (Safe)- This daemon's function is currently unknown, but removing it has no adverse effects on one's device.<br /># com.apple.mobile.profile_janitor.plist (Safe)- This daemon's function is currently unknown, but removing it has no adverse effects on one's device.<br /># com.apple.chud.chum.plist (Safe)- This daemon is thought to relate to Apple's CHUD (Computer Hardware Understanding Developer) tools. Removing this daemon will have no adverse effects on your device, unless you are a developer.<br /># com.apple.chud.pilotfish.plist (Safe)- This daemon is also thought to relate to Apple's CHUD tools. Removing this daemon will have no adverse effects on your device, unless you are a developer.<br /><br /># Conditional Daemons - These daemons can be disabled by certain users who have no need for some features of their device.<br /># com.apple.AddressBook.plist (Conditional)- If removed, Contacts in the Phone application will load slightly slower. Disable this if you don't care about that.<br /># com.apple.accessoryd.plist (Conditional)- If removed, disables accessories like FM radio transmitters, iPhone docks, and AV cables. Accessories will be able to charge your device, but that is all they will be able to do. Remove this if you don't use any of these accessories.<br /># com.apple.apsd.plist (Conditional)- If removed, Push Notifications will no longer work. Disable this if you don't use Push Notifications.<br /># com.apple.dataaccess.dataaccessd.plist (Conditional)- If removed, contacts will no longer sync via Exchange or Google Sync. Disable this if you don't use those services.<br /># com.apple.datamigrator.plist (Conditional)- Used to transfer contacts from SIM card to phone. iPod touch users can delete this.<br /># com.apple.racoon.plist (Conditional)- Used for Virtual Private Networks. Disable this daemon if you do not use any VPNs.<br /># com.apple.MobileInternetSharing.plist (Conditional)- Used for Internet Tethering. Disable this if you have an iPod touch or if you aren't interested in tethering.<br /># com.apple.aggregated.plist (Conditional)- It is believed that this performs some function related to Audio-In. If you have an iPod touch and do not intend to use Audio-In, disable this. iPhone users should leave this alone.<br /># com.apple.AOSNotification.plist (Conditional)- This daemon deals with MobileMe syncing. If you do not use the MobileMe service, you can disable this.<br /># com.apple.AdminLite.plist (Conditional)- This daemon tries to return control of your device to you if it thinks that you are waiting for a lengthly process to respond. It does this by force-quitting the process, so if you're tired of your apps crashing and you would rather wait a few seconds for them to finish what they're doing, disable this daemon.<br /><br /># Jailbreak Daemons - These are daemons installed by jailbreak applications.<br /># com.bigboss.sbsettingsd.plist (Jailbreak)- Related to SBSettings. I would suggest leaving it alone.<br /># com.imalc.insomnia.plist (Jailbreak)- Used to keep Insomnia running through resprings and reboots. If you don't want it to do that, disable this. (note from fubaya: disabling this causes the Insomnia toggle to disappear from SBSettings)<br /># com.mxweas.MxT2d.plist (Jailbreak)- The daemon that allows MxTube to download videos in the background. If disabled, the application will need to be reinstalled; however, if you don't use MxTube and are too lazy to uninstall it, you can disable this daemon.<br /># com.saurik.Cydia.Startup.plist (Jailbreak)- It's believed that this daemon deals with the AutoInstall trick for installing .deb files. If you don't know what that is and you don't use it, you can disable this daemon.<br /># org.nodomain.scrobbled.plist (Jailbreak)- The Scrobbler daemon. <br /></pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-66608230919169300212009-12-10T00:13:00.002-05:002009-12-10T00:29:31.854-05:00"Free memory"Nothing is free.<br /><br />A lot of iPhone users are obsessed with the amount of free memory they have. Apps like SBSettings will show how many megabytes of free memory you have and even allow you to free up more. A script is going around that allows you to free memory every time it drops by 2 megabytes!<br /><br />This may go against conventional wisdom, but free memory isn't all it's cracked up to be. There is an old unix saying "free memory is wasted memory." The system keeps inactive data in memory in order to make things faster to look up if it's needed again later. This makes your amount of free memory look low, but it's nothing to worry about. If the memory is needed by another program, the kernel will instantly free it.<br /><br />Example, you run an app which uses a certain library. That library is loaded into memory. You close the app, but the library stays in memory, just hanging out, doing nothing, making your free memory number go lower. If you load another app that uses that library, it will be faster to look up and will cause the app to load faster, but if the memory has been freed, it will be a little slower as the system has to read the library into memory from disk to use it with the app.<br /><br />You may be able to see and hear an example of this on your home computer. I have 2GB ram on a Linux system that only needs 500MB, but if I boot my computer and open Firefox, it takes a few seconds to load and I will hear my hard drive clicking as it reads information from the disk. If I close it and open it again, it opens instantly with no drive clicking. That's because everything the system needed to run Firefox was still in memory. If I free the pagecache (echo 1 > /proc/sys/vm/drop_caches) my free memory goes up, but if I open Firefox again, it takes longer and my hard drive clicks the same as it did the first time.<br /><br />Another example closer to topic is the mail app on the iPhone. Open it up and close it with the home button. Open and close it a couple more times and you should see that it opens almost instantly. Now go to SBSettings, free the memory and open mail again. It will be jerkier and slower than normal.<br /><br />If you don't see a difference, open an email. It will probably take a couple of seconds to load the email. Once it's loaded, go back to your inbox. Now open the email again and it will open instantly. Go back and forth from your inbox to the email a couple of times and the email should open almost instantly every time. Now, without closing mail, use SBSettings to free memory. Then click the email and it will take a while to load. Again, the data in memory has been dumped and it has to be read anew.<br /><br />This isn't to say that all free memory is bad, obviously. I have a 3G and wish I had as much free memory as the 3Gs guys. If an app needs X amount of memory and the system can't free that much, something will crash. Having extra memory is a good thing, but freeing memory to get the "free memory" number up means the system isn't using the memory the way it was designed. Things aren't being buffered and will need to be read from disk more often, and that's always slower.<br /><br />But maybe there is some advantage to clearing out the memory before opening a large app. It would keep the system from having to flush the memory and write to disk while the app is opening and could make for a more stable app launch, but I suspect everything else will be slightly slower in general.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-28222908169666538052009-12-05T00:05:00.010-05:002009-12-07T18:10:41.096-05:00ssh tricks and securityIf you have a jailbroken iPhone with ssh installed, you've probably heard about the handful of worms going around that exploits the fact that people don't change their default iPhone passwords. <br /><br />Of course, the fix is simple. <span style="font-weight:bold;"><a href="http://cydia.saurik.com/password.html">Change</a> your damn password!</span> As an added bit of security, if you have SBSettings, you can get an ssh toggle to turn off ssh access when you're not using it. That should be good enough, but why not go a little further?<br /><br />First, set up ssh keys using <a href="http://www.eng.cam.ac.uk/help/jpmg/ssh/authorized_keys_howto.html">this how-to</a>. It may seem confusing the first time, but it's really very simple. I've done it twice. The first time took a few minutes and the second time took about 30 seconds. I set up keys to login to my computer from my iPhone, and also keys to login to my phone from my computer.<br /><br />(As a side note; if you have ssh keys setup on a phone or computer that gets lost, you will need to remove it's entry in authorized_keys on the other computer and delete the key.)<br /><br />Simply setting up ssh keys doesn't help with security yet. We'll get to that, but right now let's look at the tricks you can do with ssh keys, mainly the convenience of being able to login with without a password. Instead, the computers are authenticated with the keys. You can login with slogin:<pre>slogin -i ~/.ssh/SSH_FILENAME user@IP</pre>You can also put that in a script and simply run the script to login.<br /><br />Another command that works with ssh keys is scp, which is ssh's copy command that copies files between computers:<pre>scp -i ~/.ssh/SSH_FILENAME FILE_TO_COPY user@IP:/PATH/TO/COPY/TO</pre>You can also modify that a little to put it in a script and run the script with the file you want to copy as an argument:<pre>scp -i ~/.ssh/SSH_FILENAME $1 user@IP:/PATH/TO/COPY/TO</pre>Another script to transfer directories:<pre>scp -r -i ~/.ssh/SSH_FILENAME $1 user@IP:/PATH/TO/COPY/TO</pre>You can put all of these on your iPhone and computer and perhaps name the ssh scripts "sshcomp" and "sshphone", the scp scripts "tocomp" and "tophone", and the "ssh -r" scripts to recursively copy a directory "tocompr" and "tophoner" and never have to worry about typing in long ssh or scp commands again.<br /><br />Now, let's get back to ssh security. Once the keys are working, let's look at the ssh setup. The file we want to have a look at should be located at /etc/ssh/sshd_config.<br /><br />There are a few lines that can greatly enhance our security. They are probably commented out and look like "<span style="font-style:italic;"># Something</span>", so you will need to remove the "#" in order for the option to take effect. These are the options we want to look at:<br /><br /><span style="font-weight:bold;">Port 22</span> - The default port for ssh is 22 and everyone knows it. Anyone port scanning your computer or phone will probably probe ports for common services like email, web server and ssh, and it may only take one or two seconds to scan the common ports. Well, computers have 65535 ports, so why run ssh on the ssh port? Pick a random port! <br /><br /><span style="font-style:italic;">(EDIT: I found that editing /etc/ssh/sshd_config didn't change the port on the iPhone. After a little google work, I found that launchd overides the port configuration, but you can change the phone's ssh listening port by editing /etc/services. You will see two lines "ssh 22/udp" and "ssh 22/tcp". Change both "22"s to whatever port you want to use.)</span><br /> <br />Don't forget to allow that port in firewalls and routers and specify it when using scp or ssh. To specify ports for those programs, use -P for scp and -p for slogin. Examples using port 5555:<pre>scp -i ~/.ssh/SSH_FILENAME -P 5555 $1 user@IP:/PATH/TO/COPY/TO<br />slogin -i ~/.ssh/SSH_FILENAME -p 5555 user@IP</pre><span style="font-weight:bold;">PermitRootLogin no</span> - Set this as no and login as a regular user and use "su" instead.<br /><span style="font-weight:bold;">PubkeyAuthentication yes</span> - These are the ssh keys I've been talking about. We want to use those.<br /><span style="font-weight:bold;">PasswordAuthentication no</span> - This is how you normally login through ssh. You can turn this off so the only way to login is with the ssh keys. Even if someone knows your password, they can't get in without the keys.<br /><br />Once you're finished editing the config file on your computer, restart the ssh daemon by running:<pre>/etc/rc.d/rc.sshd stop<br />/etc/rc.d/rc.sshd start</pre>I'm not certain how to do this on the iPhone. sshd is launched demand by launchd and I'm not sure when the config file is read. I would assume it's read at launch and that you can turn ssh off and back on in SBSettings, but I'm not familiar enough with launchd and ssh on the phone to say for sure, so you may have to reboot the phone.<br /><br /><span style="font-style:italic;">(EDIT: I found that flipping the SBSettings ssh toggle off and back on will load the new preferences)</span><br /><br />Once you're all finished, enjoy being more secure!JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-34334055495361821472009-12-03T22:40:00.032-05:002010-05-05T00:39:56.671-04:00Script for deleting iPhone language packs<span style="font-style:italic;">This script is outdated, please see the script <a href="http://a-common-hades.blogspot.com/2010/02/final-script-for-deleting-iphone.html">here</a>. Also, don't use the version of this script found on sinful iphone forums by Monsieurtalbot. He made a few ugly edits to the echo commands and claimed to have written the script. When called out, he then claimed to have rewritten it and fixed a bug that made Terminal crash, but a simple look at the code shows no rewrite. It's the same (outdated) script except uglier due to poorly formatted echos.</span><br /><br /><pre>#! /bin/sh<br /># Feb 9 2010<br />echo <br /># test for root<br />if [ `id -u` != 0 ]; then echo "Oops, you need to be root to run this script"; exit 0; fi<br /><br />echo "Let's delete a few thousand language packs. <br />You will have several chances to back out<br />before anything is deleted but if you want<br />to stop at any time hit ctrl c. On the <br />iPhone keyboard, control is a black dot <br />that is found on the far right when you <br />tap 123 then # =."<br />echo <br />echo "If you want to see how it runs without <br />making any changes, just answer no when it <br />asks you which languages to delete."<br />echo<br />echo "Press enter to begin."<br />read<br /><br />echo "Please contact me at ijdmas at gmail dotcom <br />if this script asks you to delete a language<br />but doesn't list that language. It will <br />look like this: <br />\"Do you want to delete:? y or n?\""<br />echo<br />echo "This is due to someone using the long name <br />for a language which Ive not seen yet. <br />Example, if Vulcan used to be vu.lproj <br />and someone starts using Vulcan.lproj,<br />it will cause that problem. If it <br />happens, it is safe to answer no and <br />continue."<br />echo<br />echo "Press enter to begin."<br />read<br /><br /># create temp files<br />touch .langlist_fubaya .keeplist_fubaya .deletelist_fubaya .alllist_fubaya<br /><br /># update database, locate all lproj, and grep directories minus English<br />echo "Searching for language packs. Please wait..."<br />updatedb && locate lproj | grep -E lproj$ | grep -v -i English | grep -v -i \/en > .alllist_fubaya <br /><br /># get a list of all languages<br />cat .alllist_fubaya | while read file; do basename "$file"; done | grep -E lproj$ | sort | uniq > .langlist_fubaya<br />echo ---------------- >> langpack.log<br />echo langlist >> langpack.log<br />cat .langlist_fubaya >> langpack.log<br /><br /># display true names beside the language codes<br /># ask user if they want to keep them or not, put keepers in ".keeplist_fubaya" file<br />echo ---------------- >> langpack.log<br />for i in $(cat .langlist_fubaya) ; do <br />q=$(cat $0 | grep -i "\# $i" | tr -d \#)<br />[ -n "$q" ] && echo "Delete:$q? y or n?" || echo "Delete: $i (unrecognized)? y or n?"<br />read choice<br /><br /># make sure "y" or "n" was entered, else keep repeating the question<br />while [[ $choice != 'y' ]] && [[ $choice != 'n' ]]<br />do<br />[ -n "$q" ] && echo "Delete:$q?" y or n? || echo "Delete: $i (unrecognized)?" y or n?<br />read choice<br />done<br /><br />echo "delete:$i: $choice" >> langpack.log<br />[ $choice = "n" ] && echo $i >> .keeplist_fubaya<br />echo <br />done<br />echo ---------------- >> langpack.log<br />echo keeplist >> langpack.log<br />cat .keeplist_fubaya >> langpack.log<br /><br /># put master list into delete list, filtering out keepers<br />cat .alllist_fubaya | grep -v -f ./.keeplist_fubaya > .deletelist_fubaya <br /># show final list of lang packs and confirm the user wants to delete them<br />echo<br />echo "Please wait while I compile a list of languages to delete. You will be asked for confirmation before anything is deleted"<br />echo ---------------- >> langpack.log<br />echo deletelist >> langpack.log<br />cat .deletelist_fubaya >> langpack.log<br />echo<br />echo -------------------------------------<br />cat .deletelist_fubaya | while read file; do basename "$file"; done | grep -E lproj$ | sort | uniq | tr '\n' ' '<br />echo<br />echo -------------------------------------<br />echo "This is your last chance. Are you sure you want to delete the language packs listed? Type y or n"<br /><br />read choice<br />if [ $choice = "y" ] <br />then<br /># do the deed<br />echo ---------------- >> langpack.log<br />echo "final confirmation: $choice" >> langpack.log<br />echo ---------------- >> langpack.log<br />echo "Please wait while I delete the chosen language packs..." && while read file; do rm -rf "$file"; done < .deletelist_fubaya <br /><br /># how many did we delete?<br />num=$(cat .deletelist_fubaya | wc -l)<br /># clean up temp files<br />rm .langlist_fubaya .keeplist_fubaya .deletelist_fubaya .alllist_fubaya<br /><br />echo <br />echo "$num language pack directories have been <br />deleted. A log file has been created at <br />`pwd`/langpack.log. Please hang on to <br />that until you are sure there are no <br />problems. My contact information is at <br />the top of the log file. The only other <br />thing left is me, this script located at <br />`pwd`/`basename $0`. Do you want me to <br />delete myself? y or n?"<br /><br />read choice<br />[ $choice = "y" ] && echo "Deleting myself..." && sleep 1.5 && echo "blarg.. I'm dead" && exec rm $0<br />echo "Phwew, Thank you! I'm too young to die. I'll be here at `pwd`/`basename $0` if you need me."<br /><br />else # if user selected "n" to deleting the language packs<br />rm .langlist_fubaya .keeplist_fubaya .deletelist_fubaya .alllist_fubaya<br />echo "Ok, I won't delete anything. If you made a mistake, just run me again."<br />fi<br /><br /># Arabic.lproj<br /># Chinese.lproj<br /># Croatian.lproj<br /># Czech.lproj<br /># Danish.lproj<br /># Dutch.lproj<br /># Finnish.lproj<br /># French.lproj<br /># German.lproj<br /># Greek.lproj<br /># Hebrew.lproj<br /># Indonesian.lproj<br /># Italian.lproj<br /># Japanese.lproj<br /># Korean.lproj<br /># Malay.lproj<br /># Norwegian.lproj<br /># Polish.lproj<br /># Portuguese.lproj<br /># Romanian.lproj<br /># Russian.lproj<br /># Slovak.lproj<br /># Spanish.lproj<br /># Swedish.lproj<br /># Thai.lproj<br /># Turkish.lproj<br /># Ukrainian.lproj<br /># ar.lproj (Arabic)<br /># cs.lproj (Czech)<br /># cs_CZ.lproj (Czech)<br /># da.lproj (Danish)<br /># da_DK.lproj (Danish)<br /># de.lproj (German)<br /># de_DE.lproj (German)<br /># el.lproj (Greek)<br /># el_GR.lproj (Greek)<br /># es.lproj (Spanish)<br /># es_419.lproj (Spanish)<br /># es_ES.lproj (Spanish)<br /># fi.lproj (Finnish)<br /># fi_FI.lproj (Finnish)<br /># fr.lproj (French)<br /># fr_CA.lproj (French)<br /># fr_FR.lproj (French)<br /># he.lproj (Hebrew)<br /># hr.lproj (Croatian)<br /># hr_HR.lproj (Croatian)<br /># hu.lproj (Hungary)<br /># id.lproj (Indonesian)<br /># it.lproj (Italian)<br /># it_IT.lproj (Italian)<br /># ja.lproj (Japanese)<br /># ko.lproj (Korean)<br /># ms.lproj (Malay)<br /># nl.lproj (Dutch)<br /># nl_NL.lproj (Dutch)<br /># no.lproj (Norwegian)<br /># no_NO.lproj (Norwegian)<br /># pl.lproj (Polish)<br /># pl_PL.lproj (Polish)<br /># pt.lproj (Portuguese)<br /># pt_PT.lproj (Portuguese)<br /># ro.lproj (Romanian)<br /># ro_RO.lproj (Romanian)<br /># ru.lproj (Russian)<br /># ru_RU.lproj (Russian)<br /># rus.lproj (Russian)<br /># sk.lproj (Slovak)<br /># sk_SK.lproj (Slovak)<br /># sp.lproj (Spanish)<br /># sp_es.lproj (Spanish)<br /># sv.lproj (Swedish)<br /># sv_SE.lproj (Swedish)<br /># th.lproj (Thai)<br /># tr.lproj (Turkish)<br /># tr_TR.lproj (Turkish)<br /># uk.lproj (Ukranian)<br /># zh-Hans.lproj (Chinese)<br /># zh-Hant.lproj (Chinese)<br /># zh_CN.lproj (Chinese)<br /># zh_HK.lproj (Chinese)<br /># zh_TW.lproj (Chinese)<br /># end of script</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-73790259088823889692009-11-23T23:11:00.003-05:002009-11-23T23:48:43.890-05:00Deleting iPhone language packsEvery iPhone application has the option of including language packs. There come in the form of a seperate directory for every language the app supports. Inside those directories are files with various strings in that language that the app may use. Some apps may not support any additional languages and some may support 20.<br /><br />They say (and I don't know who *they* are) that removing them can increase the phone's performance. I don't know how accurate that is, but it obviously does increase free space on the phone.<br /><br />So here is one way to remove them from MobileTerminal, or any other command line program that can run commands on the phone.<br /><br />First, log in as root by whatever means you wish. Either su in MobileTerminal, ssh root@IP, or whatever.<br /><br />Run this command to update the locate database: <span style="font-weight:bold;">updatedb</span> <br /><br />Now, we want to build a list of directories to delete by using the locate command to find all the language packs. Luckily, they are all found in *.lproj directories, so we start with <span style="font-weight:bold;">locate lproj</span>. <br /><br />The output will include all the files in an .lproj directory, so let's use a grep regular expression to get only the directories. <span style="font-weight:bold;">locate lproj | grep -E lproj$ </span> will output only files that end with lproj, so it will output English.lproj, but not English.lproj/somefile.txt<br /><br />Now we want to filter out the directories we want to keep. In my case, all I want to keep is English. On the iPhone, English can be either en.lproj or English.lproj so I piped the output to grep -v to filter out both: <span style="font-weight:bold;">grep -E -v -i '(en.l|English)'</span><br /><br />It may be simpler to grep the one at a time with -v and -i. "-v" is like a 'reverse grep' which displays everything except the string you specify and "-i" makes it case insensitive.<br /><br />The official iPhone apps usually use long names like "English" and "Italian" while other apps will often use "en" and "it", so be sure to look for long and short names.<br /><br />So, if you wanted to keep German, you could run this to save it to a text file:<pre>locate lproj | grep -E proj$ | grep -v -i "XXXXXX.lproj" > langpacks.txt</pre>Just add <span style="font-weight:bold;">| grep -v -i "XXXXXX.lproj"</span> for any languages you don't want deleted, and remember to add a grep for both long and short names.<br /><br />Once you're sure everything looks safe to delete, then run this command:<pre>while read file; do rm -rf "$file"; done < langpacks.txt</pre>To recap: if you're certain you only want English languages on your phone, run this:<pre>updatedb <br />locate lproj | grep -E proj$ | grep -E -v -i '(en.l|English)' > langpacks.txt <br />while read file; do rm -rf "$file"; done < langpacks.txt</pre>I deleted over 3000 language pack directories with this, and I only have less than 2 pages of apps installed.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-64455620295628349542009-11-11T22:53:00.003-05:002009-11-11T23:04:05.710-05:00A simple backup scriptUnfortunately, this can't run from a SpringBoard icon as it takes too long to execute. iPhone apps are supposed to tell the system when they've finished loading or else the system assumes they're hung and kills them. I'm looking for a workaround, as I have 3 scripts I want to run that way but which get killed every time.<br /><br />To use this script, put a list of files you want to back up in /var/mobile/backuplist. It will copy them to /var/mobile/backup/, tar and bzip2 them, then scp them to your computer using ssh keys, which I explained <a href="http://a-common-hades.blogspot.com/2009/11/send-copied-text-from-iphone-to-linux_06.html">earlier</a>. It could obviously use regular scp if you don't mind typing the password.<pre>#! /bin/sh <br />cd /var/mobile<br />while read line; do cp -r $line /var/mobile/backup/; done < backuplist<br />tar -cf backup.tar /var/mobile/backup<br />bzip2 backup.tar<br />scp -i ~/.ssh/KEY ~/backup.tar.bz2 USER@IP:/PATH/TO/DESTINATION<br />rm -rf backup<br />rm backup.*<br /></pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-35842953478161765232009-11-10T22:10:00.003-05:002009-11-10T22:27:32.290-05:00Iphone Panic ButtonThere was a thread at Macrumors where someone asked if there were any apps which could delete your sensitive files if someone took your phone. The poster's situation was that they were in school and if they were caught with a phone, they had to turn it over and the teacher would go through it looking for anything against school rules.<br /><br />This can be done with a short shell script ran from SpringBoard using the method I posted about <a href="http://a-common-hades.blogspot.com/2009/10/launching-scripts-from-springboard-icon.html">earlier</a>. <br /><br />There are several ways of doing it depending on your threat model. You could delete the files, but what will happen to the SMS app if you delete it's database? Will it crash or create a new one? If it crashes, you may not be able to use it until you get home and copy a new .db file to the phone. If you don't have one, you may even need to restore.<br /><br />A smarter way is to simply hide the files from our SpringBoard script and unhide them with another script which is hidden on the phone and ran from MobileTerminal. This should be good enough for most people and these scripts accomplishes that.<br /><br />Create a text file and list all the files and directories you want to hide. Don't worry about spaces or anything, just make a normal list with the full path to the files/directories, one per line. This example assumes you run the script from a fake app called Panic and the file list is in Panic.app. <pre>#! /bin/sh <br />while read line; do<br />dir=$(dirname "$line")<br />file=$(basename "$line") <br />mv "$line" "$dir"/."$file"; <br />done < /Applications/Panic.app/filelist.txt</pre>Files will be hidden in the same directory as their original location. If you want to move them all to a different directory, change "$dir"/."$file" to /path/to/another/directory/."$file"<br /><br />Put this next script anywhere you want and run it from MobileTerminal to unhide the files. You may notice it's almost the same script, only one variable on the mv line has changed places.<pre>#! /bin/sh <br />while read line; do<br />dir=$(dirname "$line")<br />file=$(basename "$line") <br />mv "$dir"/."$file" "$line"; <br />done < /Applications/Panic.app/filelist.txt</pre>Now this is cool. You could (sorta) run this remotely if you have the Prowl app, you just need the person with the phone to cooperate a little. You can add this to panic's plist file:<pre><key>CFBundleURLTypes</key><br /><array><br /><dict><br /><key>CFBundleURLName</key><br /><string>panic URL</string><br /><key>CFBundleURLSchemes</key><br /><array><br /><string>panic</string><br /></array><br /></dict><br /></array></pre>Then go to Prowl's folder, find "Redirections.plist" and add this:<pre><key>Key</key><br /><string>Panic</string><br /><key>URL</key><br /><string>panic:</string></pre>Then open Prowl and create a redirection based on the app name "Panic" and select panic from the list.<br /><br />Send a Prowl notification from home using "panic" in the application field. When the notification pops up on the phone, a person can choose whether to view or close it like an SMS. If they select view, it will run the panic script and hide your files. However, if they select "close", it does nothing. You could just as easily rename the panic icon to "Bank Info" or "Nekkid Chicks" and trick them into running it. I just think it's cool.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-10324672656741967982009-11-07T13:51:00.002-05:002009-11-07T14:03:23.572-05:00Send copied text from iPhone to Linux desktop finalI tweaked the script enough to finish out the subject. I think it's pretty foolproof. Set up the script from my <a href="http://a-common-hades.blogspot.com/2009/11/send-copied-text-from-iphone-to-linux_06.html">last post</a> on the phone and use this script on the computer.<br /><br />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.<br /><br /><pre>#! /bin/sh<br />cd /path/to/plist/directory<br />file=com.hitoriblog.pasteboardstacker.plist<br />link=$(awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"")}1{print $RS;exit}') $file<br /><br /># send the text to the clipboard<br />echo $link | xclip<br /><br /># If the text is a link, this will create <br /># an html file which you've pre-bookmarked in Firefox<br />if<br />echo "$link" | head -1 | grep http > /dev/null<br />then<br />cd /path/to/html/file/dir<br />echo -n '<html><br /><head><br /><title>Reverse Prowling</title><br /><meta http-equiv="REFRESH" content="0;url=' > iLink.html<br />echo "$link" >> iLink.html<br />echo '></HEAD><br /><BODY><br />Redirecting to $link...<br /></BODY><br /></HTML>' >> iLink.html<br /><br />else <br /># if the text is not a link, this will<br /># display the text in the html file <br /># which you bookmarked in Firefox.<br /># It will appear as plain text when Firefox opens it<br />echo "$link" | sed 'N;s/\n/<br>/g;P;D;' | tr -d  > iLink.html<br />fi</pre>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-47768751916261704532009-11-07T00:18:00.003-05:002009-11-07T00:25:49.490-05:00Changing the blog templateI'm getting frustrated with blogger. It took me forever to figure out how to post code as blogger doesn't have builtin code tags like most forums do. Now, if I have a long string, it gets cut off on the right side by the sidebar. Why doesn't it word wrap it? <br /><br />There is probably a simple solution but I don't know, or care about, CSS enough to make the blog look pretty. So here we are with a new template. Nice and plain.<br /><br />Old style. notice how it cut off half of the scp command<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img188.imageshack.us/img188/8655/snap2ec.jpg"><img style="cursor:pointer; cursor:hand;width: 1584px; height: 471px;" src="http://img188.imageshack.us/img188/8655/snap2ec.jpg" border="0" alt="" /></a><br /><br />New style. Scp command is there, if you scroll.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img198.imageshack.us/img198/7424/snap1cy.jpg"><img style="cursor:pointer; cursor:hand;width: 1590px; height: 482px;" src="http://img198.imageshack.us/img198/7424/snap1cy.jpg" border="0" alt="" /></a>JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.comtag:blogger.com,1999:blog-3656867536766537604.post-59575374995899416732009-11-06T21:16:00.006-05:002009-11-07T00:04:53.846-05:00Send copied text from iPhone to Linux desktop ReduxThat last post using mailx to send the iPhone's clipboard contents tested great then started failing. I tried to work out the bugs but it didn't cooperate. Mailx crashes often when executed from a SpringBoard icon and the sed line tests well then stops working for some unknown reason.<br /><br />I finally gave up and found a better, faster, and more reliable alternative, and that's to use an auto-login to scp the clipboard file to the PC, where processing can take place.<br /><br />Setting up scp to auto-login is pretty simple. It involves creating a keypair and moving the private key to the iPhone, then logging in to the computer with that key. Here is a more detailed <a href="http://www.eng.cam.ac.uk/help/jpmg/ssh/authorized_keys_howto.html">guide</a>.<br /><br />Once the auto-login is set up, use this script on the iPhone:<br /><pre><br />#! /bin/sh<br />cd /var/mobile<br />scp -i ~/.ssh/KEY ~/Library/Preferences/com.hitoriblog.pasteboardstacker.plist USERNAME@IPADDRESS:/PATH/TO/PUT/THE/FILE<br /></pre><br /><br />Now you can do the text processing on the computer. I will tweak that soon-tomorrow if I have the time- and post the results.JMhttp://www.blogger.com/profile/02471284686600275424noreply@blogger.com