How to run a script automatically after login?

I found a script while searching that goes something like this:

textfile.sh in /usr/local/etc/rc.d and
Code:
textfile_enable=”YES”
written to /etc/rc.conf. It is designed to create an empty text file on the GNOME desktop, and it never fails during each boot.

My question is, how would we do the same to make this simple script run only after login, and not at boot time?
 
It sounds like you want the script to run when a user logs in to Xorg. You could add a line to ~/.xsession or ~/.xinitrc. Make sure the script is set executable and you run it in the background before the window manager is started. Of course, this will only start the script for a single user. Is this what you're looking for?
 
Is this what you're looking for?

Yes and no! Because we also will need to include the same type script under a pure version of FreeBSD which will be running as a server. It sounds like xinitrc or xsession may be the better solution for our workstations, and it has led me into believing that we could do the same by adding the script commands at the bottom of the FreeBSD (server version) login file. Since it will be permanent in our case, this may not be a problem other than learning where this file resides. Does this make sense? If so, where is this file located? I will be googling and checking the MAN pages, but we already know that this is not a common question which either may have answers for. Thank you Mr. JRM
 
I was wrong. There’s plenty of previous subject about this right here at this forum. I typed 'run script at login' in the search box and found this one, and a few others.

https://forums.freebsd.org/threads/how-to-exceute-a-shell-script-when-freebsd-start.48009/

Now I’m taking a crash course in scripting using if, then and more instead of listing commands one-by-one. I also just realize that there may be lots of ladies who are members of this forum. I think this may be one with lots of great tips.

http://www.purplehat.org/?page_id=7

Thanks again jrm.
 
Back
Top