ordenrahl
Posts: 5
Joined: Sun Dec 22, 2013 6:41 am

Script to Run 4 terminal commands after Startup

Sun Dec 22, 2013 7:24 am

Aloha,
The following commands (to get a small screen working) execute just fine if I type them in from the LXTerminal window while running Raspian on a raspberry Pi once my desktop is loaded:

- sudo modprobe spi-bcm2708
- sudo modprobe fbtft_device name=adafruitts rotate=90
- export FRAMEBUFFER=/dev/fb1
- startx

I'm new to Pi and Python, and after piecing together several forum posts, the best way I thought to do this would be to run a python script from the /etc/xdg/lxsession/LXDE/autostart config file- I just don't know what the python script should say to automaticlaly open a LXTerminal window and type in the commands?

Any help would be much appreciated, thanks!

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Script to Run 4 terminal commands after Startup

Sun Dec 22, 2013 7:47 pm

I don't know raspbian or python but I do run lxterminal and bash startup scripts on my Pi with archlinux, and I don't think you have to open up lxterminal to run the script.

Your call to the script containing your commands from the autostart file will be something like:

mystarterscript.py &

You can start lxterminal after you start X, by adding a line in your script that calls lxterminal after the startx command:

lxterminal &

I am sorry I cannot put this all together for you, but at least there are some ideas to play with.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

ordenrahl
Posts: 5
Joined: Sun Dec 22, 2013 6:41 am

Re: Script to Run 4 terminal commands after Startup

Mon Dec 23, 2013 6:18 pm

Thanks sdjf,

I ended up going with editing the rc.local file and added the lines there. Iwas able to get the screen to work, but now I'm logging in as root for some reason instead of the usual [email protected] which is causing some problems with programs I've installed as the user pi.

Any Idea how to make it run as [email protected] instead of root?

Thanks,

J.

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Script to Run 4 terminal commands after Startup

Mon Dec 23, 2013 8:16 pm

Hmm, you could possibly do "su pi" and that will ask you to login and request a password. Of course, your whole point was to avoid having to do that, I do understand.

There is probably a file where you can change the default user for startup, although it might vary by which distribution you are running. anybody know?

Another possibility, I think there ought to be a way to make "sudo pi" not require a password and put that in the file, you might need to install sudo or sudoers if it is not already there. And then change that configuration so it is pi rather than root.

I don't know for sure, am just brainstorming.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: Script to Run 4 terminal commands after Startup

Tue Dec 24, 2013 9:24 am

su pi -c startx
Rather than
startx

Should get you the desired behaviour

You might also want to take a look at rungetty

Return to “Beginners”