سؤال

I wrote a script in Perl to move images to a network share drive which works fine on a PC. When I try to run it on a Mac all I get are error messages. I can't figure out what is causing the problem. Would there be a reason the script won't run on the Mac? I'm using File::Copy and File::Find to move these files.

This is the error message I am getting:

copy failed:No such file or directory at "location of the script" line 14.

Any help would be great. Thanks. : )

 use File::Copy;
 use File::Find;
 my @source = qw (source/location);
 my $target   = q{//share/drive/location};

 while (1)
 { sleep (10);
   find(
    sub {
     if (-f) {
       print "$File::Find::name -> $target";
       copy($File::Find::name, $target)
       or die(q{copy failed:} . $!);

       }
        },
     @source
   ); 

  }
هل كانت مفيدة؟

المحلول 2

Your //share/drive/location is not valid on your Mac. That is why you get the no such file or directory message.

You can test this in a terminal window by trying to cd to that path.

That location will need to be mounted on your Mac so that you have a valid path to it.

That is done in your Finder or via the mount_smbfs command if you have a newer version of OSX.

Once that is done, you will have a path you can write to, such as /mnt/some/path.

نصائح أخرى

You didn't supply any code, so I have to guess, but I'd say the file you're copying or the directory your copying to doesn't exist.

You probably have code like this on line 14.

copy($src, $dest) or die "copy failed:$!";

It would help you debug the program if you put $src and $dest into the error message.

copy($src, $dest) or die "copying $src to $dest failed: $!";

Seems like the error explains it all:

copy failed:No such file or directory at "location of the script" line 14.

Is "location of the script" an uncommented comment? It seems like your Perl parser is trying parse a value or variable dubbed "location of the script"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top