×

perl脚本下载

perl脚本下载(ftp使用perl脚本)

admin admin 发表于2023-03-21 22:17:17 浏览66 评论0

抢沙发发表评论

本文目录

ftp使用perl脚本


#!/usr/bin/perl -w
use Net::FTP;
use POSIX qw(strftime); #这个是我当时用来抓时间的可以省略
my $remotefile;
my $localfile;
my $dir = ’E:/CDR/trunk/’; #本地存放路径
my $host;
my $password;
my $ftp;
#1. get begin
$host=’192.168.1.105’; #被FTP的远程IP
$password=’hahahaha’; #ftp的密码
$ftp=Net::FTP-》new($host) or die “cannot connect to ftp server $host!\n“;
$ftp-》login(“root“,$password);
$ftp-》cwd(“/AP/CDR“); #远程抓取的路径
if ( -d “$dir/$host“ ) { #这个条件句是用来判断本地目录192.168.1.105是否存在,不存在就创建
}
else {
system “mkdir -p $host“;
}
print “the list of /ap/cdr from $host!!\n“; #列出远程目录的所以非目录文件,并抓取符合条件的文件
&list(“/“);
$ftp-》quit;
#1. get end
sub list() #list类,判断文件类型的核心
{
my $current = $_;
my @subdirs;

$ftp-》cwd($current);
my @allfiles = $ftp-》ls();

foreach (@allfiles){
if(&find_type($_) eq “d“){ #如果是目录则打印并忽略掉
print “this floder!!\n“;
}
else{
my $tmp = “$_“;
print $tmp.“\n“;
if($tmp=~/adf/){ #判断包含adf则抓取,当然可以扩展正则方法
$remotefile=$tmp;
$localfile = “$dir/$host/“.$remotefile;
$ftp-》binary();
$ftp-》get($remotefile,$localfile)
or die “Could not get remotefile:$remotefile\n“;
print “download $remotefile complete from $host!!\n“;
}
}
}

}
sub find_type{
my $path = shift;
my $pwd = $ftp-》pwd;
my $type = ’-’;
if ($ftp-》cwd($path)) {
$ftp-》cwd ($pwd);
$type = ’d’;
}
return $type;
}
老大 我自己执行是可以的, 把分给我吧

关于perl脚本


`C:\\KuGou2012\\Kugou.exe \“Fire Fly.mp3\“`;
如果你的音乐文件 比如 Fire Fly.mp3不和你的脚本在同一个目录,那么你就需要将路径修改为绝对路径,假设你的音乐文件绝对路径为:
D:\music\Fire Fly.mp3
那么你运行的时候,perl中执行的语句为:
`C:\\KuGou2012\\Kugou.exe \“D:\\music\\Fire Fly.mp3\“`;
注意以下几点:
1、` 这个不符号是键盘上数字1旁边那个按键。需要在半角输入法状态下打出来。用两个 ` 引起来表示调用命令行形式执行被引起来的语句。
2、路径中的\需要转义,即用双斜线,即\\
3、如果路径中存在空格等字符的时候,需要用双引号引起来,表示完整路径,否则会被识别为两个参数,这也是为什么D:\\music\\Fire Fly.mp3需要写为 \“D:\\music\\Fire Fly.mp3\“的原因
4、如果双引号引起来,因为双引号处于语句中,因此需要在双引号前面加转义字符,否则会被识别错误。

求perl脚本,用于抓取通过top指令获得的CPU信息


 #!perl   
my @list =`top -n 1`;
foreach my $listfile (@list){
    if($listfile =~ /Cpu/g){#cpu :Cpu(s):  0.1%us,  1.0%sy,  0.4%ni, 87.4%id, 10.6%wa,  0.0%hi,  0.5%si,  0.0%st -我使用top得到的目标行,则把Cpu作为了/Cpu/g里面的过滤条件
     chomp $listfile;
     my $cpuinfo = $listfile;#$cpuinfo 即是所要行
  print “cpu :“,$cpuinfo, “\n“;
 }
}

如何在cmd中运行perl


首先,下载安装active perl,运行cmd, 输入 perl -v 看有没有版本信息,如果有的话说明安装成功。再用cd..转成你perl 脚本文件目录下,perl -d abc.pl(perl脚本名),单步调试,perl abc.pl 直接运行!!

perl脚本


my $predict_shell_file = “$Outdir/$seq_file_name.predict.sh“;
这句的意思是创建标量$predict_shell_file
然后把 $Outdir/$seq_file_name.predict.sh(一个文件路径) 赋值给它。
一般是以后用作文件句柄的打开或者文件的存储。
print OUT “perl $Bin/predict_run.pl $config{bgf} $bgf_para $seq_file 》 $Outdir/$seq_file_name.bgf\n“;
这句是把后面的输入到文件句柄OUT中。 》 后面也是一个文件的路径

写perl脚本,用什么软件啊


先安装ActivePerl 这是perl解释器
http://www.onlinedown.net/soft/8364.htm
再安装DzSoft Perl Editor 这是编辑器
http://www.duote.com/soft/3014.html
我觉得巨好用!