LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-07-2005, 08:01 PM   #1
deepsix
Member
 
Registered: Apr 2003
Distribution: ANY
Posts: 339

Rep: Reputation: 32
Scripting help please


I want to write a script that uses 2 different programs to open media files ie .jpg .png .mpg .mp3

example: i want to type open at the command line and it open image files with gqview and movie files with mplayer......

any help appreciated my scripting knowlege is limited....

any kickass links to webpages with scripting tutorials would also be helpfull.......i found a few but not for a broad spectrum of uses.....

Last edited by deepsix; 09-07-2005 at 08:06 PM.
 
Old 09-07-2005, 08:15 PM   #2
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
may I suggest having this moved to the programming forum (click report this post to moderator link). Sorry I can't help, but you might get a better responce

Last edited by tomj88; 09-07-2005 at 08:16 PM.
 
Old 09-07-2005, 08:36 PM   #3
tonyfreeman
Member
 
Registered: Sep 2003
Location: Fort worth, TX
Distribution: Debian testing 64bit at home, EL5 32/64bit at work.
Posts: 196

Rep: Reputation: 30
Some Code

How about something like this:

Code:
#!/bin/bash

VIDEO_FILES="ogm mpg mpeg avi mov"
IMAGE_FILES="png jpg gif"

EXTENSION=${1##*.}

if echo $VIDEO_FILES | grep -i $EXTENSION >/dev/null 2>&1
then
        echo "Video File"
        if [[ -e $1 ]]
        then
                mplayer $1
        fi
elif echo $IMAGE_FILES | grep -i $EXTENSION >/dev/null 2>&1
then
        echo "Image File"
        if [[ -e $1 ]]
        then
                eog $1
        fi
fi
-- Tony
 
Old 09-07-2005, 09:07 PM   #4
deepsix
Member
 
Registered: Apr 2003
Distribution: ANY
Posts: 339

Original Poster
Rep: Reputation: 32
that gave me the start i needed .........thanks alot bro.......
 
Old 09-07-2005, 09:34 PM   #5
deepsix
Member
 
Registered: Apr 2003
Distribution: ANY
Posts: 339

Original Poster
Rep: Reputation: 32
you are the man dude........truly appreciated
 
Old 09-07-2005, 09:50 PM   #6
deepsix
Member
 
Registered: Apr 2003
Distribution: ANY
Posts: 339

Original Poster
Rep: Reputation: 32
Re: Some Code

Quote:
Originally posted by tonyfreeman
How about something like this:

Code:
#!/bin/bash

VIDEO_FILES="ogm mpg mpeg avi mov"
IMAGE_FILES="png jpg gif"

EXTENSION=${1##*.}

if echo $VIDEO_FILES | grep -i $EXTENSION >/dev/null 2>&1
then
        echo "Video File"
        if [[ -e $1 ]]
        then
                mplayer $1
        fi
elif echo $IMAGE_FILES | grep -i $EXTENSION >/dev/null 2>&1
then
        echo "Image File"
        if [[ -e $1 ]]
        then
                eog $1
        fi
fi








___________________________________
-- Tony
I dont understand how you declared EXTENSION what does ${1##*.} mean? if you dont mind to elaborate..........
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
new to scripting mifan Linux - Newbie 2 08-17-2005 12:10 PM
another help with scripting?! ice99 Programming 2 08-09-2005 08:56 AM
Need help scripting Tamara Programming 7 06-06-2005 02:06 AM
Scripting Help Please Jazinator Linux - Newbie 7 10-17-2004 06:35 PM
scripting bforest Linux - Newbie 4 05-11-2004 02:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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