How to execute shell command in a perl script? - 博客园
文章推薦指數: 80 %
https://stackoverflow.com/questions/3200801/how-can-i-call-a-shell-command-in-my-perl-script/2115303. 首页 新闻 博问 专区 闪存 班级 我的博客 我的园子 账号设置 简洁模式... 退出登录 注册 登录 Howtoexecuteshellcommandinaperlscript? https://stackoverflow.com/questions/3200801/how-can-i-call-a-shell-command-in-my-perl-script/21153038 1.用`` 不显示执行结果 my$files=`ls-la` —capturestheoutputofthecommandin $files 2.用systemorexec 不显示执行结果 system"touch~/foo" —ifyoudon'twanttocapturethecommand'soutput exec"vim~/foo" —ifyoudon'twanttoreturntothescriptafterexecutingthecommand 3.用open适合命令里有管道符时 open(my$file,'|-',"grepfoo");print$file"foo\nbar" —ifyouwanttopipeinputinto 好的心态+正确的方法 postedon 2021-11-2315:37 guolongnv 阅读(15) 评论(0) 编辑 收藏 举报 刷新评论刷新页面返回顶部
延伸文章資訊
- 1Executing Commands Without Shell Escapes (Perl Cookbook ...
Because Perl was designed as a glue language, it's easy to use it to call other programs—too easy...
- 2How to execute Unix/shell commands in a Perl script?
How to execute Unix/shell commands in a Perl script? · 1. exec”” · 2. system() · 3. Backticks “ o...
- 3Recipe 19.6. Executing Commands Without Shell Escapes
You need to use a user's input as part of a command, but you don't want to allow the user to make...
- 4Running external programs from Perl with system
Shell expansion. Let's say you have a program called checkfiles that can check the files listed o...
- 5How can I call a shell command in my Perl script?
How to run a shell script from a Perl program. 1. Using system system($command, @arguments);. For...