Yahoo!Hacks
ByPaulBausch
...............................................
Publisher:O'Reilly
PubDate:October2005
ISBN:0-596-00945-3
Pages:489
TableofContents|Index
Yahoo!tooktheworldbystorminthe1990sasaone-of-a-kind,searchablelistof
interestingwebsites.Buttenyearslater,ithasexpandedintoadepartmentstore
overflowingwithusefulandinnovativetoolsandservices-fromemail,blogging,social
networking,andinstantmessaging,tonews,financialmarkets,shopping,movieandTV
listings,andmuchmore.Today'sYahoo!keepsyouconnectedwitheveryaspectofyour
lifeandeverycorneroftheWeb.
Yahoo!Hacksshowsyouhowtouse,expand,personalize,andtweakYahoo!inwaysyou
neverdreamedpossible.You'lllearnhowto:
Fine-tunesearchquerieswithkeywordshortcutsandadvancedsyntax
ManageandcustomizeYahoo!Mail,usingitasyouruniversalemailclienttoaccess
allyourotheraccounts
ExploreyoursocialnetworkswithYahoo!360,bloggingyourlife,keepingupwith
friends,andmakingnewcontacts
Store,sort,blog,feed,track,andotherwisesharephotoswithFlickrandRSS
MakeMyYahoo!yourYahoo!,andpersonalizeYahoo!'smanyproperties
RollyourownYahoo!applicationswithYahoo!newWebServicesAPIandPerl,PHP,
Java,Python,Ruby,ortheprogramminglanguageofyourchoice
Visualizesearchresultsandtopics,mashupimagesfromaroundtheWeb,andremix
otherwebcontent
List(orhide)yoursitewithYahoo!,andintegrateYahoo!Groups,Messenger,
contextualsearch(Y!Q),orotherYahoo!features
Whetheryouwanttobecomeapowersearcher,newsmonger,supershopper,or
innovativewebdeveloper,Yahoo!Hacksprovidesthetoolstotakeyoufurtherthanyou
everthoughtpossible.
Yahoo!Hacks
ByPaulBausch
...............................................
Publisher:O'Reilly
PubDate:October2005
ISBN:0-596-00945-3
Pages:489
TableofContents|Index
Copyright
Credits
AbouttheAuthor
Contributors
Acknowledgments
Preface
WhyYahoo!Hacks?
HowtoUseThisBook
HowtoRuntheHacks
HowThisBookIsOrganized
ConventionsUsedinThisBook
UsingCodeExamples
SafariEnabled
HowtoContactUs
GotaHack?
Chapter1.Search
Section1.1.Hacks122:Introduction
Hack1.Fine-TuneYahoo!WebSearchQueries
Hack2.SaveTimewithSearchShortcuts
Hack3.CreateaYahoo!ID
Hack4.SetPersistentYahoo!SearchPreferences
Hack5.AssembleAdvancedSearchQueries
Hack6.TranslateAnyPagewithYahoo!
Hack7.Personalize,Track,andSharetheWeb
Hack8.PrefetchYahoo!SearchResults
Hack9.CompareYahoo!andGoogleSearchResults
Hack10.FindContentYouCanReuseLegally
Hack11.FindVideofromAcrosstheWeb
Hack12.StreamlineBrowsingwiththeYahoo!Toolbar
Hack13.CustomizetheFirefoxQuickSearchBox
Hack14.SpotTrendswithYahoo!Buzz
Hack15.FindHotTechnologiesattheBuzzGame
Hack16.TameLongYahoo!URLs
Hack17.OptOutofAdvertiserCookies
Hack18.TrackNewsAboutYahoo!
Hack19.SpidertheYahoo!Catalog
Hack20.BrowsetheYahoo!Directory
Hack21.TrackAdditionstoYahoo!
Hack22.Yahoo!DirectoryMindshareinGoogle
Chapter2.Services
Section2.1.Hacks2350:Introduction
Hack23.TrackYourInvestments
Hack24.BuildYourOwnStockUpdateEmail
Hack25.DownloadFinancialDataUsingExcelWebQueries
Hack26.ConvertCurrencieswithOneClick
Hack27.DotheMathwithYahoo!Calculators
Hack28.AddaYahoo!BookmarkwithOneClick
Hack29.ImportExistingBookmarksintoYahoo!Bookmarks
Hack30.OpenYahoo!BookmarksinaSidebar
Hack31.PublishYourYahoo!Bookmarks
Hack32.TracktheMedia'sAttentionSpanoverTime
Hack33.MonitortheNewswithRSS
Hack34.PersonalizeMyYahoo!
Hack35.TrackYourFavoriteSiteswithRSS
Hack36.AddaFeedtoMyYahoo!withaRight-Click
Hack37.BuildYourOwnNewsCrawler
Hack38.ReplaceYourPhoneBookwithYahoo!
Hack39.MonitorYourCommute
Hack40.GettheFactsatYahoo!Reference
Hack41.FindandRateMovies
Hack42.SubscribetoMovieShowtimes
Hack43.ViewMovieListsonYourCellPhone
Hack44.PlanYourTVViewing
Hack45.CreateaTVWatchList
Hack46.DevelopandShareaTripItinerary
Hack47.ShopIntelligently
Hack48.VisualizeYourMusicCollection
Hack49.TakeYahoo!ontheGo
Hack50.StayConnectedwithYahoo!Alerts
Chapter3.Communicating
Section3.1.Hacks5167:Introduction
Hack51.NavigateYahoo!Mail
Hack52.ManageYahoo!Mail
Hack53.CreateYahoo!MailMacros
Hack54.ReadAllYourEmailinOnePlace
Hack55.ReadYahoo!MailinYourPreferredEmailClient
Hack56.ManageandShareYourSchedule
Hack57.AddContactstoYourYahoo!AddressBook
Hack58.MapYahoo!AddressBookContacts
Hack59.Discuss,Share,andCollaboratewithOthers
Hack60.ArchiveYahoo!GroupsMessageswithyahoo2mbox
Hack61.ExploreYourSocialNetworks
Hack62.ImportanExistingBlogrolltoYahoo!360
Hack63.AddanAPItoYourYahoo!360Blog
Hack64.CreateaYahoo!Avatar
Hack65.AddaContentTabtoYahoo!Messenger
Hack66.SendInstantMessagesBeyondYahoo!
Hack67.Store,Sort,andShareYourPhotos
Chapter4.WebServices
Section4.1.Hacks6876:Introduction
Section4.2.
Hack68.ProgramYahoo!withPerl
Hack69.ProgramYahoo!withPHP5
Hack70.ProgramYahoo!withPython
Hack71.ProgramYahoo!withVBScript
Hack72.ProgramYahoo!withColdFusion
Hack73.ProgramYahoo!withXSLT
Hack74.ProgramYahoo!withJava
Hack75.ProgramYahoo!withRuby
Hack76.ProgramYahoo!withREBOL
Chapter5.Applications
Section5.1.Hacks7791:Introduction
Hack77.VisualizeYahoo!WebSearchResults
Hack78.FindLinkstoAnyWebSite
Hack79.ImportYahoo!LocalListingsintoYourAddressBook
Hack80.CreateaYahoo!LocalMIDlet
Hack81.ImportYahoo!LocalListingsintoExcel
Hack82.SpellWordswithYahoo!Images
Hack83.RandomizeYourWindowsDesktopBackground
Hack84.RandomizeYourMacDesktopBackground
Hack85.MashUpImagesfromAroundtheWeb
Hack86.IllustrateAnyWebSite
Hack87.AddLinkstoaBlockofTextAutomatically
Hack88.VisualizeNewsTopicsasTags
Hack89.GetRelatedTermsInstantlywithAjax
Hack90.ComparethePopularityofRelatedSearchTerms
Hack91.PlotMultiplePointsonYourOwnMap
Chapter6.Webmastering
Section6.1.Hacks92100:Introduction
Hack92.GetYourSiteListedatYahoo!
Hack93.HidePartofYourWebSitefromYahoo!
Hack94.SearchYourWebSitewithYahoo!
Hack95.AddPresencetoYourWebSite
Hack96.SyndicateRichMedia
Hack97.AddContextualSearchtoYourBlog
Hack98.PostPhotostoYourBlog
Hack99.FeedYourLatestPhotostoYourWebSite
Hack100.DisplayMessagesfromaYahoo!GrouponYourWebSite
Colophon
Index
Copyright©2006O'ReillyMedia,Inc.Allrightsreserved.
PrintedintheUnitedStatesofAmerica.
PublishedbyO'ReillyMedia,Inc.,1005GravensteinHighway
North,Sebastopol,CA95472.
O'Reillybooksmaybepurchasedforeducational,business,or
salespromotionaluse.Onlineeditionsarealsoavailablefor
mosttitles(safari.oreilly.com).Formoreinformation,contact
ourcorporate/institutionalsalesdepartment:(800)998-9938or
Table
Editor:
BrianSawyer
ProductionEditor:
A.J.Fox
SeriesEditor:
RaelDornfest
CoverDesigner:
HannaDyer
ExecutiveEditor:
DaleDougherty
InteriorDesigner:
DavidFutato
PrintingHistory:
October2005:
FirstEdition.
NutshellHandbook,theNutshellHandbooklogo,andthe
O'ReillylogoareregisteredtrademarksofO'ReillyMedia,Inc.
TheHacksseriesdesignations,Yahoo!Hacks,theimageof
bootsandspurs,andrelatedtradedressaretrademarksof
O'ReillyMedia,Inc.
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andO'ReillyMedia,Inc.,
wasawareofatrademarkclaim,thedesignationshavebeen
printedincapsorinitialcaps.
Whileeveryprecautionhasbeentakeninthepreparationofthis
book,thepublisherandauthorassumenoresponsibilityfor
errorsoromissions,orfordamagesresultingfromtheuseof
theinformationcontainedherein.
Smallprint:Thetechnologiesdiscussedinthispublication,the
limitationsonthesetechnologiesthattechnologyandcontent
ownersseektoimpose,andthelawsactuallylimitingtheuseof
thesetechnologiesareconstantlychanging.Thus,someofthe
hacksdescribedinthispublicationmaynotwork,maycause
unintendedharmtosystemsonwhichtheyareused,ormay
notbeconsistentwithapplicableuseragreements.Youruseof
thesehacksisatyourownrisk,andO'ReillyMedia,Inc.
disclaimsresponsibilityforanydamageorexpenseresulting
fromtheiruse.Inanyevent,youshouldtakecarethatyouruse
ofthesehacksdoesnotviolateanyapplicablelaws,including
copyrightlaws.
ThisbookusesRepKover™,adurableandflexiblelay-flat
binding.
ISBN:0-596-00945-3
[C]
Credits
AbouttheAuthor
Contributors
Acknowledgments
AbouttheAuthor
PaulBauschisanindependentwebdeveloperlivingin
Corvallis,Oregon.Whenhe'snothackingtogetherweb
applications,he'swritingabouthackingtogetherweb
applications.HeputtogetherAmazonHacksforO'Reillyin
2003.Paulalsohelpedcreatethepopularweblogapplication
Blogger(),cowroteabookabout
weblogscalledWeBlog:PublishingOnlinewithWeblogs
(Wiley),andmaintainsadirectoryofOregonweblogscalled
ORblogs().Whenhe'snotworkingona
book,Paulpoststhoughtsandphotostohispersonalweblog,
onfocus().
Contributors
Thefollowingpeoplecontributedtheirhacks,writing,and
inspirationtothisbook:
JacekArtymiak()isafreelance
consultant,developer,andwriter.He'sbeenprogramming
computerssince1986,startingwiththeSinclairZX
Spectrum.Hisinterestsincludenetworksecurity,computer
graphicsandanimation,andmultimedia.Jaceklivesin
Lublin,Poland,withhiswife,Gosia,andcanbereachedat
BonnieBiaforeistheauthorofseveralbooksaboutpersonal
finance,investing,andprojectmanagement.Asan
engineer,she'stenaciouslyattentivetodetailanddigests
tantalizingmorselsabouteverytopicsheapproaches.Her
sicksenseofhumorturnssubjectsthataredroolinducingin
otherbooksintoentertaining,easyreading.Herbookthe
NAICStockSelectionHandbookwonmajorawardsfrom
boththeSocietyofTechnicalCommunicationandAPEX
AwardsforPublicationExcellence,butshecherishesthe
ravesshe'sreceivedfrombeginninginvestorsmostofall.
SheisalsotheauthorofOnlineInvestingHacks(O'Reilly)
andQuickBooks2005:TheMissingManual(O'Reilly).
BonniewritesamonthlycolumncalledWebWatchforBetter
Investingmagazineandisaregularcontributorto
WomensWallStreet.com.Asaconsultant,shemanages
projectsforclientsandwinsaccoladesforherabilitytoherd
cats.Whennotchainedtohercomputer,shehikesinthe
mountainswithherdogs,cooksgourmetmeals,and
practicessayingnotoadditionalworkassignments.Youcan
learnmoreatBonnie'swebsite,
,oremailherat
TaraCalishainistheeditorofResearchBuzz
(),aweeklynewsletteron
Internetsearchingandonlineinformationresources.She's
alsoaregularcolumnistforSearchermagazine.She'sbeen
writingaboutsearchenginesandsearchingsince1996;her
recentbooksincludeGoogleHacks(O'Reilly)andWeb
SearchGarage(O'Reilly).
KevinHemenway(),betterknown
asMorbusIff,isthecreatorofDisobey.com,whichbills
itselfas"contentforthediscontented."Publisher,developer,
andwriterofmorehomecookingthanyoucouldever
imagine(likethepopularopensourcedsyndicatedreader
AmphetaDesk,thebest-keptgamingsecret
Gamegrene.com,thepopularGhostSitesandNonsense
Network,thegiggle-inducingarticlesattheO'Reilly
Network,afewpiecesatApple'sInternetDevelopersite,
etc.),he'sanardentsupporterofcloning,merelysohecan
getmoreworkdone.HecookswithaFryPanofIntellect
+2andlivesinConcord,NewHampshire.
RyanKennedyisasoftwareengineeratYahoo!,workingon
Yahoo!Mail.Inhissparetime,hemaintainstheYahoo!Java
SearchSDK.
PhilippLenssenlivesinStuttgart,Germany,whereheblogs
aboutGoogle,worksasaprogrammeronanautomobile
website,andeatsspicyThaifoodwithhisgirlfriend.He
likestoponderfuturetechnologyandjumponany
technologybandwagonthatseemsworthwhile,especiallyall
theAPIsthatmakeadeveloper'slifethatmucheasier.
Philipp'sdailymusingscanbefoundat.
MikelMaronisanindependentsoftwaredeveloperand
ecologist.Hehasbuiltseveralgeographic-orientedprojects
aroundtheworldKitmappingpackage,includingWorldasa
Blogandmapufacture.Previously,heleddevelopmentof
MyYahoo!inthepre-RSSdays.Mikelwasawardeda
master'sdegreefromtheUniversityofSussexforbuildinga
simulationoftheevolutionofcomplexityinfoodwebs.
OriginallyfromCalifornia,Mikelispresentlybasedmostlyin
Brighton,UnitedKingdom,withhiswife,Anna.Linksto
variousthingscanbefoundat.
DeepakNadigisanentrepreneurandhashelpedbuild
innovativeandusefulproductsfor14years.Heiscurrently
takingabreakaftercofoundingandsellingCovigna,a
pioneerinContractLifecycleManagement.
ToddOgasawarafocusesonMobileWorkforceandMobile
Lifestyletechnology,payingspecialattentiontothe
MicrosoftWindowsMobileplatform(PocketPCand
Smartphone).Microsofthasrecognizedhisdemonstrated
practicalexpertiseandwillingnesstosharehisexperience
byrecognizinghimasaMicrosoftMostValuable
Professional(MVP)intheMobileDevicescategorysince
2000.Hisothertechnologyfocusisintheefforttobring
commercial(especiallyMicrosoft-related)productsand
GNU/OpenSourcesoftwaretogetherinasynergisticand
productiveway.Toddhaswrittenseveralarticlesabout
mobiledevices,digitalcameras,andtheAppleMacMinifor
theO'ReillyNetwork.Hepreviouslyworkedasatechnology
analystforGTE/Verizon.Healsoservedasthecontracted
forummanagerfortheMSN.com(andlaterZDNet)
TelephonyForumandWindowsCEForum.Morerecently,he
hasservedastheeGovernmentteamleaderfortheStateof
Hawaii.YoucanfindhisMobileWorkforceandLifestyle
commentaryat.Youcanlearn
moreaboutEccentricTechnologyat
.YoucanreachToddbyemail
at
MarkPilgrimisanaccessibilityarchitectbyday.Bynight,he
isahusbandandfatherwholivesinNorthCarolinawithhis
wife,hisson,andhisdog.Markspendshiscopiousfree
timesunbathing,skydiving,andreadingImmanuelKant's
CritiqueofPureReasonintheoriginalKlingon.Hecanbe
foundstirringuptroubleat.
PremshreePillaiisageekworkingatYahoo!.HelovesRuby,
beer,andclassicrock.Heblogsat
/>EricRiesiscurrentlyCTOofIMVU,astartupcreating3-D,
avatarbasedinstantmessaging.Ericalsoserves,ina
volunteercapacity,asCTOoftheTaprootFoundation.
Previously,hewasseniorsoftwareengineeratThereand
cofounderandCTOofCatalystRecruiting.Heisauthorof
severalfreesoftwareprojects,mostrecentlythepeer-topeerRPCsystemKenosis,andcoauthorofseveralbooks,
includingTheBlackArtofJavaGameProgrammingand
MasteringJava.
AlanTaylorhasbeenawebdeveloperforover10yearsand
hasworkedforMonster.com,MSNBC.com,and
Amazon.com.Hebuildswebprojects(suchasAmazon
Light;andwebhacks/toyson
anirregularbasis,mostofwhichcanbefoundat
.AlanbelievesthatopenAPIsareyour
friendsandarepositivelythebesttrendontheInternetin
years.
Acknowledgments
Tomywife,Shawnde,thanksforthecontinuousfeedbackand
frontlineediting,andforcheerfullydiscussingYahoo!during
breakfast,lunch,dinner,andeverysparemomentinbetween.
ManythanksgotoBrianSawyerforprovidingdirectionand
encouragement,andforfine-tuningthetext.
ThankstotecheditorSteveChampeonfortestingcode,doublecheckingfacts,andaddingimportantpointstothetechnical
details.
ThankstoMorbusIfffortakingmyPerltotaskandsimplifying
theconfusingbits.
Finally,thankstoeveryoneatYahoo!whocontributedtipsand
hackideas,includingVijayAnisetti,StigSætherBakken,Dave
Brown,AuroraCasanova,DavidDueblin,JenniferDulski,Marcus
Foster,DavidHall,JasonB.Silverstein,JeremyZawodny,and
manyanonymousYahoos.ThanksalsotoChrisKalaboukisand
BernardMangoldatYahoo!Researchforlendingahand.
Preface
Yahoo!isanimpressiveexampleofwhatcanhappenwhena
hobbytakesonalifeofitsown.In1994,JerryYangandDavid
Filobeganpublishingapersonallistofsitestheyfound
interestingontheemergingWorldWideWeb.As"Jerry'sGuide
totheWorldWideWeb"grewlarger,thetwoStanfordgrad
studentsbeganorganizingthesitesintocategories,andthe
basicstructureoftoday'sYahoo!Directorywasborn.Bylate
1994,theychosetorenametheirdirectoryaftertheword
yahoobecauseitsoriginaldefinitiondescribingacrude,rude
personappealedtothepair'ssubversivenatures.(Andastrue
computergeeks,theyturnedYahoo!intoanacronymforYet
AnotherHierarchicalOfficiousOracle.)FigureP-1isalookat
theYahoo!homepagefromDecember1994.
Yahoo!looksverydifferenttoday.FigureP-2showsthemore
familiarYahoo!homepageof2005.
ThoughthetwoYahoo!homepageslookradicallydifferent,the
originalideaoftamingthechaosoftheWorldWideWeband
makingitaccessibletoawideraudienceremains.Accordingto
theirvisionstatement,Yahoo!wants"toenablepeopletofind,
use,share,andexpandallhumanknowledge."Thegoalof
furtheringthisvision,nicknamedFUSE(for"find,use,share,
andexpand"),canbefoundineveryacquisitionYahoo!makes
andeveryproductYahoo!releases.Yahoo!haslocalized
versionsofitsofferingsindozensofcountries,andtheYahoo!
brandisrecognizedaroundtheworld.Overthepast10years,
Yahoo!hasbecomemuchmorethanaguidetotheWeb;
Yahoo!isaplatformforvisualizingandconnectingwiththe
world.
ManyYahoo!featuresarefamiliartoanyonewhousestheWeb.
MillionsofpeopleuseYahoo!Searchtofindinformationonthe
Web.MillionsmoreuseYahoo!Groupstoshareinformationand
collaborateonprojects.AndstillmoreuseYahoo!Mailevery
daytostayintouchwithfriends,family,andcoworkers.And
Yahoo!iscontinuallyaddingproductsandfeaturestorealizeits
vision.
FigureI-1.Yahoo!in1994
Overthepastyear,theFUSEphilosophyhasbeenadistinct
featureofYahoo!'snewestservices.InFebruary2005,Yahoo!
launchedYahoo!WebServices,allowingoutsidedevelopersto
use,share,andexpandYahoo!features.InMarch2005,Yahoo!
launchedYahoo!360,awayforpeopletosharethoughtsand
informationwithfriendsandfamily,whileexpandinganetwork
offriends.InApril2005,Yahoo!introducedMyWeb,awayto
saveandsharesearchresultswhilecreatingyourownpersonal
categorizeddirectoryoftheWeb.
ThisbookaimstohelpyouFUSEYahoo!featuresandservices
byintroducingyoutolittle-knowncornersofYahoo!,by
reintroducingyoutofamiliarYahoo!services,andbyshowing
youexamplesofthemanywayspeopleareexpandingYahoo!
ontheirown.Thoughthehacksmightbecrudeandrudeat
times,they'rewritteninthesamespiritofsharingsomething
interestingthatinspiredthecreationofYahoo!inthefirstplace.
FigureI-2.Yahoo!in2005
WhyYahoo!Hacks?
Thetermhackinghasabadreputationinthepress.Theyuseit
torefertosomeonewhobreaksintosystemsorwreakshavoc
withcomputersastheirweapon.Amongpeoplewhowritecode,
though,thetermhackreferstoaquick-and-dirtysolutiontoa
problem,oracleverwaytogetsomethingdone.Andtheterm
hackeristakenverymuchasacompliment,referringto
someoneasbeingcreative,havingthetechnicalchopstoget
thingsdone.TheHacksseriesisanattempttoreclaimthe
word,documentthegoodwayspeoplearehacking,andpass
thehackerethicofcreativeparticipationontotheuninitiated.
Seeinghowothersapproachsystemsandproblemsisoftenthe
quickestwaytolearnaboutanewtechnology.
WhileYahoo!itselfhasbeenaroundforover10years,itis
releasingnewapplications,websites,andsoftwareatablinding
pace.Thisbookisn'tintendedtocatalogeverythingYahoo!
offers,butrathertointroducenewtechnologies,suchasYahoo!
WebServices,whileshowingnovelwaystouseperennial
offeringslikeYahoo!Search,Yahoo!Mail,andYahoo!Groups.
Throughtheyears,developershavescraped,poked,and
proddedeverycornerofYahoo!fortheirownuses,andthe
releaseofYahoo!WebServicesislikeawelcomematbeingput
outforawideraudienceofwould-behackers.Thisbookintends
toshowyouwhat'spossiblewhenyouviewYahoo!asa
platformandinspireyourinnerhackertotakeanewlookat
Yahoo!.
HowtoUseThisBook
Youcanreadthisbookfromcovertocoverifyoulike,buteach
hackstandsonitsown,sofeelfreetobrowseandjumptothe
differentsectionsthatinterestyoumost.Ifthere'sa
prerequisiteyouneedtoknowabout,across-referencewill
guideyoutotherighthack.
HowtoRuntheHacks
Theprogrammatichacksinthisbookruneitheronthe
commandline(that'sTerminalforMacOSXfolk,DOS
commandwindowforWindowsusers)orasCGI(that's
"commongatewayinterface")scriptsdynamicpageslivingon
yourwebsite,accessedthroughyourwebbrowser.
Command-LineScripts
Runningahackonthecommandlineinvariablyinvolvesthe
followingsteps:
1. Typetheprogramintoagarden-varietytexteditor:Notepad
onWindows,TextEditonMacOSX,viorEmacson
Unix/Linux,oranythingelseofthesort.Savethefileas
directedusuallyasscriptname.pl(theplbitstandsforPerl,
thepredominantprogramminglanguageusedinYahoo!
Hacks).
Alternately,youcandownloadthecodeforallofthehacks
onlineatwhere
thereisaZIParchivecontainingindividualscriptssavedas
textfiles.
2. Gettothecommandlineonyourcomputerorremote
server.InMacOSX,launchtheTerminal(Applications
Utilities Terminal).InWindows,clicktheStartbutton,
selectRun…,typecommand,andhittheEnter/Returnkeyon
yourkeyboard.InUnix…well,we'lljustassumeyouknow
howtogettothecommandline.
3. Navigatetowhereyousavedthescriptathand.Thisvaries
fromoperatingsystemtooperatingsystem,butusually
involvessomethinglikecd~/Desktop(that'syourDesktopon
theMac).
4. Invokethescriptbyrunningtheprogramminglanguage's
interpreter(e.g.,Perl)andfeedingitthescript(e.g.,
scriptname.pl)likeso:
$perlscriptname.pl
Mostoften,you'llalsoneedtopassalongsome
parametersyoursearchquery,thenumberofresultsyou'd
like,andsoforth.Simplydroptheminafterthescript
name,enclosingtheminquotesifthey'remorethanone
wordoriftheyincludeanoddcharacterorthree:
$perlscriptname.pl'"muchadoaboutnothing"scri
Theresultsofyourscriptarealmostalwayssentstraight
backtothecommand-linewindowinwhichyou'reworking,
likeso:
$perlscriptname.pl'"muchadoaboutnothing"scri
1."Amazon.com:Books:MuchAdoAboutNothing:Scree
www.amazon.com/exec/obidos/tg/detail/-/0393311112?v=
2."MuchAdoAboutNothingScript"[na
about_nothing_script.asp]
…
Theelllpsis(…)bitsignifiesthatwe'vecutoff
theoutputforbrevity'ssake.
Tostopoutputscrollingoffyourscreenfasterthanyoucan
readit,onmostsystemsyoucanpipe(read:redirect)the
outputtoalittleprogramcalledmore:
$perlscriptname.pl|more
HittheEnter/Returnkeyonyourkeyboardtoscrollthrough
linebyline,orthespacebartoleapthroughpagebypage.
You'llalsosometimeswanttodirectoutputtoafilefor
safekeeping,importingintoyourspreadsheetapplication,or
displayingonyourwebsite.Thisisaseasyas:
$perlscriptname.pl>output_filename.txt
Andtopoursomeinputintoyourscriptfromafile,simply
dotheopposite:
$perlscriptname.pl
Don'tworryifyoucan'trememberallofthis;eachcommandlinehackhasa"RunningtheHack"sectionthatshowsyoujust
howit'sdone.
CGIScripts
CGIscriptsprogramsthatrunonyourwebsiteandproduce
pagesdynamicallyarealittlemorecomplicatedifyou'renot
usedtothem.Whilefundamentallythey'rethesamesortsof
scriptsasthoserunonthecommandline,theyaremore
troublesomebecausesetupsvarysowidely.Youmightbe
runningyourownserver,yourwebsitemightbehostedonan
Internetserviceprovider's(ISP's)server,yourcontentmight
liveonacorporateintranetserveroranythinginbetween.
Sincegoingthrougheverypossibilityisbeyondthescopeofthis
(orany)book,youshouldcheckyourISP'sknowledgebase,or
calltheISP'stechnicalsupportdepartment,oraskyourlocal
systemadministratorforhelp.
Generally,though,themethodologyisthesame:
1. Typetheprogramintoagarden-varietytexteditor:
NotepadonWindows,TextEditonMacOSX,viorEmacson
Unix/Linux,oranythingelseofthesort.Savethefileas
directedusuallyasscriptname.cgi(thecgibitrevealsthat
you'redealingwithaCGIscript).
Alternately,youcandownloadthecodeforallofthehacks
onlineatwhere
thereisaZIParchivecontainingindividualscriptssavedas
textfiles.
2. Movethescriptovertowhereveryourwebsitelives.You
shouldhavesomedirectoryonaserversomewherein
whichallofyourwebpages(allthose.htmlfiles)and
images(endingin.jpg,.gif,etc.)live.Withinthisdirectory,
you'llprobablyseesomethingcalledacgi-bindirectory:this
iswhereaCGIscriptmustusuallyliveinorderforthe
servertorunthescript(ratherthanjustdisplayingthe
script'stextinyourwebbrowser)whenyouvisititsURL.
3. Youusuallyneedto"bless"CGIscriptsasexecutabletobe
runratherthandisplayed.Justhowyoudothisdependson
theoperatingsystemofyourserver.Ifyou'reona
Unix/LinuxorMacOSXsystem,thisusuallyentailstyping
thefollowingonthecommandline: