Hi guys,
I want to autostart one file(a .cs file) when i start my raspberry pi. Can any of you have an idea how it can be done?
Hi guys,
I want to autostart one file(a .cs file) when i start my raspberry pi. Can any of you have an idea how it can be done?
What's a ".cs" file? What do it do, what purpose hav it?
(This will lead towards the answer to your question.)
AIUI a .cs file is C# source, so you'd need to compile it first. At what point during the boot sequence do you want it to run?
Hi,
Thank you for the reply. I want it to run after the start(when it lands on the home screen)
(step 1) compile it to an executable, which you'll need to do to make sure it's working anyway
(step 2) add the path to the executable as a distinct line at the end of ~/.xsession (create that file if it doesn't exist).
One way is this: Open up /home/pi/.config/lxsession/LXDE-pi/autostart
At the end, add @path_to_your_file
I have a python program that starts like this in autostart: @python /var/www/sensor/read.py
C# would need to built against a viable a .Net framework like .Net Core. Which would also need to be installed on the Pi.
It isn't something I would expect someone who doesn't know what a .cs file is to be doing.
I think it would be sensible to give a little bit more information as to what the file is and what it is intended to do.
To see if it is C# you should look at it in a text editor and see if it looks like a C# code example.
On a laptop, I use Visual Studio to compile C# to a .exe file, then move it to the Pi. On the Pi, install and use Mono to run the .exe file
Editing the file /etc/rc.local to contain your command is another way. This is independent of any user login.
Did you get it to autostart?
oh, crap... that probably means WINDOWS, too.
and here I was going to recommend editing the rc.local file
(with the assumption that your Raspbian OS doesn't have systemd, or at least recognizes /etc/rc.local like the older Raspian did)
-- your story is so touching, but it sounds just like a lie "Straighten up and fly right"
does that still work with the newer Raspbian (with systemd in it, as far as I can tell)? [I refuse to install anything with systemd on an RPi]
Hopefully it does and I'll hate systemd a little less knowing that.
-- your story is so touching, but it sounds just like a lie "Straighten up and fly right"
He never responded to that particular point, or indeed to any of the other responses to his initial post. Maybe it was C shell not C#, who knows?
C# runs on Linux too.
-- https://www.greenend.org.uk/rjk/
Doesn't much matter. Its easy enough to write your own service definition and then enable it (so it starts at boot time).
-- martin@ | Martin Gregorie gregorie. | Essex, UK
Another way (not mentioned yet, I think) of getting stuff to start on boot is to add an
@reboot
line to your crontab.
-- John
I don't think this is what the OP wants. He said "I want it to run after the start(when it lands on the home screen)" which sounds to me as though he wants his program C# program to be started when he logs in to his RPi and to stop when he logs out.
So, I think a better arrangement would be to add the startup command to .bashrc as its last line and should put a stop command, e.g. "killall progname", as the first command in .bash_logout
This needs to be done on all the logins where his program should be running while he's logged in.
-- martin@ | Martin Gregorie gregorie. | Essex, UK
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.