jturnbul,
I think I misunderstood you. I thought you were just trying to put a program in your path so that you could call it from the CLI. I don't know how I missed it, but you were actually asking how to have the program start up automatically when you logged in...correct? I've just re-read the thread and I noticed that you wanted the program to start up when you logged in, but not when the machine booted. I'm assuming that you want the program to only start up for you and not any other user...correct? If you wanted it to start up automatically upon boot, you would put it in the /etc/rc.d/rc.local script. I've never had the occasion to start up a program only for a particular user because on my machine I am the only user so everything I have automatically starting up, starts up at boot, not the login. You say you're booting into run level 3 so obviously you're not booting into KDE or any other GUI environment. If you were then you could simply run the program in question then log out without shutting that program down, saving the session and then the program would run every time you logged into that saved session. As for logging into the console rather than X, I would imagine that anything in your .bashrc would run upon login. Rather than just export the path you would also want to put the actual program in the .bashrc like this: /usr/BOINC/run_client & Of course, you would need to leave the export line in that you put in earlier so that the program would be in your path. Make sure the export line is before the program call. In other words your .bashrc should look like this: Quote:
One question though. Does that "run_client" program require X? Is it a GUI program? If it is, then it won't work when you log in at run level 3. Sorry for my misunderstanding. Hope this helps this time. LocoMojo |
I wouldn't put it in ~/.bashrc because if you were to login, startx, then launch a few virtual terminals, that program will be executed for each instance of the terminal.
You can try this little test to make sure .bash_profile is being read when you login: Add 'echo "Hello World!"' to the end of ~/.bash_profile, without the single quotes. Logout and and then log back in again and somewhere in all the details before the prompt is given to you you should see the words "Hello World!" in there somewhere |
Quote:
You know, I hadn't thought of that. You're so right. However, this is also true for the .bash_profile. I just tried it with /opt/kde/bin/kcalc and I opened 3 instances of xterms and got 3 instances of kcalc. There's probably a very simple way to pull this off. Perhaps a simple bash script which is called upon login and checks to see if "program" is running, if not, execute it? LocoMojo |
Here's a little script I just wrote:
Quote:
Quote:
I'm sure there's a more elegant way of approaching this, but I'm a newbie and this is the idea I came up with. Maybe someone else will come along and say "why don't you just do this stupid...." LocoMojo |
According to the man page .bash_profile is only executed for login shells.
Ok, my linux machine is headless and I use putty to ssh into it, but I can use screen to test this. I added `echo "Hello World!` to ~/.bash_profile. I now launch a new bash session within screen (`screen bash`) and the prompt is given to me, I then launch another bash session within screen but give bash the --login argument (`screen bash --login`), the words "Hello World!" are printed then the prompt is returned. As I understand it this is correct behaviour - ~/.bash_profile is only run for login shells. Perhaps something in your configuration is making all your terminals login shells or something is making .bash_profile be included for all terminals |
Doh!
I'm such an idiot. I was using my Konsole icon on my kicker in KDE which is configured with the command "konsole -ls", konsole login shell. You're right, my bad. LocoMojo |
You are digging in the wrong place, I think.
You want to log in with KDE or GNOME (or another desktop manager) and have your program run automatically right? The thing you have been trying to do will only work when you log into a console or open a xtem/konsole on the GUI. There are two ways two approach it: most desktops will have a entry in the menu for programs to run after startx or [xdm/gdm/kdm]. Try that out first as it is more userfriendly (somehow I can't find one now on this system...?). The other option is to edit the .Xsession file(s) in your home directory, but I don't know if that would interfere with the normal startup procedure. To make sure that an init-script (that is something different indeed) is called after the network is up, one would need to make sure that the links in the rc directories pointing to it begin with a higher number in their name. If your setup will wait for a dhcp reply in the background, this may not work. In that case you'll need to write some shellcode around the calll to your daemon that checks if an interface is up. But I don't think you want that. |
Quote:
He said in his first post... Quote:
LocoMojo |
Quote:
If you want the program to run when anybody logs in then you could place the command in /etc/profile. However, rather than muck with the original scripts, consider creating a separate script and place that script in /etc/profile.d. All scripts stored in that directory are run from within /etc/profile. Name the script anything you want, but ensure the script uses an sh extension. For comparison sake, I have named my script local.sh. The bash startup scripts are sourced automatically only with the bash shell and not the Korn or C shells. The ~/.bashrc script gets sourced by bash whenever you launch a non-login terminal session. Thus, from the initial runlevel 3 non-X login screen, bash does not source ~/.bashrc. Therefore, to run any additional commands you want to place in ~/.bashrc you must source that latter script from within ~/.bash_profile. However, from any subsequent non-login shell, such as in an X-based xterm or Konsole, bash will source ~/.bashrc. So this thread probably is as good as any time to go live with my web site. :) Human Readable Of particular interest to Slackers: A Slackware Desktop Enhancement Guide Of particular interest to this thread: Harmonizing the Bash Startup Scripts Automagically Running Programs During Startup and Shutdown One last note about something mentioned in this thread, KDE provides two types of terminal windows to launch: a non-login terminal window and a login terminal window. If using bash and the bash startup scripts, then the behavior of each type of terminal window will be based upon the bash startup scripts. If using Konsole, then investigate the Konsole configuration (Settings->Configure Konsole->Sessions tab) to see the differences in the command line options each type of terminal session Konsole supports. |
to confirm I want this program to run when I login to the CLI, not the GUI.
I have found my first problem. I tried the command Quote:
I triend the same script in my .bash_profile of my root account, and it did work. So there is an obvious permission issue. I used the command Quote:
that did not help it as the "hello world" script still wont run. So my non-root account is not looking at .bash_profile |
I have 2 questions if that's OK... Can you confirm that the .bash_profile you are altering is the one in your non-root user's home directory? Can you confirm that /bin/bash is set as the shell in /etc/passwd (if not, .bash_profile is not read)? You can check the first with the command below (while logged in as the non-root user):
Code:
cat ~/.bash_profile && ls -l ~/.bash_profile Code:
grep `whoami` /etc/passwd | cut -d: -f7 |
Also verify that the ~/.bash_profile script located in your non-root account home directory is owned by that account and not root. Occasionally I copy files as root and then forget to modify the file's group and account ownership. Use the list command (ls -l) in your home directory to view the file's ownership. If you see "root root" then the file is owned by root and not your non-root account.
|
cat ~/.bash_profile && ls -l ~/.bash_profile
I get this result, which to me, looks like I dont have executale rights... correct?? #!/bin/bash echo "Hello World" -rw-rw-r-- 1 jnt users 38 2006-01-25 17:35 /home/jnt/.bash_profile grep `whoami` /etc/passwd | cut -d: -f7 or grep $(whoami) /etc/passwd | cut -d: -f7 I get a blank line print with either of those commands |
this is my passwd file. I dont think /bin/bash is in my non root directory of 'jnt'
root:x:0:0::/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: adm:x:3:4:adm:/var/log: lp:x:4:7:lp:/var/spool/lpd: sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/: news:x:9:13:news:/usr/lib/news: uucp:x:10:14:uucp:/var/spool/uucppublic: operator:x:11:0:operator:/root:/bin/bash games:x:12:100:games:/usr/games: ftp:x:14:50::/home/ftp: smmsp:x:25:25:smmsp:/var/spool/clientmqueue: mysql:x:27:27:MySQL:/var/lib/mysql:/bin/bash rpc:x:32:32:RPC portmap user:/:/bin/false sshd:x:33:33:sshd:/: gdm:x:42:42:GDM:/var/state/gdm:/bin/bash pop:x:90:90:POP:/: nobody:x:99:99:nobody:/: jnt:x:1000:100::/home/jnt: |
The problem is that you don't have bash set as your shell. The line for jnt should end in /bin/bash the same as gdm's line does.
|
All times are GMT -5. The time now is 10:44 PM. |