在 Raspberry 启动时运行终端命令

编程入门 行业动态 更新时间:2024-10-23 09:38:03
本文介绍了在 Raspberry 启动时运行终端命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个使用curses和pygame库的项目,我的python程序/脚本只能使用终端运行,否则会发生此错误

I am working on a project in which I am using curses and pygame librarie, my python program/script can only be run through using terminal otherwise this error occurs

fd=_sys.__stdout__.fileno()) _curses.error: setupterm: could not find terminal

我想使用这两个命令在树莓派启动时运行我的程序

I want to run my program on startup of Raspberry pi by using these two commands

cd Desktop python test.py

我知道 rc.local 但无法运行它....(首先打开终端,然后运行这 2 个命令以运行我的脚本)

I am aware of rc.local but unable to run this....(first open terminal and then run these 2 commands in order to run my script)

推荐答案

我花了大约 1 天时间测试了 4 个 Linux/raspberry 启动运行脚本问题的解决方案.那么这里就是解决方案(我选择crontab)

I spent around 1 day and test 4 solutions for Linux/raspberry startup run script issues. Then here is the solution (I choose crontab)

  • 打开 crontab(使用 linux@crontab -e -> 不使用 sudo crontab -e ...这可能是将来某些脚本等访问的错误)
  • pi@crontab -e

    pi@ crontab -e

    然后选择nano并像这样编辑......这很棘手,我测试后发现可能超过10倍:

    Then choose nano and edit like this... It is tricky, ı found after test may be more than 10x times:

    @reboot cd /home/pi/beetool && /usr/bin/python3 run.py &

    我的代码在/home/pi/beetool 下等着我.如果你不改变发生错误的目录.

    My code is waiting for me under /home/pi/beetool. If you don't change the directory that occurs error.

    我的代码使用无限循环,所以我必须以&"结束如上所示.

    And my code uses infinite loop so I have to finish with "&" as you see above.

    所以我也希望对某人有所帮助...

    So I hope that helps someone, too ...

    更多推荐

    在 Raspberry 启动时运行终端命令

    本文发布于:2023-10-04 09:58:30,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1467151.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:终端   启动时   命令   Raspberry

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!