2011-06-15 14 views
40

एक मानक खिड़कियों .cmd फ़ाइल में मैं ऐसा करके बस stdout करने के लिए संदेश भेज सकते हैं:मैं cmd ​​से stderr को संदेश कैसे भेजूं?

echo message 

मैं एक संदेश कैसे भेजूँ stderr करने के लिए कर सकते हैं?

उदाहरण:

call child.cmd 1>>stdout.log 2>>stderr.log 

और एक बच्चे युक्त:

:: Writes a message to stdout 
:: (which in the parent is piped to stdout.log) 
echo message 

:: Now I want to write a message to stderr 
:: (which in the parent is piped to stderr.log) 
??? 

उत्तर

45

आप STDERR के हैंडल पर STDOUT के हैंडल को रीडायरेक्ट करने का प्रयास कर सकते हैं। अपने बच्चे को इस प्रक्रिया में, एक हैंडल रीडायरेक्ट के साथ गूंज करते हैं:

:: Writes a message to stdout 
:: (which in the parent is piped to stdout.log) 
echo message 

:: Now I want to write a message to stderr 
:: (which in the parent is piped to stderr.log) 
echo message 1>&2 

Microsoft 'splainin it

15

प्रयास करें echo message 1>&2

मैं

मान लीजिए कि मैं स्क्रिप्ट से युक्त parent.cmd करते हैं मैंने अभी कोशिश की और ऐसा लगता है एक बैच फ़ाइल के भीतर से भी सही ढंग से काम करने के लिए।

संबंधित मुद्दे