bash - 将 Cygwin/bash 结果输出到文本文件

标签 bash batch-file cygwin dos

我正在编写将从任务计划程序运行的脚本。它不能从调度程序正确执行,但可以从命令行正确执行。 (可能是权限问题?)我想将输出重定向到一个文本文件,但是从命令行或调度程序执行时我得到一个空的 results.txt 文件。

这是批处理文件的内容:

D:
chdir D:\scripts
C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt

最佳答案

也许您的脚本写入了标准错误 (stderr)。尝试改变

C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt

C:\cygwin\bin\bash --login -i D:\scripts\myscript.sh > results.txt  2>&1

它也将 stderr 重定向到文件。

关于bash - 将 Cygwin/bash 结果输出到文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8157779/

相关文章:

linux - 中断执行并在终端打印部分信息

bash - 在运行超过指定时间的 bash 中终止进程?

linux - 使用批处理文件或 shell 脚本进行文件传输

Windows 批处理脚本 : substring calculation

bash - 语法错误: unexpected end of file trying to run a simple bash script

sed - 文件中的 DOS 到 UNIX 路径替换

linux - 在 bash 脚本中,git 无法识别它自己的目录?

batch-file - 创建 cmd 快捷方式以在 Inno Setup 中执行批处理文件

windows - 批量编码文本文件

node.js - Git diff 不适用于 Windows 绝对路径