Michael D Schleif wrote:
> * $Bill Luebkert <[EMAIL PROTECTED]> [2005:10:28:07:21:26-0700] scribed:
>> I ran it like this and it seems OK, but I don't have the same conditions:
> 
> There's the rub ;>
> 
>> use diagnostics;
>> use strict;
>> use warnings;
>>
>> my $prog = "E:/usr/ov/bin/nvhotbackup.bat";
>> my $dir = 'E:/backup';
>>
>> if (not -d $dir) {
>>      mkdir $dir or die "mkdir $dir: $! ($^E)";
>> }
> 
> I have cut-pasted your exact code.  Please, recognize that my real code
> does use tests of this nature.

If your mkdir is failing in the Perl script, could there be a permissions
problem ?  You're using /'s instead of \'s like the above right ?

> Also, please, notice the anomaly I tried to describe in my last post,
> regarding whether or not this directory actually gets created (see
> below.)
> 
>> my $dest = timestamp ();
>> if (not -d "$dir/$dest") {
>>      mkdir "$dir/$dest" or die "mkdir $dir/$dest: $! ($^E)";
>> }
>>
>> do_prog ($prog, $dir, $dest);
>>
>> exit 0;
>>
>> # Run system command & return exit code
>>
>> sub do_prog {
>>      my ($prog, $dir, $dest) = @_;
>>
>> $dir =~ s!/!\\!g;    # this one you definitely need
>> $prog =~ s!/!\\!g;   # this may be optional
> 
> This is _not_ required, since MS Windows 2003 Server _does_ follow
> forward slashes in cmd shell.

That's why I said it was optional.  It works either way.
Actually mine works without either of them I believe.

>> my $cmd = qq{$prog "$dir" $dest};
>> print "CMD == ", $cmd, "\n";
>>
>> # my $null = "NUL";
>> # system "$cmd >$null 2>&1";
>>
>> system $cmd;         # seems OK
> 
> Again, I get the same results that I have always had at this point.
> Your code has not affected my results ;<
> 
>> # my @res = `$cmd`;  # also tried this OK
>> #print "res='@res'\n";
> 
> The reason that this is *not* an option is, I need to use the exit codes
> from the call to batch file.

You still can get the return code from `` calls:

    $CHILD_ERROR
    $?      The status returned by the last pipe close, backtick (``) command,
            successful call to wait() or waitpid(), or from the system()
            operator. This is just the 16-bit status word returned by the wait()
            system call (or else is made up to look like it). Thus, the exit
            value of the subprocess is really ("$? >> 8"), and "$? & 127" gives
            which signal, if any, the process died from, and "$? & 128" reports
            whether there was a core dump. (Mnemonic: similar to sh and ksh.)

> Please, understand: Whenever I use back-slashes -- however many, however
> quoted do far -- this directory does *NOT* get created!  Nor does the
> Perl code die at the mkdir test ?!?!

Then don't use back slashes.  I created the dir without them - look at
the mkdir's above.

> Here are my two (2) basic problems:
> 
> [A] The called batch file will not accept a file path with
>     forward-slashes; and

So reverse them just before the system call.

> [B] When I pass the directory string _with_ back-slashes, the mkdir :

I thought the dir was already made before passing the args to the bat file ?

>     - does *NOT* create a directory;

The mkdir (in the Perl code) should have already created the dir and it
works fine with slashes, so use them there.

I'm not following you - be more explicit on where the mkdir is - Perl or bat ?

>     - does *NOT* die nor croak any warning;
>     - function is passed and do_prog() *IS* called;
>     Of course, since the batch file concatenates $dir and $dest into a
>     directory path, into which it tries to copy many files, the batch
>     file *ALWAYS* fails, because there is *NO* directory into which
>     those files can be copied.

If that's true, you should first concentrate on getting the mkdir in
the Perl script to work so it's there - before you deal with the bat file.

> Yes, I know that this is confusing; and I am quite befuddled ;<
> 
> Here is information on my development workstation:
>     System Information:
>     OS Name    MS Windows XP Professional
>     Version    5.1.2600 SP 1 Build 2600

That's what I'm on.

> C:\>perl -v
> 
> This is perl, v5.8.7 built for MSWin32-x86-multi-thread
> (with 7 registered patches, see perl -V for more detail)

I'm one behind you there.

> What do you think?

I think you're doin something wrong.  ;)

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

Reply via email to