LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-06-2005, 03:44 AM   #1
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 30
How to check in a script whether the shell is login or non login?


I am sure this has been asked before, but since I can't find it and since I am sure the answer is quite short....I'll ask again.

Thanks.
 
Old 09-06-2005, 03:54 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
If using bash, try :
Code:
shopt | grep login_shell
 
Old 09-06-2005, 04:09 AM   #3
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Original Poster
Rep: Reputation: 30
Thanks, I didn't know about shopt...but, now I keep opening xterms (Konsoles to be accurate) and when I 'shopt', in every terminal I open the login_shell toggles are switched to ON. That can't be right. Can it?
 
Old 09-06-2005, 04:20 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
Your shell in konsole is a login shell, but if you start a bash script
without the -l option, it won't be a login shell

try :
Code:
#!/bin/bash
echo $(shopt | grep login_shell)
Then execute the script in your konsole terminal
 
Old 09-06-2005, 04:42 AM   #5
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Original Poster
Rep: Reputation: 30
I see what you are saying. Only if it's a child process it is not a login shell. Well, that certainly doesn't solve my problem.

I guess then I should ask my question as: "How can I check in a script whether the current shell is the one in which I actually logged in, gave my uname and password or any other shell that I opened by starting Xserver and clicking on the xterm icon?"
 
Old 09-06-2005, 06:01 AM   #6
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
There are some ways, for example echo $TERM, if it is linux, then
you are surelly in a console terminal, so not in X
 
  


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
Use a shell script to do login and other commands jpan Linux - General 15 01-12-2005 06:52 AM
Connection, login and upload files to ftp server via shell script Paulo Ges Linux - Networking 2 02-21-2004 01:01 PM
Shell script login command? chup Linux - General 3 08-24-2003 06:43 PM
login message shell script? jczr2 Linux - Newbie 22 05-28-2003 09:10 PM
telnet login via shell script lethe Linux - General 8 05-13-2002 09:31 AM


All times are GMT -5. The time now is 05:53 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration