在 Raspberry 启动时运行终端命令 [英] Run Terminal Commands on Raspberry Startup

查看:61
本文介绍了在 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)

  1. 打开 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 启动时运行终端命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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