Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-16-2005, 12:35 PM   #1
Registered: Jan 2005
Location: Philadelphia, PA
Distribution: ubuntu
Posts: 68

Rep: Reputation: 15
newbie script question

I'm running Vector and Yoper on my system.
Sharing the same home directory, but I want to use a different WM.

So in .xinitrc I want to write a script so that if

kernel = startkde

kernel = starticewm

I'm new to scripting so I don't know the syntax. I know I can get the kernel version with uname -r but how do I put it into a script?

Old 12-16-2005, 01:38 PM   #2
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Something like:


KERNEL="uname -r"

$KERNEL | grep 2.4
if [ $? -eq 0 ]; then

$KERNEL | grep 2.6
if [ $? -eq 0 ]; then

exit 0

Old 12-16-2005, 02:31 PM   #3
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
Or even just:

[ "$(uname -r | cut -f 1-2 -d .)" = "2.6" ] && startkde || starticewm
to keep it simple. This will also "fallback" to icewm if kde cannot be started.
Old 12-16-2005, 07:31 PM   #4
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
"$(uname -r | cut -f 1-2 -d .)" = "2.6"
There's (AFAICT) actually no point in quoting:

$ [ $(uname -r | cut -f 1-2 -d .) = 2.6 ] && true || false; echo $?
Old 12-16-2005, 10:05 PM   #5
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
AT TLDP, there is an excellent bash guide by Machtelt Garrels. I also HIGHLY recommend buying a book on scripting.
Old 12-17-2005, 05:44 AM   #6
Registered: Jan 2005
Location: Philadelphia, PA
Distribution: ubuntu
Posts: 68

Original Poster
Rep: Reputation: 15
Thanks. My problem was was that I could not login from the KDM screen as user. I thought it was the .xinitrc and .xsession files, so that's why I tried the script. No help though. I can go to console and login, then startx, but I don't know why KDM login manager won't work for non-root users.


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
Newbie question - running a script at boot time Napalm Llama Red Hat 8 04-19-2005 04:11 PM
Help a script newbie unholy Programming 2 09-19-2004 08:05 AM
veprory simple but frustrating for a newbie shell script question marigb Linux - Newbie 11 04-28-2004 01:11 PM
shell script newbie question yoshi95 Programming 1 03-11-2004 03:43 AM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 09:41 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:54 PM.

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