gpt4 book ai didi

linux - 未获取到文件中的错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:04:07 25 4
gpt4 key购买 nike

可能是一个天真的问题,但我被卡住了。

我有一个 shell 脚本 file.sh,其中包含一个简单的命令(我没有安装 python)

echo $PATH && cd/home/akash/repos/dhvani/&& echo $PWD && python main.py

当我以 sh file.sh >/tmp/out 运行它时。我在 /tmp/out 中得到了 echo 的部分,但没有得到错误。我没有安装 python,所以我也必须在文件中得到类似 python: not found 的错误。但我只在终端中得到它。

任何人都可以解释我如何记录此错误的方法。

最佳答案

要使 stderrstdout 转到文件,请执行以下操作:

sh file.sh > /tmp/out 2>&1

关于linux - 未获取到文件中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48239644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com