LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-20-2005, 12:51 AM   #1
chummers36
LQ Newbie
 
Registered: Sep 2005
Distribution: Red Hat Enterprise 3.0 ES
Posts: 2

Rep: Reputation: 0
Question Shell Script


Completely dumb towards linux, anyways
I finally got linux installed with Windows XP, set it up using a 7 gig partition with ext3 file system, 2 gig for swap space, and anothe 2 gigs for fat32 to share between the two OS's. Tried to mount the ntfs fs but wouldn't let me tried to update the kernel but didn't work either, anyways just hoping I have it setup ok. Back to the point, downloaded an mp3 player called MPG123, and want to create a script shell that will run MPG123 then go to the dir where I have my mp3's at and play them. Right now I have all of my mp3's in /mnt/winxp/mp3, so what I do now is go to folder where the MPG123 program is located and type:
mpg123 -Z /mnt/winxp/mp3/*.mp3
and it will start playing the mp3's, so all I want is for that to be automated, the -Z option is just to play it random.
 
Old 09-20-2005, 01:57 AM   #2
Stan the caddy
Member
 
Registered: Dec 2003
Location: Victoria, B.C
Distribution: Slackware
Posts: 61

Rep: Reputation: 15
Usually for little one liner commands like that your better off to just make an alias. Edit your ~/.bashrc file and add this
Code:
alias play='/path/to/mpg123 -Z /mnt/winxp/mp3/*.mp3'
then at the command line do
Code:
source ~/.bashrc
Now whenever you want to play your music type play.

As for mounting NTFS filesystem, assuming your kernel is compiled with support for it add the following line to your /etc/fstab file

Code:
/dev/hda1   /mnt/windoze   ntfs   auto,user,umask=000,ro   0   0
replaceing /dev/hda1 with the location of your windows partition and /mnt/windoze with where you want your mountpoint. Type mount /mnt/windoze and that should be it.

Last edited by Stan the caddy; 09-20-2005 at 02:02 AM.
 
Old 09-20-2005, 02:05 AM   #3
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
Hi,

you can create a shell script in /bin or /usr/bin (or another path in your $PATH variable) wich looks like this:
Code:
#/bin/bash

/path/to/mpg123 -Z /mnt/winxp/mp3/*.mp3
however a more elegant solution would be to get mpg123 in your path by creating a symbolic link. go to the /bin directory and type:
ln -s /path/to/mpg123 mpg123
this will create a symbolic link "/bin/mpg123" wich links to "/path/to/mpg123", now you can always run mpg123 without going to the directory where it's located. You may also create an alias for the -Z option, like:
alias mpg123="mpg123 -Z"
now if you type mpg123 /mnt/winxp/mp3/*.mp3, it will execute "/path/to/mpg123 -Z /mnt/winxp/mp3/*.mp3"

Greets,
.-=~ iluvatar ~=-.
 
Old 09-20-2005, 02:26 AM   #4
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Quote:
Originally posted by Stan the caddy
Usually for little one liner commands like that your better off to just make an alias. Edit your ~/.bashrc file and add this
Code:
alias play='/path/to/mpg123 -Z /mnt/winxp/mp3/*.mp3'
Ummm... 'play' is already a program to play wav, midi, and raw audio file formats. You'll want to use something other than 'play'.
 
Old 09-20-2005, 02:40 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
A quick way to find out if your kernel has ntfs support is to look at the /proc/filesystems psuedo-file.
cat /proc/filesystems

If ntfs isn't listed, the support may be compiled as module instead of built in, and the module might not be loaded.
If this is the case try as root:
modprobe ntfs

For ntfs and vfat (fat32) filesystems, I alway use the fmask and dmask options. For things like thumb drives, I make myself the owner of the drive with the uid= and gid= options. ( check the "man 8 mount" man-page for the details )
There may also be an "fstab" manpage entry.

____

p.s. I you include which distro you are using in your profile, it would make it easier to answer your questions. For example, an early Fedora Core would not have ntfs support in it's kernel by default. Some distro's will set up a mount point for the ntfs drive under /data, and some in /mnt/windows. In other words, it may be mounted already.

Using the partitioner gui utility for you distro may enable you to mount a drive. Doing it this way may also select better options, such as the font encoding used by the filesystem.
 
Old 09-20-2005, 08:54 PM   #6
chummers36
LQ Newbie
 
Registered: Sep 2005
Distribution: Red Hat Enterprise 3.0 ES
Posts: 2

Original Poster
Rep: Reputation: 0
Thx for the help got the script working. Put up my distro of linux, when I tried to mount said ntfs not supported so thats when I tried to upgrade the kernel, came up something like this kernel is installed but not running, said to reboot and select kernel but wasn't showing anywhere, so not to sure to do about that.
 
Old 09-21-2005, 02:13 AM   #7
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
You have to add the kernel to your bootloader configuration. How to do this depends on wich bootloader you use, I don't know wich redhat uses by default nowadays, but my guess is grub. I don't have any experience with grub but if you post a new thread about this subject (because this thread is called 'shell script' it won't attract boot-loader-specialists) you should get an anwser soon!

greetz,
.-=~ iluvatar ~=-.
 
Old 09-21-2005, 07:11 AM   #8
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,605

Rep: Reputation: 53
if you want to learn more about script see
LQ bookmark search for bash

Will add list of tutorials that helped me when I started
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

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

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