I agree bill, it does not make sense, nonetheless on my win98 machine (creak creak), the extra space is required.

jim

$Bill Luebkert wrote:
James Sluka wrote:
  
One more thing to try is to add a trailing space after the directory
spec, as in;
    system qq{$prog "$dir " $dest}
or
    my $cmd = qq{$prog "$dir "  "$dest"};

I did some quick tests with;
##########Perl code
my $prog = 'c:\windows\desktop\some-batch.bat';
my $dir  = 'c:\windows\desktop\jim';    # no trailing backslash
my $dest = 'thelabel';

# both the directory and batch files do exist
if (-e $prog) {print "prog found\n"} else {print "prog NOT found\n"};
if (-d $dir)  {print "dir  found\n"} else {print "dir  NOT found\n"};

# Version 1, works
system qq{$prog "$dir " $dest}; # quoted $dir in case blanks in path
                                # and note the extra space in "$dir "

# Version 2, works
my $cmd = qq{$prog "$dir "  "$dest"}; # note the extra space in "$dir "
print "\n\nCMD ==", $cmd, "=\n";
system "$cmd";
# end Perl code

### some-batch.bat contains
echo %1
echo %2
dir %1

The perl code above fails if the trailing space after the dir spec is
omitted. The space can be in the original variable or added when the
command is created (as I did above).
    

That doesn't make any sense.  There's already one space there why would
putting two there make a difference ?  Mine worked with just one.
A trailing \ may make some change, but an extra space seems pretty
redundant.

This works fine for me:

if (-e $prog) { print "$prog found\n" } else { print "$prog NOT found\n" };
if (-d $dir)  { print "$dir  found\n" } else {
  mkdir $dir or die; print "$dir NOT found created\n" };

# $dir =~ s/\//\\/g;	# this is optional for me

system qq{$prog "$dir" $dest};

The bat file produces (for my version) :

%0 = E:/tmp/nvhotbackup.bat
%1 = "E:/tmp/backup"
%2 = thelabel

dir "E:/tmp/backup"
 Volume in drive E is DATA120
 Volume Serial Number is 0000-0E20

 Directory of E:\tmp\backup

10/28/2005  10:51 AM    <DIR>          .
10/28/2005  10:51 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)   7,019,872,256 bytes free

errorlevel = 0
cmdline = cmd /c "E:/tmp/nvhotbackup.bat "E:/tmp/backup" thelabel"
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

  
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to