fourmi has asked for the wisdom of the Perl Monks concerning the following question:

having problems with a system move call using unix.. any ideas?!!?!?!?!?!?
print "mv $OutFile $List/archive.html\n\n"; system ('mv -f $OutFile $List/archive.html');
gives the following
mv September03narchive.html September03n/archive.html mv: Insufficient arguments (1) Usage: mv [-f] [-i] f1 f2 mv [-f] [-i] f1 ... fn d1 mv [-f] [-i] d1 d2

Replies are listed 'Best First'.
Re: Move damit!
by Abigail-II (Bishop) on Sep 18, 2003 at 14:49 UTC
    You have single quotes in your argument to system, so $OutFile and $List are passed without being interpolated. Most likely, neither of them exist in the shell, which does interpolate them, resulting in the command:
    mv -f /archive.html
    which causes mv to complain.

    Abigail

      use File::Copy; move($OutFile, "$List/archive.html");
        I fail to understand your point. The problem wasn't that he used 'system', the problem was that he used single quotes instead of double quotes. Given the mistake, the system solution works better than your suggestion - at least that solution gave error messsages. But:
        use File::Copy; move ($OutFile, '$List/archive.html');
        would fail silently because you didn't check the return value of move.

        Abigail

Re: Move damit!
by blue_cowdawg (Monsignor) on Sep 18, 2003 at 14:54 UTC

    In addition to the comments made elsewhere in this thread I have a trick that I use on those rare occations that I use system and it doesn't work for one reason or another. If you do this:

    system('set -xv ; myCommand arg1 arg2 argv');
    the shell will show you exactly what it is executing as it does so. You wouldn't want to do that in production but for troubleshooting it works.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
Re: Move damit!
by ctilmes (Vicar) on Sep 18, 2003 at 14:45 UTC
    What happens if you execute that from the command line?
Re: Move damit!
by fourmi (Scribe) on Sep 18, 2003 at 15:05 UTC
    SOLUTION
    system ('set -xv;mv -f ' . $OutFile." ". $List.'/archive.html');
    cheers doodz!
      Or you could have just used double quotes:
      system ("mv -f $OutFile $List/archive.html");
Re: Move damit!
by fourmi (Scribe) on Sep 18, 2003 at 15:02 UTC
    mv September03narchive.html September03n/archive.html works fine at the command line, set -xv is useful, still stuck though so experimenting with random '\'!