I have a Raspberry Pi 3 - Model B, with Raspbian jessie operation system. Im trying to open "chromium" on startup. i wrote a simple script: #!

问题描述 投票:1回答:3

我有一个Raspberry Pi 3 - B型,与Raspbian jessie操作系统.Im试图打开 "铬 "的启动。

我写了一个简单的脚本。

#!/bin/bash
/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com
exit 0

我可以手动运行这个脚本,然后就可以了 完美.我读了很多关于在启动时运行这个脚本的各种方法.我试过:添加这行。@reboot path/to/my/scriptcrontab -e 文件,但没有成功。此外,我还尝试编辑 /etc/rc.local 文件中加入这一行。

#!/bin/sh -e
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  /home/pi/Desktop/script1.sh&   <-------- THIS LINE 
fi
exit 0

我已经检查过了,这个脚本是 可执行 和rc.local也是。

  • rwxrwxrwx 1 pi pi script1.sh
  • rwxr-xr-x 1 root root rc.local

我可以在我的任务管理器中看到script1.sh tesk(它以root身份运行),但什么都没有发生。

默认用户是Pi,我以Pi用户身份登录,而不是以root身份登录,也许这就是问题所在,谁能给我解释一下是什么问题,为什么我只能在任务管理器中看到脚本,我该怎么办?TNX!

更新我已经把rc.local改成了这样。

!/bin/sh -e
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  su - pi -c "/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com &"
fi
exit 0

我还是不能用:binbash usrbinchromium-browser --noerordialogs --...。我做了一个小破解...

我添加了这一行
bash raspberry-pi raspbian
3个回答
2
投票

然后我编辑了

在文件的最后,我把我的路径添加到我的脚本中。@lxterminal这意味着。

nano .config/lxsession/LXDE-pi/autostart

每次你启动Raspberry Pi的时候终端就会打开(第一条命令)

每次终端机运行时,我的脚本也会运行(第二条命令)。$ sudo nano .bashrc对我来说确实有效.TNX的帮助:)

./home/pi/Desktop/script.sh

  1. 看看这个问题的验证答案......

在树莓PI上开机后运行Shell脚本。

看来你需要以用户的身份运行该脚本。

1
投票

EDIT: 我错过了 在命令末尾添加shell脚本路径。

pi

su - pi -c "/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com &"

将shell脚本路径直接添加到 & (不是~.bashrc)效果更好。

也就是说,它不会在每个终端会话(包括ssh)中执行命令。

0
投票

~/.config/lxsession/LXDE-pi/autostart

© www.soinside.com 2019 - 2024. All rights reserved.