简体   繁体   English

sh 1 sudo找不到在ubuntu上完成的python脚本在bananian上不起作用

[英]sh 1 sudo not found python script done on ubuntu does not work on bananian

I made a script on ubuntu and now I want it to run on my banana pi with bananian (raspbian for banana pi). 我在ubuntu上编写了一个脚本,现在我希望它可以与bananian(香蕉pi的树莓派)一起在我的香蕉pi上运行。 Here is the part where of my script I have some problems: 这是我的脚本中存在一些问题的部分:

foundmob= False
foundusb= False

sudoPassword='figaro'#my sudo password
command="usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000100000000000000000000'" # the command that for ce the modem to be on serial mode
while foundusb!= True : # this allows me to look for the modem as an usb and then force it

    foundmob=terminalComAndRead("lsusb",'12d1:1f01')#doing a ls usb and then looking for the id of my device
    changemob=terminalComAndRead("lsusb",'12d1:1001')#this is the id of my device when it is already in serial mode

    if foundmob == True :

        os.system('echo %s|sudo -S %s' % (sudoPassword, command))# this is the line who execute the command on sudo

While I execute this script in ubuntu, I do not have any problem, but then when I want to execute it on bananian with my banana pi, I get this error: 当我在ubuntu中执行此脚本时,我没有任何问题,但是当我想用香蕉pi在bananian上执行它时,出现此错误:

sh: 1: sudo: not found sh:1:sudo:未找到

It seems that the error comes from this line: 似乎错误来自此行:

os.system('echo %s|sudo -S %s' % (sudoPassword, command))# this is the line who execute the command on sudo

So tried to run it on sudo and in another log in (not sudo). 因此,尝试在sudo和另一个登录名(不是sudo)中运行它。 But still it does not work. 但是它仍然不起作用。 Anybody has an idea? 有人有主意吗? Thx 谢谢

Maybe sudo it's not in PATH or not installed. 也许sudo不在PATH中或未安装。 Have you verified it ? 你验证了吗?

That error message is saying that the python script can't find the sudo command. 该错误消息表示python脚本找不到sudo命令。 Does the bananian install have a sudo command? bananian安装程序是否有sudo命令? Do you need sudo to get the privileges you need for the usb_modeswitch command? 您是否需要sudo才能获得usb_modeswitch命令所需的特权?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM