Run bash script in Perl program - BOL

文章推薦指數: 80 %
投票人數:10人

Run bash script in Perl program ! · 2. exec””. syntax: exec "command"; · 3. Backticks “ or qx//. syntax: `command`;. syntax: qx/command/; · 4. IPC ... BOL Login Usernameoremail Password Rememberme Register Lostpassword ActivityNewsOpportunityResearchLabsQuestionsPagesDiscussionMoreBioScriptsBlogsBookmarksFilesFunGroupsPollsTheWireTrystVideos NeelamJha@neelam NeelamJhaBioinformaticsBeginner BlogsBookmarksFilesFunNewsOpportunitypostPagesPollsResearchLabspostTrystVideosWirepostsTagcloudBioinformatics,tools,virus,ComputationalBiology,Education,Study,CV,Jobs,Prepare,University,Degree,DBT,CREST,TWAS,Innovation,TATA,Ramalingaswamy,Researchers,Indian,Opportunities,Fellowship,Letter,motivation,applicants,motif,discovery,protein,dna,Coronavirus,COVID,2019,Testing,Sites,India,Pandemic,Module,awk,Script,Bash,Perl,list,REST,API,blast,Genome,Programming,elgg,host,ubuntu,linuxAllsitetagsOurSponsors DownloadBioinformaticsOnline(BOL)Appsinyourchromebrowser. BlogsNeelamJhaRunbashscriptinPerlprogram! RunbashscriptinPerlprogram! NeelamJha@neelam PublicByNeelamJha603daysago PerlBashScriptawkModule BioPerlisacompilationofPerlmodulesthatcanbeusedtobuildbioinformatics-relatedPerlscripts.Itisused,forexample,inthedevelopmentofsourcecodes,standalonesoftware/tools,andalgorithmsinbioinformaticsprogrammes.Differentmodulesareeasytoinstalandinclude,makingiteasiertoperformdifferentfunctions.DespitethefactthatPythoniscommonlyfavouredoverPerl,somebioinformaticssoftware,suchasthestandaloneversionof'alienomics',iswritteninPerl.Oftenit'samajorproblemforbeginnerstoexecutecertainUnix/shellcommandsinPerlscript,soit'shardtodeterminewhichfeatureisuniquetoasituation.Perlprovidesvariousfeaturesandoperatorsfortheexecutionofexternalcommands(describedasfollows),whichareuniqueintheirownway. Theyvaryslightlyfromoneanother,makingitdifficultforPerlbeginnerstochoosebetweenthem. 1.IPC::Open2Moreathttps://bioinformaticsonline.com/snippets/view/42919/perl-ipcopen2-module2.exec”” syntax: exec"command";It'saPerlfunction(perlfunc)thatexecutesacommandbutneverreturns,similartoafunction'sreturnstatement.Whilerunningthecommand,itkeepsprocessingthescriptanddoesnotwaituntilitfinishesfirst,returnsfalsewhenthecommandisnotfound,butneverreturnstrue.3.Backticks“orqx//syntax: `command`;syntax: qx/command/;It'saPerloperator(perlop)thatexecutesacommandandthenresumesthePerlscriptoncethecommandhasended,butthereturnvalueisthecommand'sSTDOUT.4.IPC::Open3syntax: $output= open3(\*CHLD_IN,\*CHLD_OUT,\*CHLD_ERR, 'commandarg1arg2','optarg',...);ItisverysimilartoIPC::Open2withthecapabilitytocaptureallthreefilehandlesoftheprocess,i.e.,STDIN,STDOUT,andSTDERR.Itcanalsobeusedwithorwithouttheshell.Youcanreadaboutitmoreinthedocumentation:IPC::Open3.$output=open3(my$out, my$in,'commandarg1arg2');ORwithoutusingtheshell$output=open3(my$out, my$in,'command','arg1','arg2');5.a2psyntax: a2p[options][awkscript]ThereisaPerlutilityknownasa2pwhichtranslatesawkcommandtoPerl.IttakesawkscriptasinputandgeneratesacomparablePerlscriptastheoutput.Suppose,youwanttoexecutethefollowingawkstatementawk'{$1="";$2="";print}'f1.txtThisstatementgiveserrorsometimesevenafterescapingthevariables(\$1,\$2)butbyusinga2pitcanbeeasilyconvertedtoPerlscript:Forfurtherinformation,youcanreadit’sdocumentation:a2pMorehelpathttps://bioinformaticsonline.com/snippets/view/42920/perl-script-to-run-awk-inside-perl6.system()syntax: system("command");ItisalsoaPerlfunction(perlfunc)thatexecutesacommandandwaitsforittogetfinishedfirstandthenresumethePerlscript.Thereturnvalueistheexitstatusofthecommand.Itcanbecalledintwoways:system("commandarg1arg2");ORsystem("command","arg1","arg2");HELPHerearesomeusefulPerlcheatsheetsthatcanbeusedasaquickreferenceguide.-- https://www.pcwdld.com/perl-cheat-sheet RelateditemsViewall82relateditems BenchmarkingPerlModule!1519daysagoRahulNayaktoplevelpage AdvancedBash-ScriptingGuide2438daysagoJitbookmark PerlModuleInstallation3389daysagoJitendraNarayanbookmark ReverseComplementProblemSolvedwithPerl2692daysagoJitPages ClumpFindingProblemSolvedwithPerl2692daysagoJitPages GenomeBrowser:GBrowse2437daysagoJitbookmark irishgrid:IrishGridMappingSystem2857daysagoJitbookmark RestrictionDigest:ApowerfulPerlmoduleforsimulatinggenomicrestrictiondigests1593daysagoNeelamJhabookmark AboutTermsPrivacy



請為這篇文章評分?