Auto start files on startup

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?
Reply to
Pradeep Shanmugam
Loading thread data ...
What's a ".cs" file? What do it do, what purpose hav it?
(This will lead towards the answer to your question.)
Reply to
Roger Bell_West
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?
Reply to
Rob Morley
Hi,
Thank you for the reply. I want it to run after the start(when it lands on the home screen)
Reply to
Pradeep Shanmugam
(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).
Reply to
Roger Bell_West
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
Reply to
4ctestsystems
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.
Reply to
Nick
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
Reply to
4ctestsystems
Editing the file /etc/rc.local to contain your command is another way. This is independent of any user login.
Reply to
Mel Wilson
Did you get it to autostart?
Reply to
4ctestsystems
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"
Reply to
Big Bad Bob
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"
Reply to
Big Bad Bob
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?
Reply to
Rob Morley
C# runs on Linux too.
--
https://www.greenend.org.uk/rjk/
Reply to
Richard Kettlewell
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 
 Click to see the full signature
Reply to
Martin Gregorie
Another way (not mentioned yet, I think) of getting stuff to start on boot is to add an
@reboot
line to your crontab.
--
John
Reply to
John Aldridge
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 
 Click to see the full signature
Reply to
Martin Gregorie

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.