My initial failure comes on the first copy command, it fails with - Could not copy directory0 to copieddirectory0: A file or directory in the path name does not exist. Looking at the directory I see the directories there, with the right timestamps, but somehow system seems to get a failure on the call. Is there something that might generate a problem with the call as it is, especially since I am flushing calls to disk?use strict; use Cwd; use Getopt::Long; my ($help) = 0; my ($num) = 20; # Number of default loops to run my ($testdir) = ""; my ($verbose) = 0; GetOptions('help|?' => \$help, "num=i" => \$num, "testdir=s" => \$testdir, 'verbose' => \$verbose); # Header print "Beginning Directory Manipulation Testing...\n" if $verbose; $| = 1; # Get the current working directory my $home_dir = getcwd; # Change to the test directory chdir($testdir); # Set up test dirs if they do not exist if (!-d "test") { mkdir("test"); } if (!-d "test1") { mkdir("test1"); } # Change to the test area chdir("test"); # Directory Manipulation for (my $dir = 0; $dir < $num; $dir++) { # Make the directory if (!-d "directory$dir" ) { mkdir("directory$dir", 0755) or die "Can't make $testdir\\test +\\directory$dir: $!\n"; } # Change permissions of the directory if ($^O =~ /Win32/) { print "\nRunning chmod from - $home_dir\\..\\..\\bin\\chmod on + $testdir\\test\\directory$dir.\n" if ($verbose); if ($verbose) { system($home_dir . "\\..\\..\\bin\\chmod -v a+rwx $testdir +\\test\\directory$dir"); } else { system($home_dir . "\\..\\..\\bin\\chmod a+rwx $testdir\\t +est\\directory$dir"); } } else { system("/bin/chmod 777 directory$dir") or die "Could not chmod + directory$dir: $!\n"; } # Copy the directory if ($^O =~ /Win32/) { print "\nRunning $home_dir\\..\\..\\bin\\cp on $testdir\\test\\directory$dir.\n" if ($verbose); system("$home_dir\\..\\..\\bin\\cp -rv directory$dir copieddir +ectory$dir"); } else { system("/bin/cp -r directory$dir copieddirectory$dir") or die "Could not copy directory$dir to copieddirectory$dir: +$!\n"; } # Rename the directory if (!-d "copieddirectory$dir") { print "copieddirectory$dir does not exist!\n" if $verbose; } if ($^O =~ /Win32/) { system("move copieddirectory$dir ..\\test1\\moveddirectory$dir > o +ut.txt"); if (-e "out.txt") { unlink("out.txt"); } } else { system("/bin/mv copieddirectory$dir ../test1/moveddirectory$di +r") or die "Could not move directory$dir: $!\n"; } # Delete the copied directory if ($^O =~ /Win32/) { rmdir("..\\test1\\moveddirectory$dir"); } else { system("/bin/rm -r ../test1/moveddirectory$dir") or die "Could not remove moved directory$dir: $!\n"; } # Remove the directory if ($^O =~ /Win32/) { rmdir("directory$dir") or die "Can't remove directory: $!\n"; } else { system("/bin/rm -r directory$dir") or die "Could not remove di +rectory$dir: $!\n";; } }
In reply to System call constantly dying by gokuraku
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |