Review your favorite Linux distribution.
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 08-25-2008, 10:16 PM   #1
LQ Newbie
Registered: Jul 2008
Posts: 27

Rep: Reputation: 15
how to run script


I found one script on the linux device driver book
# invoke insmod with all arguments we got
# and use a pathname, as newer modutils don't look in . by default
/sbin/insmod ./$module.ko $* || exit 1
# remove stale nodes
rm -f /dev/${device}[0-3]
major=$(awk "\\$2=  =\"$module\" {print \\$1}" /proc/devices)
mknod /dev/${device}0 c $major 0
mknod /dev/${device}1 c $major 1
mknod /dev/${device}2 c $major 2
mknod /dev/${device}3 c $major 3
# give appropriate group/permissions, and change the group.
# Not all distributions have staff, some have "wheel" instead.
grep -q '^staff:' /etc/group || group="wheel"
chgrp $group /dev/${device}[0-3]
chmod $mode  /dev/${device}[0-3]
I still confuse how to save this script (what name and where should i save it) and how to run this script.

I usually didn't use script instead of just running one by one command to load my module by using (insmod, mknod, chmod)
Old 08-25-2008, 10:18 PM   #2
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Save it as whatever you like, though it is usually a good idea to give it the extension ".sh". Then you make the file executable by running the command "chmod +x filename"; after that you can run the script from the terminal or from within your GUI file manager.
Old 08-25-2008, 10:23 PM   #3
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
file name doesn't matter (you can call it <file>.sh but it's really not important). Create empty file:

touch <file>

Open it with editor:

vim <file>

Press 'i' on your keyboard to enter 'insert' mode.

Copy/paste the text of your script.

Press 'Esc'
Type ':wq' to save it.

Make the file executable:

chmod +x <file>

Run it (make sure you are in the same directory as file):


Last edited by klearview; 08-25-2008 at 11:19 PM. Reason: formatting
Old 08-25-2008, 11:18 PM   #4
LQ Newbie
Registered: Jul 2008
Posts: 27

Original Poster
Rep: Reputation: 15
klearview and MS3FGX,

Thank you for quick response, improve my knowledge and now i happy to use script


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
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:29 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