Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl copy命令等待复制完成_Perl_Copy - Fatal编程技术网

Perl copy命令等待复制完成

Perl copy命令等待复制完成,perl,copy,Perl,Copy,我将文件从位置windowsLocation1复制到LinuxLocation1,作为“windowsLocation1->windowsLocation2->LinuxLocation1”,windowsLocation2是可从windows和Linux计算机访问的交换区域 copy("//server1/dir1/myfile.txt", "$copy_dir/myfile.txt") or die "Copy failed: $!"; <telnet into Linux machi

我将文件从位置windowsLocation1复制到LinuxLocation1,作为“windowsLocation1->windowsLocation2->LinuxLocation1”,windowsLocation2是可从windows和Linux计算机访问的交换区域

copy("//server1/dir1/myfile.txt", "$copy_dir/myfile.txt") or die "Copy failed: $!";
<telnet into Linux machine>
$obj->{telnet}->print( "sleep 10; cp /net/dir1/myfile.txt /tmp/files/");
#added "sleep 10, to avoid the race condition between copy and cp.
copy(“//server1/dir1/myfile.txt”,“$copy\u dir/myfile.txt”)或die“复制失败:$!”;
$obj->{telnet}->print(“sleep 10;cp/net/dir1/myfile.txt/tmp/files/”;
#增加了“睡眠10,以避免复制和cp之间的竞争条件。
这种“睡眠10”秒有时是不够的,它的抛出错误为“cp:read error:Input/output error”,我认为第二个“cp”命令试图在第一个“copy”命令仍在写入时访问文件


有什么方法可以避免这种情况吗?谢谢。

我猜您是从
文件::copy
模块获得了
复制
例程

在对CPAN进行了简短的搜索之后,我发现了一个名为的模块,它似乎可以满足您的需要,并且有来自Perl5.6的成功测试报告


我也发现了,但是它只有关于perl 5.8的报告,尽管这是毫无证据的。就这个模块而言,你可能只是一个时间旅行的先驱……

这可以被重构为使用一个健壮的协议,比如
scp
?嗨,Jim,我的perl版本不支持scp,这需要一些时间来实现migr把我们所有的脚本都用上了最新的Perl。谢谢。@Krish我们有没有机会知道您选择了哪个模块?