Quote:
Originally Posted by guanx
1. su - USER_NAME -c YOUR_COMMAND
This will setup your environment. I always do so.
|
Quote:
Originally Posted by guanx
2. If you didn't follow 1., you could still use
HOME=/ screen -r
to re-attach your session.
|
I know this, but that's no use to me if I want the programs to run in a screen from the very start of the computer booting up. I'd use Virtual Consoles but they really only work when you are local.
Just as an example of the type of usage:
1) Computer runs, say, iptraf, kismet or other console-based program, at startup without any user having to login (blackbox systems).
2) Occasionally I need to login remotely to the device, and see the output of iptraf in a nice graphical way (yes, I can grep logs etc. but that's not what I want to do for a quick check) but I need to see an iptraf that was running from the second the computer was up on the network.
Running it in a screen works perfectly because you can login remotely, resume the screen and see/interact with the program which was running from the first boot and will continue running until you switch the machine off. You can also show that same screen on a VC at the same time. However, screen doesn't want to work (lately, I've done this before, though) from an init script because of this environment issue. The environment gets set up the second you login or su to root, but that's *too late* for the program.
Some of the programs I want to use will even refuse to start if they don't have $HOME set up to a nice writable folder (i.e. something other than /) when you run then, so you end up with, out of seven programs I want to run in this fashion, three running on screens that you have to faff about to connect to and four processes which just die instantly.
I don't really want to play with $HOME from within the rc.local script but if I need to, I will. I just wondered what change was made to do this and why it was made... I've definitely done this before on slackware without problems (not that long ago, either).