LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 09-30-2002, 05:09 PM   #1
newpenguin
Member
 
Registered: Sep 2002
Location: lahore pakistan
Distribution: slackware,redhat, FreeBSD,openbsd
Posts: 219

Rep: Reputation: 30
Wink A Newbie,s Scripting Question


hello i have a problem in scripting , actually just started the scripting.
hope you will be able to understand it

i want to enter in running kernel,s modules directory in a script
like "/lib/modules/running kernel/driver...."
i know that "uname -r" command will print the running kernels name , and it can help me in this case
but how to use it in the script ????
thanks for your help .
 
Old 09-30-2002, 05:14 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Code:
[chris@trevor chris]$ echo /usr/lib/`uname -r`/kernel
/usr/lib/2.4.18/kernel
 
Old 09-30-2002, 07:42 PM   #3
newpenguin
Member
 
Registered: Sep 2002
Location: lahore pakistan
Distribution: slackware,redhat, FreeBSD,openbsd
Posts: 219

Original Poster
Rep: Reputation: 30
sorry to say but it didnt worked.
i think my stupid mind is not able to understand it .
please if you can explain ?
i want to do "cd /lib/modules/running kernel/........"
 
Old 09-30-2002, 08:29 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Like he said (w/o outer quotes): "cd /lib/modules/`uname -r`/kernel" :-]
Note the backticks can also be replaced with $(), as in "cd /lib/modules/$(uname -r)/kernel" but that's coding stylee.

If you ever come across a piece of code you can't understand there's two things make it more understandable. If you run it from a script you can execute the script as "sh -x <scriptname>" which will show you all the actual values your script works with. The second thing is echoing. For the above example try on the commandline: "echo "cd /lib/modules/`uname -r`/kernel"". Notice we just put echo in front and wrap the whole command in double quotes. It should return the line which would be executed as command.

Last edited by unSpawn; 09-30-2002 at 08:32 PM.
 
Old 10-01-2002, 07:03 AM   #5
Faecal
Member
 
Registered: Sep 2002
Location: York, UK
Distribution: Debian Sid
Posts: 215

Rep: Reputation: 30
Quotes have never worked for me with commandline substitutions - I've always had to use $(). Just an observation (bash,RH).
 
Old 10-01-2002, 09:51 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
quotes are not the same as bacticks, do not confuse the two.
 
Old 10-02-2002, 01:23 PM   #7
newpenguin
Member
 
Registered: Sep 2002
Location: lahore pakistan
Distribution: slackware,redhat, FreeBSD,openbsd
Posts: 219

Original Poster
Rep: Reputation: 30
now when i read it cleared my concept that
`uname -r` = $(uname -r)
but actually the `uname -r` was case sensative and i was using like this `uname -r' which was wrong.
thanks a lot for the help of you .
this is really a helpfull site.
 
Old 10-07-2002, 12:52 PM   #8
newpenguin
Member
 
Registered: Sep 2002
Location: lahore pakistan
Distribution: slackware,redhat, FreeBSD,openbsd
Posts: 219

Original Poster
Rep: Reputation: 30
hello all
so this is my first script for which thisthread was created.
my problem was to load the sound module for 3 kernels in slackware.but its compatible only with new kernels

so i put these lines in /etc/rc.d/rc.local

cd /lib/modules/`uname -r`/kernel/drivers/sound/

if [ -f via82cxxx_audio.o ]; then

modprobe \*via82cxxx_audio.o

# as one kernel uses .o.gz modules
else

modprobe \*via82cxxx_audio.o.gz

fi

cd ~

a 's first script and only because of slackware.
i know this is nothing for you but for me it is

thanks again for your help.

Last edited by newpenguin; 10-07-2002 at 12:59 PM.
 
  


Reply



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 Bash Scripting Question jsaxton86 Programming 2 11-26-2005 07:58 PM
Newbie scripting question, dates Bubba235 Linux - Enterprise 8 11-05-2004 12:06 AM
Newbie Bash scripting question Caidence Programming 2 08-03-2003 04:53 AM
Newbie bash scripting question... cmfarley19 Linux - Newbie 2 05-03-2003 08:26 AM
Newbie Scripting, please help granny Programming 6 04-24-2003 11:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 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
Open Source Consulting | Domain Registration