start a program when I login, not boot
running slackware 10
I would like to have a program run when I log in from the non GIU interface, the basic one with slack. I just dont know where to add the script. Its a program that all users have access to. I see alot of post regarding starting a program at boot, but few regarding login, that have helped. One post did say it does not matter to start a program at login, that you can just start it at boot, and every user will be able to access it PS it needs an internet connection to work, so I would need it to run after my internet connection has been established |
Add your script to ~/.bash_profile. As I understand it .bash_profile is only executed when you first login, not like ~/.bashrc which is executed for every instance of bash
|
where do i find ./bash_profile???
I used the find -name command with no luck. |
Quote:
Quote:
LocoMojo |
It doesn't exists by default, just create it.
|
Thanks, I found it along with some other interseting things.
Is there anything I have to include in there other then the path to the program I want to run, along with the program name. cause it did not work when I logged on. example... /directory/directory/program_to_run thats the only line in my .bash_profile |
Quote:
Quote:
If it is not in your path then you have two choices: 1. Use absolute paths to call it, i.e., /usr/local/bin/program & (use & to send it to the background so you still have access to your console/xterm). 2. Put the program in your path. For example, if the program in question is in /usr/local/bin , but /usr/local/bin is not in your path then you need to issue the follwoing: Quote:
LocoMojo |
Quote:
I'll post my script to save some time. export PATH=$PATH:/usr/BOINC echo $PATH run_client & or /usr/BOINC/run_client & ive tried both with no luck |
Quote:
Is it called "run_client"? If so, is run_client a binary? Don't type "echo $PATH run_client &". Only type "echo $PATH" to see what directories are currently in your path. It is used for information only. If "run_client" is a binary and if it is in your path then you will only need to type "run_client" without the quotes. If "run_client" is in a directory that is not currently in your path then you need to put the directory (not the program) in your path. For example, if "run_client" is in the /usr/bin directory then you would do "export PATH=$PATH:/usr/bin". After that you will be able to type "run_client" and the program will run. Another way to determine whether "run_client" is in your path is to type "which run_client" without the quotes. If it is in your path it will show you the directory it is in. If it's not in your path it will say something like "no run_client found in this directory, that directory or that other directory". If you know exactly where "run_client" is, can you type "file /path/to/run_client" and then post back here what it says? LocoMojo |
the program is called run_client
dont know how to tell if its a binary, but all i have to do to run it is cd to its directory, and type "run_client &" and it will un for me in the background. I did use the command export PATH=$PATH:/usr/BOINC which is the path I need. When I do that it does allow me to run run_client from my home directory without having to cd to the programs directory. however once I logoff that directory is gone from my home path. So would this be the script to run??? #!/bin/bash export PATH=$PATH:/usr/BOINC run_client & with regards to file /usr/BOINC/run_client I get this result... /usr/BOINC/run_client: ASCII text |
Quote:
|
Quote:
Must be a script, I guess. Still, it should say something like "Bourne again script, executable". Anyway, if you want it to stay in your path after you log out and in then you should do this: 1. Go to your home directory and type "touch .bashrc" without the quotes. 2. Open .bashrc with your favorite editor and type the following: # .bashrc # myExports export PATH=$PATH:/usr/BOINC Then save the file. From then on every time you log in and open your xterm "run_client" will be in your path. If you ever decide to take it out of your path, for whatever reason, just comment it out by typing a "#" at the beginning of the "export" line. One thing though...be sure that your .bash_profile says: Quote:
Good luck! LocoMojo |
didnt work. input exactly as you have it, in both files.
is it possible that when I log in from the CLI (runlevel 3) that its not even looking for .bash_profile ??? I thought I read somewhere that .bash_profile was for logging in with a GUI. |
From O'Reilly's 'Learning the Bash Shell', 3rd edition (pg 57):
.bash_profile is read and executed only by the login shell. If you start up a new shell (a subshell) by typing bash on the command line, it will attempt to read commands from the file .bashrc. In other words, .bash_profile is run when you login at the CLI in run level 3. |
how do I know if its reading it or not??
should I not get error messages for wrong paths ro anything I am doing wrong. I have since set it up to run when I boot, by adding some script to the rc.local file. It took a few boot attempts before I got the scipt right. However everytime I got it wrong I was able to see boot errors telling me either the path didnt exist, or couldnt find the command etc... Should i not see errors via the login methdod like i do with the boot method??? |
All times are GMT -5. The time now is 07:15 AM. |