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