• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
黄洪波写点东西的地方
博客园    首页    新随笔    联系   管理    订阅  订阅
使用perl实现scp批量分发

perl模块Net::SCP::Expect批量下发文件

用Net::SSH::Perl和Net::SCP::Expect写部署脚本

scp分发文件的perl脚本 

Perl SCP操作

 

#!/usr/bin/perl

use Net::SCP::Expect;
my $pc_ip
="192.168.233.135"; my $pc_passwd="test"; my $pc_user="test"; my $pc_ssh_port="22";
eval{ my $scpe
= Net::SCP::Expect->new(host=>$pc_ip,user=>$pc_user,password=>$pc_passwd,port =>$pc_ssh_port,auto_yes=>1); #$scpe->scp("$pc_ip:/home/autotest/log/$log_file","$ENV{WORKSPACE}/MPLS_Test_Result.html"); $scpe->scp("/home/huanghongbo/testlogs/test.log","$pc_ip:/home/huanghongbo/testlogs/"); };

 

复制整个目录

在Net-Scp-Except中的readme中有此一句

recursive - Set to 1 if you want to recursively copy entire directories.

#!/usr/bin/perl

use Net::SCP::Expect;

my $pc_ip="192.168.233.135";
my $pc_passwd="test";
my $pc_user="test";
my $pc_ssh_port="22";


eval{
        my $scpe = Net::SCP::Expect->new(host=>$pc_ip,user=>$pc_user,password=>$pc_passwd,port =>$pc_ssh_port,auto_yes=>1,recursive=>1);
        #$scpe->scp("$pc_ip:/home/autotest/log/$log_file","$ENV{WORKSPACE}/MPLS_Test_Result.html");
        $scpe->scp("/home/huanghongbo/class/","$pc_ip:/home/huanghongbo/class/");
        
};

 

posted on 2016-12-25 03:05  红无酒伤  阅读(1089)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3