LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-24-2006, 01:39 PM   #1
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Rep: Reputation: 15
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
 
Old 01-24-2006, 02:41 PM   #2
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
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

Last edited by phil.d.g; 01-24-2006 at 02:43 PM.
 
Old 01-24-2006, 06:35 PM   #3
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
where do i find ./bash_profile???
I used the find -name command with no luck.
 
Old 01-24-2006, 07:10 PM   #4
LocoMojo
Member
 
Registered: Oct 2004
Distribution: Slackware 12
Posts: 165

Rep: Reputation: 30
Quote:
Originally Posted by jturnbul
where do i find ./bash_profile???
I used the find -name command with no luck.
It's in your home directory. To see it you need to issue the following command:

Quote:
ls -a (if you're in your home directory)

ls -a ~/ (if you're not in your home directory)
By the way, it is .bash_profile not ./bash_profile. There's also a systemwide file called profile in /etc.

LocoMojo

Last edited by LocoMojo; 01-24-2006 at 07:12 PM.
 
Old 01-24-2006, 07:21 PM   #5
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
It doesn't exists by default, just create it.
 
Old 01-24-2006, 07:27 PM   #6
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
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
 
Old 01-24-2006, 07:41 PM   #7
LocoMojo
Member
 
Registered: Oct 2004
Distribution: Slackware 12
Posts: 165

Rep: Reputation: 30
Quote:
Originally Posted by jturnbul
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
If the program you want to run is in your path:

Quote:
echo $PATH
Then you only have to type the name of the program to call it.

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:
export PATH=$PATH:/usr/local/bin
Another way to see your PATH is to type "env" without the quotes. This will bring up all your environment variables.

LocoMojo
 
Old 01-24-2006, 08:27 PM   #8
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by LocoMojo
If the program you want to run is in your path:



Then you only have to type the name of the program to call it.

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:



Another way to see your PATH is to type "env" without the quotes. This will bring up all your environment variables.

LocoMojo
Thanks, I tried the commands from CLI and they worked, however I put them into my .bash_profile and nothing happens when I log on.

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
 
Old 01-24-2006, 08:55 PM   #9
LocoMojo
Member
 
Registered: Oct 2004
Distribution: Slackware 12
Posts: 165

Rep: Reputation: 30
Quote:
Originally Posted by jturnbul
Thanks, I tried the commands from CLI and they worked, however I put them into my .bash_profile and nothing happens when I log on.

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
What program are you trying to run?

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
 
Old 01-24-2006, 09:17 PM   #10
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
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
 
Old 01-24-2006, 09:28 PM   #11
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
#!/bin/bash
export PATH=$PATH:/usr/BOINC
run_client &
this didnt work
 
Old 01-24-2006, 09:36 PM   #12
LocoMojo
Member
 
Registered: Oct 2004
Distribution: Slackware 12
Posts: 165

Rep: Reputation: 30
Quote:
Originally Posted by jturnbul
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
It's a text file and it runs when you type run_client & ?

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:
if [ ! "$BASHRC" -a -f ~/.bashrc ]; then
. ~/.bashrc
fi
If it doesn't then put that in the .bash_profile file exactly as quoted.

Good luck!

LocoMojo
 
Old 01-24-2006, 09:45 PM   #13
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
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.
 
Old 01-24-2006, 09:53 PM   #14
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
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.
 
Old 01-24-2006, 10:33 PM   #15
jturnbul
Member
 
Registered: Sep 2004
Location: Toronto, Canada
Distribution: Fedora 4 - Slackware 10 - PHLAK
Posts: 92

Original Poster
Rep: Reputation: 15
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???
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Start at Boot - After X, before login. grim1234 Slackware 2 11-05-2005 11:00 AM
start gui based program after user login shahidawan Linux - General 9 07-27-2005 08:46 PM
How do I start a program on boot ? overproof Mandriva 4 04-22-2005 07:13 AM
How to start program on X login donbellioni Linux - General 11 07-28-2004 04:45 PM
program start at boot moonloader Slackware 4 03-08-2004 06:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration