這一個正在困擾着我,所以我正在接觸到我知道的最好的編碼社區,在這麼多長時間的咖啡之後尋求幫助。等待文件不再是不存在的perl
基本上我需要一個perl腳本來等待文件不再出現在服務器上,然後再繼續。真的在等待所有屏幕會話被終止(/ var/run/screen成爲一個空目錄)。
#!/usr/bin/perl
my $directory="/root/screens";
opendir(DIR, $directory) or die "couldn't open $directory: $!\n";
my @files = readdir DIR;
closedir DIR;
foreach (@files){
while (-e $_) {
print "$directory has $_ existing\n";
sleep 1;
}
}
Ex Dir。
total 8
drwxr-xr-x. 2 root root 4096 Oct 11 22:58 ./
drwxr-x---. 17 root root 4096 Oct 11 05:33 ../
-rw-r--r--. 1 root root 0 Oct 11 22:58 S-root
-rw-r--r--. 1 root root 0 Oct 11 22:58 S-root1
上面沒有明顯的工作,但我只是沒有看到一個很好的辦法做到這一點在谷歌和它一直是漫長的一天。
您需要DIR中的美元符號($ DIR) – amrfaissal
不,您不需要DIR中的美元符號。 – mob