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) 编辑 收藏 举报 刷新评论刷新页面返回顶部
延伸文章資訊
- 1How to execute shell command in a perl script? - 博客园
https://stackoverflow.com/questions/3200801/how-can-i-call-a-shell-command-in-my-perl-script/2115...
- 2Recipe 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...
- 3An Easy Way to Access the OS System Command from Perl
Perl programs run on many different platforms such as Windows, Mac OS and the various UNIX ... Pe...
- 4Run bash script in Perl program - BOL
Run bash script in Perl program ! · 2. exec””. syntax: exec "command"; · 3. Backticks “ or qx//. ...
- 5Running external programs from Perl with system
Shell expansion. Let's say you have a program called checkfiles that can check the files listed o...