The problem with sudo, is that it's root running for a single executable - Typically. so in cases like this:
*$ sudo apt-get update && apt-get upgrade* sudo wont work for both commands, only the first. But this is a very simplified example. Additionally, one thing that many may not know, or just may not think of is: sudo is root. So if you sudo a command, that requires a path to work. Something that is only in the users path environment won't work. Because when you run sudo, you're not your user for that single command - You're root ;) On Tue, Apr 26, 2016 at 1:17 PM, John Baker <[email protected]> wrote: > I had more trouble but finally got my desktop icon working to start up my > Python program. It turned out to be quite simple. Here's my icon file: > > [Desktop Entry] > Version=1.0 > Exec=sudo /home/debian/Desktop/paint.sh > Name=Paint > Comment=Start up SimB.py > Encoding=UTF-8 > Terminal=false > Type=Application > > and here's my script to start my Python program: > #!/bin/bash > sudo python /home/debian/Desktop/SimB.py > > I tried and tried and tried to get crontab running and systemd running but > was stymied by Tkinter errors. Tkinter requires the sudo to run my python > GUI program and I couldn't figure out how to do that with crontab and > systemd. I think there must be a way to get crontab or systemd to work to > start my SimB.py program on boot, but I couldn't figure out how to do so. > > The problems I was having a few days ago were with the Beaglebone ADC, > that it requires some delay time before re-measuring a voltage and I was > running a For loop to measure the voltage four times to get an average. > Somehow, the lack of a delay clobbered Debian. I cut out the For loop, > finding that I didn't need to do the averaging, and was able to get the > PyBBIO adcRead function to run ok. The ADC problem had not shown up > previously and of course the problem would pop up when I was trying to get > the startup icon to start my program. Very weird! > > Thanks again for all the help. > John > johnbakeree.blogspot.com > > > On Wednesday, April 20, 2016 at 9:04:45 PM UTC-7, John Baker wrote: >> >> *Some glimmer of hope*: I was able to get my Python code running, at >> least for a few seconds. I put an icon of sorts on the BBB Debian desktop; >> the icon/shortcut called an sh that started my Python code using sudo >> python myProg.py. But unfortunately it shut down in a few seconds and an >> LXDE window showed up saying something about Shut Down or Cancel or >> Something Else but the BBB shut down and I was not able to recover from the >> glitch. I started from the info by Cyril Laury at >> http://askubuntu.com/questions/299052/how-to-execute-sh-script-from-a-desktop-shortcut >> and hacked around to make a startup script. So it seems that my Python >> program is clobbering Debian, possibly with my write to a logfile. But >> that's to be determined. So hopefully I can fix the problem and then I'll >> be happy with this means to start up my Python code and will happily forget >> about crontab's and systemd's. >> Thanks for all the help and suggestions. You-all kept me going. >> John >> >> On Wednesday, April 20, 2016 at 11:46:57 AM UTC-7, John Baker wrote: >>> >>> Thanks for your help and your patience with me. >>> Unfortunately, still no joy and no error message but then I'm illiterate >>> with Linux. >>> >>> I forgot to mention that I am using PyBBIO to drive PWM output and to >>> read ADC channels and it requires me to start my GUI program with sudo >>> python SimB.py on the Debian terminal and an attached keyboard to the BBB. >>> >>> I tried the following, first without the "root" in the command and then >>> with the "root" in the command as shown in this crontab -l output: >>> >>> >>> >>> >>> I will set this aside for now and try systemd, to see if I can get some >>> kind of error message at least. >>> John >>> >>> On 4/20/2016 5:12 AM, Dennis Lee Bieber wrote: >>> >>> On Tue, 19 Apr 2016 21:52:27 -0700 (PDT), John Baker<[email protected]> >>> declaimed the >>> following: >>> >>> >>> My Python program SimB.py runs fine if I start it with sudo python SimB.py >>> using a keyboard attached to my BBB. >>> >>> Which, by default, is connected to the X-Window server running on >>> "localhost" (and which is also connected to the HDMI/LCD output). IOWs, you >>> have a full graphical environment preset for you, and Tkinter can connect >>> to the display server. >>> >>> >>> So I gave crontab a try again, putting it in /etc. Here's my crontab and >>> crontab -l which seems to say my python program is running but I don't see >>> >>> A timed background job not connected to any form of console/display. >>> >>> >>> that it has done anything, don't see anything running on my BBB 4DCAPE >>> screen. I saw something in the CronHowTo () page about GUI's but haven't >>> tried that yet, figuring that I would just try to start SimB.py and see >>> what happened. So what to do next? >>> >>> >>> Uhm... Read that how-to page? Or maybe >>> this:http://ubuntuforums.org/showthread.php?t=185993 >>> >>> >>> -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beagleboard/a8dea5d7-7e62-4ff0-9be3-51fe4cadcae2%40googlegroups.com > <https://groups.google.com/d/msgid/beagleboard/a8dea5d7-7e62-4ff0-9be3-51fe4cadcae2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CALHSORpuHZL48ZZDzigKNXMpCs37%3DjDJNnowrf60ohatEDOd5A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
