相关疑难解决方法(0)

将脚本输出重定向到 /dev/tty1 并将输出捕获到文件

我想在控制台上显示文本输出,该文本输出始终显示在我的 Raspberry Pi 上的小屏幕上。

以下代码用于显示文本输出:

cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /dev/tty1
Run Code Online (Sandbox Code Playgroud)

现在我想在屏幕上看到输出的同时捕获输出 - 我尝试过“tee”,但它不会在屏幕上显示文本,也不会将其捕获到文件中:

cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py | tee /dev/tty1 /tmp/capture.txt
Run Code Online (Sandbox Code Playgroud)

如何将脚本的输出重定向到,/dev/tty1以便我可以在屏幕上看到它,同时还将输出捕获到文件中?

更新1:

根据下面的答案 - 我尝试使用“脚本” - 不幸的是它不起作用:

script -c "cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /dev/tty1" /home/pi/python_test_scripts_linux/report.html
Run Code Online (Sandbox Code Playgroud)

更新2:

我还尝试将输出重定向到 /dev/tty1 的文件的输出,但它也不起作用:

sudo tail -F /home/pi/python_test_scripts_linux/report.html > /dev/tty1 &
cd /home/pi/python_test_scripts_linux && sudo nice -n -20 /home/pi/python_test_scripts_linux/test_wrapper.py > /home/pi/python_test_scripts_linux/report.html 
Run Code Online (Sandbox Code Playgroud)

linux bash io-redirection tty tee

4
推荐指数
1
解决办法
9307
查看次数

标签 统计

bash ×1

io-redirection ×1

linux ×1

tee ×1

tty ×1