I am no expert, but here is what I would try next in this situation: I would open Notepad and create a BAT file. I would copy and paste whatever command you said works. Then I would save this as TEST.BAT and make sure to select Unicode format after you click on Save As. Okay. Now run the program. Does it still work? It should. But then the next step is to see if you can generate the same BAT file from Perl. Run it and see what happens. When you take the $trans string and save it to a text file in Unicode file format, the output file of your Perl script should match exactly the the file you saved with Notepad. You will be able to compare the content using a Hex Editor to see if the bytes match. They should. Because if the file generated by Notepad works and the file generated by Perl doesn't work, then you know for sure that Perl does something to the string before saving it to a file. That's what I am suspecting, but I don't know. So, I would try to save it to a file first from Perl to be able to catch exactly how and where things go wrong.

Edit: Let's say that the Notepad version of BAT file works and the Perl version BAT file works also and they match. But then when you put the command between backticks, it fails. That would tell us that when perl sends the string to be executed by the shell, something happens to the string and it changes from Unicode to ASCII. Then I don't know what other option you have. But maybe try system("something > tempfile.txt"); and see what that does.


In reply to Re^4: Problem running shell command from Perl by harangzsolt33
in thread Problem running shell command from Perl by CrashBlossom

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.