jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

run terminal command at boot

Sat Aug 13, 2016 3:11 pm

Hello,

I'm trying to run the following command at boot to run noVNC for remote access via Dataplicity.

I presume the easiest way is to create a file in etc\init.d
Is it as easy as just putting the commands below into a file?

cd noVNC
./utils/launch.sh --vnc 127.0.0.1:5901 --listen 80

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: run terminal command at boot

Sat Aug 13, 2016 3:50 pm

jondallimore wrote: I presume the easiest way is to create a file in etc\init.d
Is it as easy as just putting the commands below into a file?
cd noVNC
./utils/launch.sh --vnc 127.0.0.1:5901 --listen 80
1. This is linux, the separator is /

2. When you write etc/init.d , what you are saying is that you want some file or directory that is relative to the current one. When you don't know what the current one is or it might not be a specific one, you should write the path out fully: /etc/init.d

3. 127.0.0.1 is only available locally.

4. Usually using ports that are 1024 or below is only available to root on linux although there are workarounds in some cases.

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Sat Aug 13, 2016 4:36 pm

If all you have to say is to be picky about things, then dont bother replying.

If anyone has anything useful to say, please feel free.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: run terminal command at boot

Sat Aug 13, 2016 5:23 pm

Being "picky" about things is how you solve most problems when you have things misconfigured.

Since you're using Dataplicity, try their documentation, it's going to be way more helpful. https://docs.dataplicity.com/docs/make- ... or-your-pi
Account Inactive

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Sat Aug 13, 2016 6:15 pm

I havnt got things 'misconfigured'. Ive followed the documentation and everything works.

All I'm asking is how to run a command on boot.

If you know the answer, then great. If not, dont reply. Its that simple.

W. H. Heydt
Posts: 11067
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: run terminal command at boot

Sat Aug 13, 2016 7:44 pm

jondallimore wrote:If all you have to say is to be picky about things, then dont bother replying.

If anyone has anything useful to say, please feel free.
Computers are *stupid*. Being picky matters.

W. H. Heydt
Posts: 11067
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: run terminal command at boot

Sat Aug 13, 2016 7:55 pm

jondallimore wrote:I havnt got things 'misconfigured'. Ive followed the documentation and everything works.

All I'm asking is how to run a command on boot.

If you know the answer, then great. If not, dont reply. Its that simple.
There are multiple ways to run things at boot. Init.d is one. If you don't need X running, then it can be done with a cron entry "@reboot". If you need X to be up (and you are running with the autologin on), then put it at the end of ~/.config/lxsession/LXDE-pi/autostart .

Bear in mind, particularly with cron, that your normal environment isn't set up, so you may need a PATH set and possibly other variables.

As already noted a bare "cd <directory>" without a leading "/" is relative to where you are. For anything other than the autostart method, you need an absolute path. Since you are running two commands, if you use @reboot, either separate the commands with a semicolon or put it all in a shell script and give the absolute path to that shell script. Using a shell script has the advantage that you can specify your choice of command interpreter (bash, sh, csh, etc.) as well as setting any environment variables you may need.

One last bit of advice...no one here is being paid to help you. Lose the chip from your shoulder or you may find future help a little thin on the ground.

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: run terminal command at boot

Sat Aug 13, 2016 8:34 pm

Everyone who has replied to you has taken time out of their day to provide you with valuable information - the answers I've read are both useful and correct. When asking questions of people who know more than you about a subject, it is generally considered proper behavior to be polite. In particular, everything stderr said was true, and each bit was offered in order to help save you from needlessly falling into several obvious pitfalls that he could see you were heading towards, that could potentially waste hours of your time trying to figure out what happened. And you responded to this kindness of his with, "dont bother replying". That is not polite. Perhaps you should apologize.

Computers are picky. That is inherent in their nature. Linux will never give you a B+ for effort because you tried, things either work or they don't. If you aren't willing to care about getting the details actually right, then perhaps computers are just not for you, and you should seek a less-demanding hobby.

Complaining that people who are under no obligation to help you are being picky because they are explaining how to make things actually work, rather than how to make things sort of almost work... is a great way to get people to not bother helping you.

And the cheapest (quickest but not necessarily best) way to run a command at boot would probably be to add it to the end of /etc/rc.local. Likely something like this:

( cd /home/pi/noVNC; ./utils/launch.sh --vnc 127.0.0.1:5901 --listen 80; ) &

although the data you provide leaves out too many details to be certain that this will work.
Last edited by CarlRJ on Sat Aug 13, 2016 8:46 pm, edited 1 time in total.

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Sat Aug 13, 2016 8:46 pm

