LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-16-2005, 12:35 PM   #1
mngmd
Member
 
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 = 2.6.xxx startkde

kernel = 2.4.xxx 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?

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

Rep: Reputation: 52
Something like:

Code:
#!/bin/bash

KERNEL="uname -r"

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

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

exit 0

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

Rep: Reputation: 46
Or even just:

Code:
#!/bin/bash
[ "$(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
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

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

Code:
$ [ $(uname -r | cut -f 1-2 -d .) = 2.6 ] && true || false; echo $?
0
 
Old 12-16-2005, 10:05 PM   #5
pixellany
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
mngmd
Member
 
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.
 
  


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
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


All times are GMT -5. The time now is 02:50 PM.

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