But nothing will convince it that -resize 120x120 is an argument not a file!!!
The file arguments themselves are fine $searchdir and $tndir are interpreted right. Indeed I get unaltered files dumped in the destination directory which kind of confirms that its just the -resize flag that isn't getting heard.
I have read the man for this program over many times and I'm sure i'm using it correctly.
Any ideas on how to crack this? Many thanks to any takers.
I had an idea to debug this , im breaking it right down to basics
When I execute this from a script in the same directory as the given .jpg file it WORKS
echo I am doing this from a script
convert resize 120x120 apache.jpg apachetn.jpg
But when I put the filenames into variables
searchfile="apache.jpg"
tndir="apachetn.jpg"
echo I am a script that uses variables
echo $searchfile
echo $tndir
convert resize 120x120 $searchfile $tndir
IT FAILS
convert: Unable to open file (resize) [No such file or directory].
convert: Unable to open file (120x120) [No such file or directory].
btw it makes no difference if the variables are quoted or not
So my logic tells me that the last two vars are getting lost completely and hence convert is taking -resize and 120x120 to be the filenames
What your saying reminds me of all those times I was banging my head trying to get a script called 'test' to work..... but alas it doesn't seem to be my problem on this occasion. The quest continues....
My Bash powers are weak but my next guess is to use 'here document' or command substitution... am I thinking right? How would I recast the syntax to use an alternative method of calling convert?
Perhaps when you run "convert -resize 120x120 apache.jpg apachetn.jpg", the values 'apache.org' and 'apachetn.jpg' are being passed to your convert program. But when you pass '$searchfile' and '$tndir', your convert program does not know what your script assigned to those variables...
Although this:
convert -resize 120x120 $searchfile $tndir
convert: Unable to open file (]resize) [No such file or directory].
convert: Unable to open file (120x120) [No such file or directory].
really looks like your script is inadvertently executing the "convert" command instead of your "convert" program.
Try this: rename your convert program to myConvert and just use that instead. Is that do-able?
Now im calling that link and everything works fine, must be a paths/environment issue, not sure I'll ever truly know but I've sure learned a lot of Bash the last 24 hours.
So thanks for all your thoughts that kept me going. Im kinda glad this problem had me beat because I discovered this place now. Hope you 'have a day' too and that it its filled with an adequate amount of prosperity and happiness