Welcome to the most active Linux Forum on the web.
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 06-18-2004, 02:02 AM   #1
Registered: Sep 2003
Location: Tampa
Distribution: RH9 & FC2
Posts: 55

Rep: Reputation: 15
Question How to Make a Linux Script File

I recently added an iomega zip drive to my system. I'd like to create a script for mounting and unmounting the drive, but alas...I don't know how to make scripts!

I need it to do this:


Instead of having to type:
iw -m /dev/sda -mp /zip
I want to type:


Instead of:
iw -u /dev/sda
I want:

Once I learn how to create this script I'm going to make scripts for my CDROMs and floppy.

Last edited by TankerKevo; 06-18-2004 at 02:05 AM.
Old 06-18-2004, 02:19 AM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
You don't necessarily need a script to do that. You can, but I would guess most people would suggest setting up an alias instead. I'll give you equivalents for both (alias and script).

For an alias, you have two choices on where to put it: /etc/bashrc or ~/.bashrc

Making a change to /etc/bashrc will make the alias available to every user on the system. Making the change to ~/.bashrc will make the alias available only for that particular user. Define an alias like this:
alias mzip='iw -m /dev/sda -mp /zip'
After finishing, source the file you changed. Either source /etc/bahrc or source ~/.bashrc

You only have to source the file for any shells you currently have open. The next time you log in, the alias will be ready automatically.

Now, for the shell script...

Open a text editor and type in this (or copy-paste):

iw -m /dev/sda -mp /zip

exit 0
Save the file as mzip (the name you want to use for the command). Then execute the following command:
chmod a+x mzip

That command makes the script executable. Now, if you want to type "mzip" on the command line no matter where you are, then move the mzip file to a spot somewhere in your PATH variable. A good place would probably be /usr/local/bin

And that's all there is to it.
Old 06-18-2004, 05:42 AM   #3
Registered: Sep 2003
Location: Tampa
Distribution: RH9 & FC2
Posts: 55

Original Poster
Rep: Reputation: 15
Alrite thanks!

I'm doing this now! I'll let everyone know how I did this afternoon!
Old 06-18-2004, 08:39 PM   #4
Registered: Sep 2003
Location: Tampa
Distribution: RH9 & FC2
Posts: 55

Original Poster
Rep: Reputation: 15
Worked great!!!

I used the alias feature on my mount and unmount commands and created a script w/ a symbolic link in my rc.3 and rc.5 directories using "mprobe ppa&" so that my CPU recognizes that there's a zip drive automatically at start up!

Iomega Zip 100 Parallel (So that people looking for the same solution find it when searching.)

Thanks Dark Helmet for the knowledgeable advice!


Last edited by TankerKevo; 06-18-2004 at 08:41 PM.


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
Perl cgi Script can`t make file.Why? ZairSadiqov Linux - Software 1 11-22-2006 08:22 AM
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 10:02 PM
How to make a file inherit script permissions antony.booth Linux - Security 4 03-11-2005 06:04 AM
Make file, dos, linux The_Nerd Programming 1 05-30-2004 12:36 AM
A way to script file transfer from Linux to windows? jkcunningham Linux - Networking 11 11-21-2002 08:58 PM > Forums > Linux Forums > Linux - Newbie

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