Perl批量执行Linux安装程序和脚本
2013-01-29 00:03
477 查看
转载http://www.oschina.net/code/snippet_222150_7901
#!/usr/bin/perl #use Cwd; sub ExecuteAll(){ local($dir) = @_; opendir(DIR,"$dir"|| die "can't open $dir"); local @files =readdir(DIR); closedir(DIR); for $file (@files){ next if($file=~m/\.$/ || $file =~m/\.\.$/); if ($file =~/\.(sh)$/i){ system "xterm -e bash \"$dir\/$file\""; } elsif($file =~/\.(bin|run|bundle)$/i){ system "xterm -e \"$dir\/$file\""; } elsif($file =~/\.(pl)$/i && $file != $0){ system "xterm -e perl \"$dir\/$file\""; } elsif($file =~/\.(class)$/i){ $file =~ s/(.*)\.(.*)/$1/; system "xterm -e java \"$dir\/$file\""; } elsif($file =~/\.(rpm)$/i){ system "xterm -e rpm -ivh \"$dir\/$file\""; } elsif($file =~/\.(rb)$/i){ system "xterm -e ruby \"$dir\/$file\""; } elsif($file =~/\.(py)$/i){ system "xterm -e python \"$dir\/$file\""; } elsif($file =~/\.(jar)$/i){ system "xterm -e java -jar \"$dir\/$file\""; } elsif(-d "$dir/$file"){ ExecuteAll("$dir/$file" ); } } } &ExecuteAll(getcwd);
相关文章推荐
- Perl脚本打包为独立执行程序
- 从Linux程序中执行shell(程序、脚本)并获得输出结果(转)
- linux 通过sh脚本执行java程序-(1)
- 从Linux程序中执行shell(程序、脚本)并获得输出结果
- linux下通过sh脚本执行java工程程序
- Linux(CentOS)下把python脚本转化成可执行程序
- 在Linux系统下安装Perl脚本语言
- 从Linux程序中执行shell(程序、脚本)并获得输出结果
- Linux下,将python安装在个人目录下,配置环境变量,以及解决crontab执行python脚本会出错的问题
- 从Linux程序中执行shell(程序、脚本)并获得输出结果
- 简易登录,批量执行命令,批量copy文件shell脚本【Linux运维之道之脚本案例】
- 从Linux程序中执行shell(程序、脚本)并获得输出结果(转)
- linux 下面程序自动安装脚本
- Shell脚本执行hive语句 | hive以日期建立分区表 | linux schedule程序 | sed替换文件字符串 | shell判断hdfs文件目录是否存在
- 制作Linux下程序安装包——使用脚本打包bin、run等安装包
- 关于linux中执行脚本或程序时指定的路径
- 制作Linux下程序安装包——使用脚本打包bin、run等安装包
- LINUX下做JAVA程序启动脚本(优化可执行Raspbian Debian9U1)
- linux .sh文件,简单命令执行重启scrapy 程序(批量kill pid、后台运行程序)
- 网络游戏服务器开发::学习了两天python写了一个linux下自动安装程序的脚本