Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
(I tested this with ActiveState Perl 5.8.8 and 5.12 on Windows 7 (64 bit))

I have the following batch file testing.bat:

echo XXXXXXX >X_%2.log 2>&1 sleep 5
Note that this batch file ignores its first parameter and just uses its second. It seems to be important to demonstrate this bug to have a batch file which will be called with 2 parameters.

Further, I have the following Perl program testing.pl:
use strict; use warnings; my $cmdline="cmd /c testing.bat AA 1"; my $child_pid=system(1,$cmdline); print "$child_pid\n"; wait; print "Finished\n"; exit;
This just calls testing.bat with in background, and terminates when the child also terminated. Running the batch file in background seems to be crucial for this bug (?) to occur. BTW, the sleep in the batch file is not essential to demonstrate the problem, but it shows that the wait indeed waits until the child terminates.

When I run perl testing.pl, I get the following output:

C:\Users\rofischx\playground>perl testing.pl 4864 C:\Users\rofischx\playground>echo XXXXXXX 1>X_1".log 2>&1 The filename, directory name, or volume label syntax is incorrect. C:\Users\rofischx\playground>sleep 5 Finished

We see that there occurs suddenly a double quote inside the redirection, which in turn causes the error message. Any idea where this spurious double-quote comes from? Also, could someone try to reproduce this behaviour, either with the same Perl version, or with a newer one, an let me know the outcome?

Also interesting: From my experiments with this problem, the program posted here seems to be the minimal one. Whenever I tried to simplify it further (reducing the number of parameters in the batchfile, for instance), the problem did not show up.

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Calling Windows Batch from Perl, double-quote appearing out of nowhere by rovf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-18 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found