Forgive me for being so late to jump in.  I'm sure my withdrawn rationality
will prevail.  We need to get back to basic debugging procedures.  Verify
that something does what u think it does.

Mkdir:
D:\>perl
mkdir "a/b/c/d";
-d "/a/b/c/d" ? print "dirs exist" : print "dirs don't exist";
^D
dirs don't exist

Your mkdir fails because Perl cannot recursively create directories.
Atleast on build 813.  In ur two dir example it would work if dir1 already
existed. Maybe an interbuild change?  Use shell builtin:
D:\>perl
system "cmd /c mkdir a\\b\\c\\d";
-d "a/b/c/d" ? print "dirs exist" : print "dirs don't exist";
^D
dirs exist


At 07:30 AM 10/28/2005 -0500, Michael D Schleif wrote:
>[A] As is, $prog fails like this:
>
>      Invalid switch - "backup\20051028070933".
>
>    Nevertheless, $dir/$dest *DOES* get created.

It says invalid switch because the full arg as passed by perl is
E:/backup\20051028070933.  Everything after the / is interpreted as a switch
by the Windows program - not the batch file.  Simply flip that ONE / into a
\ immediately before the system call.


>    mkdir "$dir/$dest"
>        or die "\n\n\tERROR: Cannot create \'$dir/$dest\' : $! : $?\n\n";
>
>    Nor, does it get created ;<

Don't have an answer for that one.


This code works for me.  Copy and paste this and see what happens.  Dir1
should not preexist.  What args does the bat file see?  Also notice the
system command.  It has weird quotishness that I think has been overlooked.
It does *not* reevaluate \ escapes in whatever was passed to it.  However,
if you feed it a quoted string, the quotes "operator" *will* evaluate \
escapes before passing that string to system.

===test.pl===
    my $prog = "D:/testbat.bat";
    my $dir = 'D:/dir1';

    my $dest = timestamp();
    mkdir $dir;
    mkdir "$dir/$dest";
    -d "$dir/$dest" ? print "dirs exist\n" : print "dirs don't exist\n";
    do_prog($prog, $dir, $dest);

    sub do_prog {
        my ($prog, $dir, $dest) = @_;
        $dir =~ s!/!\\!g;
        my $cmd = join " ", $prog, $dir, $dest;
        print "CMD is ", $cmd, "\n";
        system $cmd;
    }

    sub timestamp {
        @_ = localtime($_[0] ? shift : time() );
        return sprintf "%d%02d%02d%02d%02d%02d", $_[5] + 1900,$_[4] +
1,$_[3],$_[2],$_[1],$_[0];
    }

======

===testbat.bat===
@echo off
echo testbat.bat
echo Arg 1 is %1
echo Arg 2 is %2
echo Arg 3 is %3

======


Here is my output:
D:\>perl test.pl
dirs exist
CMD is D:/testbat.bat D:\dir1 20051029113850
testbat.bat
Arg 1 is D:\dir1
Arg 2 is 20051029113850
Arg 3 is










--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to