是否有可能重定向脚本中的批处理文件的输出? [英] Is it possible to redirect the output of a batch file inside the script?

查看:152
本文介绍了是否有可能重定向脚本中的批处理文件的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个批处理脚本的标准输出去到一个文件中。我想如果可能的话要做到这一点的脚本中。

注意:我的的要做到这一点: foo.bat> StdOut.txt

我愿做脚本里面的东西输出重定向到一个文件结果
例如:

foo.bat

  ::标准输出重定向到StdOut.txt
::插入批次code做什么,我想在这里。


解决方案

一做就是下面的方法。使用呼叫命令的脚本来执行的标签。 修改我认识的第一个版本我张贴似乎并不在CMD.EXE提示工作(我是用TCC)。下面,似乎在这两个指令的处理器工作:

 关闭@echo
致电:testitout> t.tmp
GOTO:EOF:testitout
回声您好
回声再见

I would like to set the standard output of a batch script to go to a file. I would like to do this inside the script if possible.

Note: I do not want to do this: foo.bat > StdOut.txt

I would like to do something inside the script to redirect the output to a file
For example:

foo.bat

:: Redirect standard output to StdOut.txt
:: Insert batch code to do what I want here.

解决方案

One way of doing it is the following. Use the call command to execute a label in the script. Edit I realized the first version I posted does not seem to work in a cmd.exe prompt (I was using TCC). The following seems to work in both command processors:

@echo off
call :testitout > t.tmp
goto:eof

:testitout
echo Hi There
echo Goodbye

这篇关于是否有可能重定向脚本中的批处理文件的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