LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2006, 05:06 PM   #1
mashed
LQ Newbie
 
Registered: Mar 2006
Location: Finland
Distribution: Fedora Core 5
Posts: 28

Rep: Reputation: 15
Start up script


How can I create a script that runs after a certain user has logged in? If I I'm running an x-server I can obiously use .xsession, but what if I'm not running an x-server?
 
Old 12-19-2006, 05:13 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
generally it'd by ~/.bashrc or ~/.profile for a single user or /etc/bashrc or /etc/profile for everyone.
 
Old 12-19-2006, 05:39 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
create a script that runs after a certain user has logged in
Since this question isn't that clear to me, one word of caution. It depends if you vant to run ze script that is under ze control of a user or if it's for system-wide purposes. In ze first case (say you vant to start say ssh-agent) ~/.bash_login will do. In ze second case you will vant to resort to something outside of the users control for which you can use PAM modules like PAM_script.
 
Old 12-20-2006, 03:24 PM   #4
mashed
LQ Newbie
 
Registered: Mar 2006
Location: Finland
Distribution: Fedora Core 5
Posts: 28

Original Poster
Rep: Reputation: 15
Script that is that is under the control of a user will do, like the one you get by editing .bashrc. However, how do you write a script that is run only if x-server is not running on the display that has logged in?
 
Old 12-20-2006, 04:48 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
ok if that's the route you wish to go down, you just need to do something like checking the output of the "tty" command with your bash script. if it starts "/dev/tty" then your in a real console, if not, and it's /dev/pts/1 or something then you're in a terminal within an x session:

(tty | grep tty > /dev/null) && command to run when in real terminal || command to run when in emulated terminal
 
Old 12-23-2006, 02:28 AM   #6
mashed
LQ Newbie
 
Registered: Mar 2006
Location: Finland
Distribution: Fedora Core 5
Posts: 28

Original Poster
Rep: Reputation: 15
Hmm. still didn't quite work. I'm trying to write a script that is run only if login is not going to start the x-server. (tty | grep tty > /dev/null) shows tty in both cases, so the script is run always. (Because, if the x is goint to be started it is not already on.) I think, that the only time (tty | grep tty > /dev/null) doesn't result tty is, when you are in an emulated console.
 
Old 12-24-2006, 10:01 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
oh, so it's whether x is going to be started, not whether it's alread been started? well what are you actually referring to with regards to when the x server will or won't start? runlevel?
 
Old 12-26-2006, 02:12 PM   #8
mashed
LQ Newbie
 
Registered: Mar 2006
Location: Finland
Distribution: Fedora Core 5
Posts: 28

Original Poster
Rep: Reputation: 15
When you are running the x-server, it usually runs on emulated console #7, I want to create script, that is not run, if you log in trough emulated console #7 while in runlevel 5. (And, in another words, this means that script is always run, if you don't use an x serve. Because that means, that you are not loggin in trough console #7 at rl 5).

For some reason, the "(tty | grep tty > /dev/null) && command" is run, when I log in at #7 in rl 5, even though the x is supposed to be running (So maybe it is reset at some point in login process? I don't know.)
 
Old 12-26-2006, 02:53 PM   #9
Tortanick
Member
 
Registered: Jul 2006
Distribution: Debian Testing
Posts: 299

Rep: Reputation: 30
why not post what you want the script to do? Maby there is an alternative to predicting X.

Perhaps you could duplicate you're PAM modual for normal logons, one for KDM/GDM and one for console, then just add you're script to the console one.

I'm not sure what would happen if a user choses console logon from KDM/GDM though

Last edited by Tortanick; 12-26-2006 at 02:59 PM.
 
Old 12-27-2006, 03:09 PM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well what actually is the output from "tty" itself inside and outside of x? unless you have a path issue, i'm pretty confident it will work fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 up script martincho Debian 5 06-24-2006 11:32 PM
Start up script mashed Linux - Hardware 2 04-06-2006 09:25 AM
getting script to start at boot short101 Debian 2 01-24-2005 07:32 AM
Start up script... podollb Linux - Software 3 10-19-2004 05:38 PM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 12:00 PM


All times are GMT -5. The time now is 03:47 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration