求助,帮我写一个简单的shell脚本(已解决)
Tofloor
poster avatar
powang110
deepin
2013-04-20 23:33
Author
请问各位高手,我想开机自动运行这一条命令 sudo setpci -s 00:02.0 F4.B=66 ,如何写脚本?
Reply Favorite View the author
All Replies
lwxez
deepin
2013-04-21 00:18
#1
同求,有类似需求!
Reply View the author
FEI17
deepin
2013-04-21 00:57
#2
请问各位高手,我想开机自动运行这一条命令 sudo setpci -s 00:02.0 F4.B=66 ,如何写脚本?

echo XXXX | sudo -S "-s 00:02.0 F4.b=66"
Reply View the author
jhkwei
deepin
2013-04-21 02:26
#3
sudo gedit /etc/rc.local
把你的东西加在最后面就行了,当然不要加sudo 这个词了
也可以加在 gedit ~/.bashrc 中间,只是不知道怎么在sudo 时输入密码
Reply View the author
powang110
deepin
2013-04-21 02:59
#4
#! /bin/bash
if [ -z "$1" ]; then
    a=66
else
    a=$1
fi
sudo setpci -s 00:02.0 F4.B=$a

你们写的东西,我不会用。我在网上找了一下,用这个脚本可以,但不太理想,不能开机自动执行,还要输入密码。
Reply View the author
powang110
deepin
2013-04-21 03:58
#5
用3楼朋友jhkwei的方法,成功了,谢谢!跟和我一样的菜鸟们分享一下,简要说明一下步骤:

1.终端输入sudo gedit /etc/rc.local,系统打开一个记事本。

2.在最后一行,当然是 exit 0 的上面那一行输入setpci -s 00:02.0 F4.B=66,保存,重启,开机自动调好所设定的亮度,不用输入密码。

问题解决,请版主锁帖,谢谢!
Reply View the author
cxbii
deepin
2013-04-21 04:00
#6
用3楼朋友jhkwei的方法,成功了,谢谢!跟和我一样的菜鸟们分享一下,简要说明一下步骤:

1.终端输入sudo gedit /etc/rc.local,系统打开一个记事本。

2.在最后一行,当然是exit的上面那一行输入setpci -s 00:02.0 F4.B=66,保存,重启,开机自动调好所设定的亮度,不用输入密码。

问题解决,请版主锁帖,谢谢!
不需要锁帖啊.
你说得不够完全把?
是把setpci -s 00:02.0 F4.B=66插在exit 0这行前面才对把
Reply View the author
powang110
deepin
2013-04-21 04:11
#7
哈——哈——哈——
cxbii朋友 真是一个有心人,是的,把setpci -s 00:02.0 F4.B=66插在exit 0这行上面,谢谢!
  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.
  13. setpci -s 00:02.0 F4.B=66
  14. exit 0
Copy the Code
Reply View the author
cxbii
deepin
2013-04-21 04:43
#8
修改了一下~
Reply View the author