I absolutely appreciate people who make an effort to answer the question.

People who "take time out of their day" to do nothing more than correct others on the most minor of things must simply have nothing better to do.

I understand that some people make assumptions - perhaps they shouldn't. I asked a straightforward question, a straightforward answer or a request for more information is all that is needed - not people getting uppity because I put a / instead of a \ in a forum post.

Anyone who explains how to make things actually work - fair play.
Anyone who moans about the wrong / in a post - I consider THAT to be impolite.

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: run terminal command at boot

Sat Aug 13, 2016 8:53 pm

jondallimore wrote:not people getting uppity because I put a / instead of a \ in a forum post.
...
Anyone who moans about the wrong / in a post - I consider THAT to be impolite.
Why get so defensive when someone points out that the thing that you wrote WON'T WORK the way you wrote it. It is not "moaning", "making assumptions" or "getting uppity", it is responding to precisely what you wrote.

This forum is not here solely for your personal benefit. Questions get asked, and they get discussed. You benefit from the answers, and so do other people now and in the future. That is the nature of this forum (I personally have benefited considerably from past discussions on this forum that I have found and read). If you want your question answered in a hurry, with no discussion, no information available to others in the future, and no politeness on your part, there are consultants who will gladly do so, on the clock, for a substantial fee. You're not paying anyone here enough to be able to order them around. We are not your servants. Telling people to shut up unless they're specifically answering the exact question you have in mind is impolite.

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Sat Aug 13, 2016 9:40 pm

Get over yourself.

Discussion is fine, I welcome it. I dont want or need an answer immediately.

What I am asking for, quite simply, is a discussion about the question I asked.

The first reply didnt do that - he or she decided that they would instead pick up on minor mistakes in a forum post and ignore the question altogether. There was no attempt to answer the question, and no attempt to ask for more information, simply a rant about the fact that something quite minor was slightly incorrect on the posting.

Thanks to those who have made an effort to help, I have now got where I need to be with this.
Those who think I am being rude - you could not be more wrong. I simply will not accept people being condescending and petty.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2152
Joined: Thu Jul 11, 2013 2:37 pm

Re: run terminal command at boot

Sun Aug 14, 2016 5:50 pm

@jondallimore,

Please take the corrections in the spirit in which they were offered (i.e. rectifying syntax errors or errors in commands).

There is no "getting over yourself" when typing a command into a computer. It either works or it doesn't, and the usual cause for the not-working case is user error.

Granted, an explanation as to *why* the commands as written failed rather than correction presented without advice would be preferable to novice users. That goes for all respondents in this thread that offered terse solutions rather than explanations.
Rockets are loud.
https://astro-pi.org

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: run terminal command at boot

Sun Aug 14, 2016 8:01 pm

My terse response was a link to a very complete and detailed guide that explained exactly how to solve the issue. Including SysV initscripts with the exact solution. I guess I could copy and paste the code, but since the OP was using Dataplicity, wouldn't a link to the instructions that Dataplicity has deemed as being the way to run the daemons on their platform be sufficient?
Account Inactive

Heater
Posts: 13878
Joined: Tue Jul 17, 2012 3:02 pm

Re: run terminal command at boot

Sun Aug 14, 2016 8:23 pm

The "proper" way to do this on Debian 8/Raspbian is to use systemd. systemd is what starts everything.

Create a systemd service file that contains something like this:

Code: Select all

[Unit]
Description= My funky program
After=network.target

[Service]
ExecStart=/home/pi/MyFunky/MyFunky
WorkingDirectory=/home/pi/MyFunky
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MyFunky
User=root
Group=root
Restart=always
[Install]
WantedBy=multi-user.target
Place that service file in /etc/systemd/system/MyFunky.service

Start your program with:

$ sudo systemctl start MyFunky

Stop your program with:

$ sudo systemctl stop MyFunky

Enable you program to be run at boot time with:

$ sudo systemctl enable MyFunky

You can stop it running at Enable boot time with:

$ sudo systemctl disable MyFunky

Of course change "MyFunky" and paths etc to be what you want for your program.

Have a google around for systemd service for more info.
Memory in C++ is a leaky abstraction .

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Mon Aug 15, 2016 12:30 am

"get over yourself" referred to the posters attitude, nothing to do with computing at all.

The link to Dataplicity documentation was something I had already looked at and it did not help me with the specific aspect I asked about. Perhaps look at the documentation before posting the link?

I'm afraid some people came across as offering advice in the spirit of looking down their noses and an assumption of superiority. Im sure that was unintentional, but perhaps people should read what they type carefully and think about how it comes across to others.

