Perl批量执行Linux安装程序和脚本

Perl批量执行Linux安装程序和脚本,第1张

概述转载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); c

转载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 != ){			system "xterm -e perl \"$dir\/$file\"";		}		elsif($file =~/\.(class)$/i){			$file =~ s/(.*)\.(.*)//;			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安装程序和脚本全部内容,希望文章能够帮你解决Perl批量执行Linux安装程序和脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1283005.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-09
下一篇2022-06-09

发表评论

登录后才能评论

评论列表(0条)

    保存