JennieInMI has asked for the wisdom of the Perl Monks concerning the following question:
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
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.$tf="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\I +DE\\tf.exe"; $buildLabel = "the build label"; `\"$tf\" labels /owner:theOwner \"$buildLabel\"`;
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: No command window output when running script
by syphilis (Archbishop) on Dec 29, 2012 at 09:11 UTC | |
by JennieInMI (Acolyte) on Dec 29, 2012 at 22:55 UTC | |
by syphilis (Archbishop) on Dec 29, 2012 at 23:26 UTC | |
by JennieInMI (Acolyte) on Dec 30, 2012 at 01:33 UTC |