LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-04-2005, 04:30 PM   #1
bmfan
Member
 
Registered: Mar 2005
Posts: 74

Rep: Reputation: 15
bash scripting question


Im making myself a litle script that i can use to join screenshots with, the screenshots might be jpg's or they could be png's . heres the script
Code:
#!/bin/bash
read -p "Enter Output Filename :" NM
read -p "Enable Shadow ? y/n :" S
read -p "Enter The Number of Tiles wide :" TW
if [[ "$S" = [yY]* ]]; then
  echo "--- Joining Images, Please Wait ---"
  montage *.jpg *.png  -shadow -geometry +4+4 -tile "$TW"x -quality 70 $NM  | tail
  echo "--- Joining Complete ---"
  else
  echo "--- Joining Images, Please Wait ---"
  montage *.jpf *.png  -geometry +1+1 -tile "$TW"x -quality 70 $NM  | tail
  echo "--- Joining Complete ---"
 fi

it works as is, however if its a directory full of png's it will say can't open *.jpg. im looing for a way for the script to join eith png's or jpg's. without spiting out that error. any ideas ?
 
Old 11-04-2005, 05:28 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you want to just sink that error? redirect stderr to /dev/null: "command -option parameter 2> /dev/null" is that all you're after?
 
Old 11-04-2005, 05:30 PM   #3
bmfan
Member
 
Registered: Mar 2005
Posts: 74

Original Poster
Rep: Reputation: 15
yeah i just want to get rid of the error the script works as is, it just spits out that error for either *.jpg or *.png depending on which is in the directory
 
Old 11-04-2005, 05:54 PM   #4
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Just use *.{jpg,png} instead of specifying them seperately. If one or other doesn't exist, it
will be ignored.
 
Old 11-04-2005, 05:58 PM   #5
bmfan
Member
 
Registered: Mar 2005
Posts: 74

Original Poster
Rep: Reputation: 15
ive tried that
montage *.{jpg,png} -shadow -geometry +4+4 -tile 3x v.jpg
it still spits out the error
montage: unable to open image `*.png': No such file or directory.
 
Old 11-04-2005, 06:08 PM   #6
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Oh, right. There should be a shell option to ignore failed matches. In zsh (which is what I use), it's 'setopt nomatch'. With bash, try 'set -o nomatch'. I haven't used bash for years though so I'm not sure about that. Have a look at the man page (search for, say, 'globbing') if 'nomatch' is not recognized.
 
Old 11-04-2005, 08:54 PM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
How about something like this
Code:
#!/bin/bash

read -p "Enter Output Filename :" NM
read -p "Enable Shadow ? y/n :" S
read -p "Enter The Number of Tiles wide :" TW
if [[ "$S" = [yY]* ]]; then
  echo "--- Joining Images, Please Wait ---"
  montage *.jpg *.png -shadow -geometry +4+4 -tile "$TW"x -quality 90 $NM  2> /dev/null | tail
  echo "--- Joining Complete ---"
else
  echo "--- Joining Images, Please Wait ---"
  montage *.jpg *.png -geometry +1+1 -tile "$TW"x -quality 90 $NM  2> /dev/null | tail
  echo "--- Joining Complete ---"
 fi
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting Question fiod Linux - Newbie 4 11-19-2005 05:09 AM
Bash scripting question. pete1234 Programming 23 09-22-2005 06:52 PM
Bash Scripting Question jsimmonds Programming 2 06-16-2005 09:07 AM
BASH Scripting question flagg0204 Programming 4 12-23-2004 07:59 AM
Bash scripting question Hammett Linux - General 4 11-29-2004 06:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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