Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: No command window output when running script

by syphilis (Canon)
on Dec 29, 2012 at 09:11 UTC ( #1010805=note: print w/ replies, xml ) Need Help??


in reply to No command window output when running script

`\"$tf\" labels /owner:theOwner \"$buildLabel\"`;

I think it's just that backticks returns the output, rather than prints the output ... and since you haven't collected what was returned, it just gets lost.
By way of demonstration:

C:\_32\C>cd C:\_32\C C:\_32\C>perl -e "`cd`" C:\_32\C>perl -e "$x=`cd`;print $x" C:\_32\C
Cheers,
Rob


Comment on Re: No command window output when running script
Download Code
Re^2: No command window output when running script
by JennieInMI (Acolyte) on Dec 29, 2012 at 22:55 UTC

    Hi Rob,

    Thank you for this reply. It makes perfect sense. I wasn't storing what was returned and printing it, so nothing was output to the screen. Returning and outputting are not inherently equivalent.

    I just tried out your example. Cd doesn't return a value so nothing is output with this example, but when I used dir instead I got a nice screenful of info. :-D I'm not on my work computer right now so I can't try out my tf command yet, but I will give it a try later. Thank you again for the answer.

    Jennie

      Cd doesn't return a value so nothing is output with this example

      Interesting ... and there's probably a good reason for that, but I don't know what it is.
      Certainly, the behaviour you're seeing doesn't conform to the documentation I get for cd, which begins with:
      C:\_32\C>cd /? Displays the name of or changes the current directory. CHDIR [/D] [drive:][path] CHDIR [..] CD [/D] [drive:][path] CD [..] .. Specifies that you want to change to the parent directory. Type CD drive: to display the current directory in the specified drive +. Type CD without parameters to display the current drive and directory. .....
      Perhaps you're running in a different shell (I use cmd.exe), or perhaps your cmd.exe shell finds a different 'cd' implementation to run.
      To force your cmd.exe shell to use its own implementation, I think you just need to involve a shell metacharacter in the command - eg:
      cd <nul
      Does that command print out the current directory for you ?

      (Admittedly this has nothing to do with the subject you initially raised ... but I find it a little bit interesting.)

      Cheers,
      Rob

        Hi Rob,

        I apologize. My error. I do run cmd.exe and just reran your code example. cd was, indeed, returning a value. However, since the returned value looked exactly like the command prompt only minus the > sign I just didn't realize that it wasn't the command prompt. I'm not generally dense. I don't know what's wrong with me here lately. Anyway, your example was fine. I just messed up reviewing the result. Thank you again for the answer.

        Jennie

        Update:

        After messing around with the syntax a little I did finally get it to work at the command line. Thanks again Rob.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-01 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls