Results 1 to 5 of 5
In linux Red Hat, I need to create a method of displaying the Message of the Day(motd) in a xmessage box when the user logs into our systems via GUI. ...
- 10-22-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 6
need help with script using motd and xmessage!?
In linux Red Hat, I need to create a method of displaying the Message of the Day(motd) in a xmessage box when the user logs into our systems via GUI. If the user connects to the system via text mode, the motd should only display as text.
Create a script or method to determine if a student is logged in via
the graphical user's interface (GUI) or via text mode.
- 10-22-2008 #2Just Joined!
- Join Date
- Jul 2007
- Posts
- 49
you can put a file in the root of their home dir called .xsession which will execute after an X login. Make it executable and use this or something like:
#!/bin/bash
xmessage `cat /etc/motd`
You can put this in any users home dir or put it in the skel dir so when a new user is created they automatically get the .xsession file.
- 10-23-2008 #3Just Joined!
- Join Date
- Oct 2008
- Posts
- 6
Thank you for ask my question, but my account is not admin, I can't not put a file in the root of their home dir.
The goal is to display the /etc/motd file, the main focus is to
create a test condition, upon login, which will determine a GUI login or a
text login (ssh, CTRL+ALT+F[1-6]).
- 10-23-2008 #4Just Joined!
- Join Date
- Oct 2008
- Posts
- 6
is my script logic should look like this: right?
if a user log in via GUI, then display a xmessage when login.
if a user log in via ssh(remote login), then display a message in text.
but How can I determine which log in is use? and how can i execute this program, where should I put it.
- 10-24-2008 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Determining if your are in X or not is a matter of checking if the DISPLAY var is set or not. That's not hard. Simple example:
Launching it is another different story.Code:if [ ! -z "$DISPLAY" ] then echo "X is running." else echo "X is NOT running." fi
The stuff that is run when a user login is dependant on the shell that the user uses, and is controlled via the initialization files of that shell, so, you should be reading the man pages for the shells that you allow on your system. But bear in mind that any user can change his/her shell usually, so, there's absolutely no guarantee that they will use the shell you think they'll use. If you don't have admin privileges, then you have even less control.
If you use, let's say, bash, then you should read the bash man page section titled "INVOCATION" to see the files that are sourced and in which order. There you can launch your script.
With X the thing is a bit more complicated becuse it depends on a number of things. The main question you need to answer is: are you starting X using "startx" on command line or are you starting X using a graphical login manager?


Reply With Quote
