tag:blogger.com,1999:blog-9007601562606157016.post2840285712861801216..comments2023-05-11T16:21:37.725+01:00Comments on <Stuff about="code" />: Raspberry Pi - run program at start-upMartin O'Hanlonhttp://www.blogger.com/profile/03047799173301971515noreply@blogger.comBlogger100125tag:blogger.com,1999:blog-9007601562606157016.post-75570816420906158272018-09-12T02:46:29.683+01:002018-09-12T02:46:29.683+01:00thanks man, really helpful post, thumbs up thanks man, really helpful post, thumbs up Anonymoushttps://www.blogger.com/profile/03553193940518258501noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-48053465871657095212018-05-24T11:00:22.677+01:002018-05-24T11:00:22.677+01:00I'm sorry I'm wrong in the name, the right...I'm sorry I'm wrong in the name, the right thing is ...<br /><br />Hello Martin..Anonymoushttps://www.blogger.com/profile/02561141281586435201noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-14589121051892162622018-05-24T08:40:03.074+01:002018-05-24T08:40:03.074+01:00Hello Laurent:
I have a problem that can not be s...Hello Laurent:<br /><br />I have a problem that can not be solved, I'll explain.<br /><br />In Init.d I have the script set and it works when booting, but the strange thing is that everything works, except for a UDP sending parameter.<br /><br />The command that I tell you to execute is this .....<br /><br />./acarsdeco2 --gain 49 --freq-correction 15 --freq 131511000 --freq 131711000 --freq 131811000 --outConnectUdp pp: 192.168.1.128: 9742 --http-port 8998<br /><br />Everything works except --outConnectUdp pp: 192.168.1.128: 9742<br /><br />Well the funny thing is the following, if I run it through the console, it works perfect, if I execute it via init, d, that parameter fails.<br /><br />What could happen?<br /><br />Thank you very much.Anonymoushttps://www.blogger.com/profile/02561141281586435201noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-82578354160132725912017-12-11T04:36:38.810+00:002017-12-11T04:36:38.810+00:00Thx a lot man, your snippet very helpful and easy ...Thx a lot man, your snippet very helpful and easy to use!Anonymoushttps://www.blogger.com/profile/07366687966510408782noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-12627127610433960812017-11-15T08:06:47.937+00:002017-11-15T08:06:47.937+00:00Hi,
I'm having a little issue with my conten...Hi, <br /><br />I'm having a little issue with my content. I needed to test if a straightforward content that I as of now had composed begins on boot. It does, be that as it may I didn't consider including an approach to stop the content and now I can't sign in to my Raspberry. CTRL+C doesn't fill in and additionally some other summons I attempted. I had a go at hunting down an approach to stop the content physically yet I didn't discover anything valuable. Any proposals?<br /><br />Regards,<br /><a href="http://www.trephelix.com/" rel="nofollow">Trep Helix</a>Anonymoushttps://www.blogger.com/profile/16808282943044266213noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-53838939986870418742017-10-18T16:51:24.395+01:002017-10-18T16:51:24.395+01:00Added an & at the end of sudo python Thermomet...Added an & at the end of sudo python Thermometer.py and now it runs. I am getting the echo statement along with an error message, but the script runs anyway. Go figure. ThanksKC8ZTJhttps://www.blogger.com/profile/13203167424907626347noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-36369899634272784312017-10-11T19:51:02.301+01:002017-10-11T19:51:02.301+01:00Well, did some more reading of your script. I lef...Well, did some more reading of your script. I left out the "# If you want a command to always run, put it here", I put sudo python Thermometer.py and now the script runs sort of. My py program reads an attached temperature sensor every two minutes and sends it to an IoT site for display. When I put in sudo /etc/init.d/Thermometer.py start, my program will go thru one cycle and then stop. I also do not get the echo statement. KC8ZTJhttps://www.blogger.com/profile/13203167424907626347noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-32972314703661319182017-10-10T21:51:50.629+01:002017-10-10T21:51:50.629+01:00Yes I did. I used sudo chmod 755 /etc/init.d/Therm...Yes I did. I used sudo chmod 755 /etc/init.d/Thermometer.pyKC8ZTJhttps://www.blogger.com/profile/13203167424907626347noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-85378047110948367182017-10-10T08:21:57.321+01:002017-10-10T08:21:57.321+01:00Did you make the script executable?Did you make the script executable?Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-57987877754470472542017-10-09T21:43:52.888+01:002017-10-09T21:43:52.888+01:00Matin, I have tested my script and it works from b...Matin, I have tested my script and it works from bash but when I try to run sudo /etc/init.d/Thermometer.py I get the message below. <br /><br />Starting Thermometer.py<br />/etc/init.d/Thermometer.py: 24: /etc/init.d/Thermometer.py: /home/pi/Thermometer.py: Permission deniedKC8ZTJhttps://www.blogger.com/profile/13203167424907626347noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-39139504898657832912017-10-05T10:47:38.108+01:002017-10-05T10:47:38.108+01:00chmod 755 makes a script executable. In your examp...chmod 755 makes a script executable. In your example 'python' is the program and it is already executable so you dont need to.Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-2296797557966554042017-10-02T17:35:15.211+01:002017-10-02T17:35:15.211+01:00Hello Martin, I am writing a python script to meas...Hello Martin, I am writing a python script to measure temperatures and would like my pi zero to start the script when it boots up. After looking at your code to start the no-ip program, I am wondering how to start the python script that usually requires "sudo python Temperature.py" in bash. Should the I amend youur "sudo chmod 755 /etc/init.d/NameOfYourScript" to include the python Temperature.py? KC8ZTJhttps://www.blogger.com/profile/13203167424907626347noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-79576316725560404352017-08-21T12:50:15.399+01:002017-08-21T12:50:15.399+01:00Hi Martin, I used the version with init.d and it a...Hi Martin, I used the version with init.d and it almost works. If I start the script with command "sudo /etc/init.d/NameOfYourScript start", I can see the output of my script on tty (which is what I want). If I enter the command "sudo update-rc.d NameOfYourScript defaults", I know the script started, because it beeps at startup, but I can't see the text messages. How can I direct the output to tty?Nicolaehttps://www.blogger.com/profile/17008327180969510314noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-30947081422642939312017-06-25T05:09:38.925+01:002017-06-25T05:09:38.925+01:00thanks so much!!thanks so much!!Anonymoushttps://www.blogger.com/profile/13119153069067118362noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-80618567687698897232017-06-14T10:58:54.988+01:002017-06-14T10:58:54.988+01:00Im not sure. All init.d scripts are run as root as...Im not sure. All init.d scripts are run as root as that probably cant be changed. <br /><br />In the init.d script could you run your script using runuser (https://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/)?Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-17304177103060057782017-06-13T19:18:58.457+01:002017-06-13T19:18:58.457+01:00Hi,
it works fine and instruction are very clear !...Hi,<br />it works fine and instruction are very clear !<br />One question : how would you make the script running as pi user ? mine is running as root. I'm quite new in linux so i can't get it ...<br />thanks,<br />Guillaume<br />Guillaumehttps://www.blogger.com/profile/07766203924944440079noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-24148713752918981882017-05-10T16:40:15.669+01:002017-05-10T16:40:15.669+01:00Its because line 10 of what you copied wrapped to ...Its because line 10 of what you copied wrapped to line 11. Joing the two lines or start line 11 with the octothorpe ('#').Anonymoushttps://www.blogger.com/profile/11207449010172947549noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-33152796300467620292017-04-05T20:38:18.309+01:002017-04-05T20:38:18.309+01:00I've been following this tutorial which refere...I've been following this tutorial which references your script:<br /><br />The script works great but when I do the [sudo update-rc.d autoconnectnet defaults] command it doesn't work... can you give any advice please? I assume I've done something wrong but i dont get an error so can't guess what<br /><br />https://lawrencematthew.wordpress.com/2013/08/07/connect-raspberry-pi-to-a-3g-network-automatically-during-its-boot/Anonymoushttps://www.blogger.com/profile/09390299101222661675noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-73856800585223800502017-03-15T13:53:33.522+00:002017-03-15T13:53:33.522+00:00Thanks for the good explanations!
I'm trying ...Thanks for the good explanations!<br /><br />I'm trying to get usb_modeswitch to run on reboot. I have made a script with the help from this article. It seems to work, but to early to be able to do anything. Actually it's the second first output to /var/log/messages after reboot:<br /><br />Mar 15 13:37:27 navio rsyslogd: [origin software="rsyslogd" swVersion="8.4.2" x-pid="515" x-info="http://www.rsyslog.com"] exiting on signal 15.<br />Wed 15 Mar 13:37:30 UTC 2017<br />ff Script without spec<br />ff Starting usb_modeswitch ff<br />Mar 15 13:37:30 navio rsyslogd: [origin software="rsyslogd" swVersion="8.4.2" x-pid="522" x-info="http://www.rsyslog.com"] start<br />Mar 15 13:37:30 navio kernel: [ 0.000000] Booting Linux on physical CPU 0x0<br />Mar 15 13:37:30 navio kernel: [ 0.000000] Initializing cgroup subsys cpuset<br />Mar 15 13:37:30 navio kernel: [ 0.000000] Initializing cgroup subsys cpu<br />Mar 15 13:37:30 navio kernel: [ 0.000000] Initializing cgroup subsys cpuacct<br />Mar 15 13:37:30 navio kernel: [ 0.000000] Linux version 4.4.6-4d0ae01-emlid-v7+ (root@kernelcruncher) (gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu1) ) #3 SMP PR$<br /><br /><br />This is what the script looks like:<br /><br />#! /bin/sh<br /><br />### BEGIN INIT INFO<br /># Provides: usb_modeswitch<br /># Required-Start: $remote_fs $syslog $all<br /># Required-Stop: $remote_fs $syslog<br /># Default-Start: 2 3 4 5<br /># Default-Stop: 0 1 6<br /># Short-Description: Simple script to force usb mode swich<br /># Description:<br />### END INIT INFO<br /><br /><br />(date && echo 'ff Script without spec') >> /var/log/messages<br /><br /># Carry out specific functions when asked to by the system<br />case "$1" in<br /> start)<br /> echo "ff Starting usb_modeswitch ff" >> /var/log/messages<br /> # run application you want to start<br /> /usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.conf<br /> ;;<br /> stop)<br /> echo "ff Stopping nothing ff" >> /var/log/messages<br /> # kill application you want to stop<br /> ;;<br /> *)<br /> echo "ff Other ff" >> /var/log/messages<br /> exit 1<br /> ;;<br />esac<br /><br />exit 0<br /><br />If I put the action in /home/pi/.bashrc it works but I would like it to work before login.<br /><br />Grateful for any tipps! /Fredrik<br />Anonymoushttps://www.blogger.com/profile/14590187408819899784noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-76396874311245781492016-12-12T18:51:02.523+00:002016-12-12T18:51:02.523+00:00Hi firts thanks you, this help me a lot but
My pro...Hi firts thanks you, this help me a lot but<br />My problem: when i follow the steps and i reboot the raspPI it works find but when i shutdown the raspPI doesnt work any more<br />What i try: Google the problem, find syntaxis errors, change the permisions, corret the python scripts<br />Doudts: i try to star de script but doesnt do anything<br />Sebastian Duranhttps://www.blogger.com/profile/04481627332188260291noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-89321938555770167292016-12-12T18:43:00.619+00:002016-12-12T18:43:00.619+00:00what do you change??
what do you change??<br />Sebastian Duranhttps://www.blogger.com/profile/04481627332188260291noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-89582289500375652822016-10-11T21:08:40.250+01:002016-10-11T21:08:40.250+01:00You will need to make your script executable befor...You will need to make your script executable before you can run and test it. In my experience its pretty difficult to break a computer. If you are worried, take your SD card out of the Pi, stick it in a computer, create an image of it as a back up, and if the worst comes to the worst you can just re-image your SD from your backup.Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-58952967060831055242016-10-11T15:52:16.252+01:002016-10-11T15:52:16.252+01:00So this may sounds stupid but how would you go abo...So this may sounds stupid but how would you go about testing before you make the script executable. It's my first time doing any of this and I don't want to like break the computer or something. Thank you Anonymoushttps://www.blogger.com/profile/01179686750453603386noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-50581546782594312932016-10-02T18:28:30.346+01:002016-10-02T18:28:30.346+01:00Thanks for this Martin,
You were an absolute inspi...Thanks for this Martin,<br />You were an absolute inspiration at Picademy earlier this year and now your fabulous blog has helped me to write my first 'run at startup' script. I was slightly lost and it didn't actually work... but it was a triumph nonetheless!<br />Thank you,<br />PabloAnonymoushttps://www.blogger.com/profile/06803288357087683445noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-50378167185774947262016-09-23T06:43:26.940+01:002016-09-23T06:43:26.940+01:00Fantastic post- worked for me and DynamicDNS right...Fantastic post- worked for me and DynamicDNS right off the bat!Anonymoushttps://www.blogger.com/profile/10920104253932502620noreply@blogger.com