Having said all that, there have been several very useful replies and I have now got this issue sorted. Thankyou to those who helped, and if I'm ever able to help you, I certainly will.
I consider this thread closed now.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: run terminal command at boot

Mon Aug 15, 2016 12:49 am

I have been a member of this forum and have volunteered my time and efforts to help others with their problems. You have successfully helped make up my mind that this is no longer a place for me.

So long and thanks for all the fish.
Account Inactive

User avatar
CarlRJ
Posts: 599
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: run terminal command at boot

Mon Aug 15, 2016 3:21 am

SonOfAMotherlessGoat wrote:So long and thanks for all the fish.
SonOfAMotherlessGoat, you and I may share similar opinions of the OP, but his defensive self-centered attitude is not representative of the majority of the people on this forum. I have enjoyed and benefited from comments I've seen you post on the forums here. Please don't leave on his behalf.

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Mon Aug 15, 2016 11:27 pm

Im not sure how anyone could describe my attitude as "defensive and self centred"

I dont like people who pick up on little things whilst ignoring the actual problem, and I said so.

It seems some people on here dont like that. That is their problem, and I will continue to say exactly what I think regardless of whether others like it or not. Its a shame that so many think its their place to be pedantic and then take offence when told that they are pedantic.

Meanwhile, those people who actually looked at my problem and helped me fix it have been wonderful, thankyou.

This is about the third time I have said that - never has the phrase "get over yourself" had greater relevance. Its not about me, its not about you, so we will agree to disagree. Or at least, I will. What you do is up to you.

W. H. Heydt
Posts: 11067
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: run terminal command at boot

Mon Aug 15, 2016 11:41 pm

jondallimore wrote: I dont like people who pick up on little things whilst ignoring the actual problem, and I said so.
Many people here are "detail oriented" because that's what it takes to get a computer to do what you want. In my experience, it is a common trait among Engineers, and especially that subset of Engineers that are Programmers. Complaining that people in a computer support forum "pick on little things" is complaining about their most obvious and useful characteristic. Fail to get the "little things" right and it doesn't matter how good the grand sweep of your plans are right, they still won't work.

Heater
Posts: 13878
Joined: Tue Jul 17, 2012 3:02 pm

Re: run terminal command at boot

Mon Aug 15, 2016 11:43 pm

jondallimore,

Thing is, this is the internet. When you speak here you are speaking to the entire human population of the planet.

Naturally there will be all kind of replies coming back you don't like.

Meh, shrug it off.

Not worth getting agitated about.
Memory in C++ is a leaky abstraction .

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: run terminal command at boot

Tue Aug 16, 2016 2:06 am

SonOfAMotherlessGoat wrote:I have been a member of this forum and have volunteered my time and efforts to help others with their problems. You have successfully helped make up my mind that this is no longer a place for me.

So long and thanks for all the fish.
This is a trend I've noticed for a while now, many of the 'regulars' are gone. Perhaps it's time for us old timers (in terms of Pi ownership and use) to give way to the new generation?

jondallimore
Posts: 218
Joined: Thu Aug 04, 2016 11:02 pm

Re: run terminal command at boot

Tue Aug 16, 2016 8:20 am

It honestly doesnt bother me if people pick up on little things.
It irritates me when thats ALL people do. Pick up on little things whilst trying to help - fine. Being picky for the sake of it - not fine.

Im quite happy most of the time to let it go with replies that are less than useful. Occasionally, I feel it simply needs to be said. I have in the past posted asking if something would work or if changes were needed and recieved just "No" as an answer - utterly pointless. If you have nothing useful to add - dont reply. Let others try to help if they can. The goal of a forum, surely everyone can agree, is to move the discussion forward.

As for people leaving - perhaps those are the people that need to get over themselves.
I tend to find sometimes the longer someone is on one of these forums, the less useful their posts are. All I ask is that people stop and think - is a post or a reply useful? Will it actually help someone - or is it just petty nonsense which fails to move the discussion forward.

Sorry if anyone thinks I've been rude in trying to make this point - thats not my intention. I thought I asked a fairly straightforward question originally, and I appreciate all attempts to move the discussion forward and the various solutions offered. I also do not appreciate the pedantry and seeming arrogance of some of the others.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: run terminal command at boot

Tue Aug 16, 2016 10:19 am

Locking now as it's gone off topic.

Be civil to each other please. A bit of give and take is needed. We're all different and text-based communication is limited. :D
Alex Eames RasPi.TV, RasP.iO

Return to “General discussion”