LinuxQuestions.org
Review your favorite Linux distribution.
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 10-07-2004, 09:00 PM   #1
poiuytrewq
Member
 
Registered: Jul 2004
Posts: 107

Rep: Reputation: 15
writing a bash script


hey, im trying to write a simple bash script, and im hopping for a little help.

im making a script that eventualy i want to add to the nautilus menu "open with" for image files. so that i can right click on that file and have it converted to a png and a gif format without opening a program.

the script will look something like this:

convert PleaseConvertMe.jpg output.png
convert PleaseConvertMe.jpg output.gif
mv output.png /home/userid/imagecache/output.png
mv output.gif /home/userid/imagecache/output.gif

the problem im having is how do i make the program know what image i am right clicking on in nautilus?
aka(i think) how do i give the /path/to/PleaseConvertMe.jpg as an argument?
 
Old 10-07-2004, 09:55 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
The filename(s) will be passed via the command line, so you can access them with $1, $2, $3 (...), or $* for all at once. I don't have nautilus or gnome, so I can't test that this works, but that's how it appears from the scripts on g-scripts.sourceforge.net.
 
Old 10-07-2004, 11:26 PM   #3
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
Your sample script is a bit heavy for a simple conversion.
The following should do just as well
Code:
convert PleaseConvertMe.jpg /home/userid/imagecache/output.png
convert PleaseConvertMe.jpg /home/userid/imagecache/output.gif
Or if you're converting the same image into 2 formats, this might even work:
Code:
convert PleaseConvertMe.jpg /home/userid/imagecache/output.{png,gif}
The second one might not work, depending on how convert works.

Edit: Apparently the second one doesn't work...I just tested it and got an error

Last edited by mikshaw; 10-07-2004 at 11:35 PM.
 
  


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
Writing bash script with recursion.. ray5_83 Programming 4 08-04-2004 06:44 PM
Help writing a pinging bash script dehuszar Linux - Software 3 06-18-2004 03:03 PM
Writing to a file - Bash script Skute Programming 2 03-15-2004 05:41 AM
writing a bash/ perl script on debian phr00ta Programming 4 01-29-2004 02:38 PM
writing bash script ankitgdit Programming 4 08-19-2003 07:47 AM


All times are GMT -5. The time now is 08:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration