0

there's probably a way to do this but I've been searching for hours with no solution in sight. I'm also an amateur at this so my level of knowledge on this is minimal.

what I'm looking to do is have a normal terminal open once I log in and then enter these commands

cd /home/pi/Downloads/pi-weather-station
npm start

here's what it looks like when I do it manually

pi@raspberrypi:~ $ cd /home/pi/Downloads/pi-weather-station
pi@raspberrypi:~/Downloads/pi-weather-station $ npm start
npm WARN npm npm does not support Node.js v10.21.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

> pi-weather-station@1.0.0 start /home/pi/Downloads/pi-weather-station
> node ./server/index.js

pi-weather-station v1.0.0 has started on port 8080
2
  • Does executing /home/pi/Downloads/pi-weather-station/npm start do what you want? If you can remove the cd command, you could easily put it in rc.local or systemd. But systemd is better - look it up on Google – Unsigned_Arduino Nov 1 '20 at 17:50
  • the command you suggested says no file or directory with that name I edited the post to show what it looks like when I do it manually – Nathan Radtke Nov 1 '20 at 18:26
2

I assume you are login to the default Graphical User Interface LXDE of the Raspberry Pi OS.

what I'm looking to do is have a normal terminal open once I log in and then enter these commands

the bash script ~/.profile is executed on login, so you can append this line at the end:

lxterminal --working-directory=/home/pi/Downloads/pi-weather-station --command='npm start' &

Please note the & at the end. Without it, .profile will not finish. If the terminal immediately closes after running the command, then try this line:

lxterminal --working-directory=/home/pi/Downloads/pi-weather-station --command='/bin/bash -c "npm start; /bin/sleep infinity"' &

and close it with Ctrl+C.

1
  • thank you! it worked and the command makes sense to me seeing it as I needed it applied – Nathan Radtke Nov 2 '20 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.