#!/usr/local/bin/perl
use strict;
use warnings;
system("cd $PATH
/usr/bin/sftp mysite.com <<!EOF
put sample.txt
bye
!EPF");
Run Code Online (Sandbox Code Playgroud)
当我压缩应用程序时,它询问密码,如何在代码本身中传递用户/密码,
我想要的是,我的脚本不应该问密码.我想在代码本身中设置用户/密码.用户命令在sftp中不起作用如何制作它.
有了这么模糊的问题,很难给出更多回答......
你试过Net :: SFTP模块吗?
编辑:
基于对问题的编辑 - 尝试使用Net :: SFTP :: Foreign
use Net::SFTP::Foreign;
use warnings;
use strict;
my $host = "xxx.xxx.xxx.xxx";
my $sftp = Net::SFTP::Foreign->new($host, user => 'user', password => 'pass');
$sftp->error and die "Something bad happened: " . $sftp->error;
$sftp->put("sample.txt", "/home/test/test") or die "put failed: " . $sftp->error;
Run Code Online (Sandbox Code Playgroud)
您应该收到更有意义的错误消息,然后您可以从那里获取它.
| 归档时间: |
|
| 查看次数: |
11273 次 |
| 最近记录: |