Hi Folks, My code is actually doing what I want it to, but I'm curious about some unexpected behavior so I am here to ask those who might know. :-)

My script sends a system command to TFS to attempt to extract a build label in order to assess if that build has been baselined. This is my mock-up to test the code:

$tf="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\I +DE\\tf.exe"; $buildLabel = "the build label"; $/ = undef; BuildCheckedInToTFS(); sub BuildCheckedInToTFS(){ my $checkedIn = 0; print "Verifying build label exists in TFS...\n"; `\"$tf\" labels /owner:theOwner \"$buildLabel\" > "TFSLabelInfo.t +xt"`; open TFSLABEL, "TFSLabelInfo.txt" or die $!; my $TFSLabel = <TFSLABEL>; close TFSLABEL; if ($TFSLabel =~ /$buildLabel/){ $checkedIn = 1; print "Build $buildLabel has been checked-in to TFS."; } else { print "Baselining failed. \n:" + "Build $buildLabel has not been checked-in to TFS."; } return $checkedIn; }

For those who are curious, I use the returned value in another portion of the script. Anywho, it is doing just what I want- it reports whether or not the build label in question is present. This is just an audit script so that's all I need. However, when I was just testing the tf command and all I had was this

$tf="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\I +DE\\tf.exe"; $buildLabel = "the build label"; `\"$tf\" labels /owner:theOwner \"$buildLabel\"`;
in my script it produced no apparent result. When I would run the script there would be a pause as though some work were taking place, then the command prompt would simply reappear and there would be no output on the screen. I figured it was checking the mapped drive so I added the redirection to see if something would come of that. As soon as I did, the text file appeared and I got the expected result (a listing of the labels matching the specs). What I don't understand is why I get no output in the command window when I run the tf command via my Perl script. When I simply run the command at the command prompt I get the expected output (a listing of the labels matching the specs) in the window, but when I run it via my script I get nada in the command window. I even tried putting in an echo command and still the same thing - a pause followed by the command prompt. I would expect nothing to show in the window if the output is being redirected, but I don't get why it is happening when the output is not redirected.

This doesn't matter in terms of the function of this script, but I'm curious to know the reason why. I am new to Perl and perhaps what you might call an advanced beginner at programming, so if you need to get very technical a link to a detailed explanation would really be welcome. Thanks in advance!


In reply to No command window output when running script by JennieInMI

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.