Gentoo Archives: gentoo-user

From: Michael Sullivan <michael@××××××××××××.com>
To: gentoo-user <gentoo-user@l.g.o>
Subject: [gentoo-user] OT - Question about new bash
Date: Sun, 29 Jan 2006 17:49:19
Message-Id: 1138556593.10508.27.camel@camille.espersunited.com
1 I wrote a script a long time ago for resizing pictures uploaded to a
2 certain directory on my server box. The script was supposed to check to
3 see if any JPG files in the directory had not been resized, and if they
4 hadn't, it was supposed to resize them. It did some other stuff, but
5 that was the important thing. It worked fine until the recent bash
6 upgrade and now it gives me an error. Here is the script:
7
8 michael@bullet ~ $ cat system/resizepics
9 #!/bin/bash
10 OLD_DIR=$PWD
11 cd /home/michael/unfiledPics
12
13 if [ ! -d current ]; then
14 mkdir -p current/mini
15 fi
16
17 if [ ! `ls -l | wc -l` -le 2 ]; then
18 for x in *.JPG; do
19 if [ ! -e current/$x ]; then
20 convert "$x" -thumbnail 200x200 -verbose current/mini/mini-"$x"
21 convert "$x" -thumbnail 640x480 -verbose current/"$x";
22 fi
23 done
24 fi
25
26
27 if [ `ls -l | wc -l` -ge 12 ]; then
28 today=`date '+%m%d%y'`
29 mv current $today
30 mv $today /home/michael/webspace/html/camera
31 mkdir -p /home/michael/unfiledPics/current/mini
32 rm /home/michael/unfiledPics/*.JPG
33 fi
34
35 cd $OLD_DIR
36
37 As I said, before the bash upgrade this worked perfectly. Now, when I
38 try to run it, I get this:
39
40 michael@bullet ~ $ system/resizepics
41 system/resizepics: line 11: [: too many arguments
42 system/resizepics: line 11: [: too many arguments
43
44
45 The error is printed twice because there are two .JPG being checked, but
46 I'm not sure why the error is occurring in the first place. Line 11
47 says:
48
49 if [ ! -e current/$x ]; then
50
51 This used to mean "if a file named "current/<whatever $x is>" does not
52 exist, then execute the following block", but it keeps tripping on this
53 line. Was the -e switch deprecated or something? What should it be?
54 If it matters, my /bin/bash version is
55
56 michael@bullet ~ $ bash --version
57 GNU bash, version 3.00.16(1)-release (i586-pc-linux-gnu)
58 Copyright (C) 2004 Free Software Foundation, Inc.
59
60 Please help!
61
62
63 --
64 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] OT - Question about new bash fire-eyes <sgtphou@×××××××××.org>
Re: [gentoo-user] OT - Question about new bash znx <znxster@×××××.com>
Re: [gentoo-user] OT - Question about new bash Alexander Skwar <listen@×××××××××××××××.name>