Page 1 of 1

difference between cmd line & script

Posted: 2017-02-12T11:31:09-07:00
by DennyC
Hi...

I have an awk script that I am trying to use convert in and it fails with the following error...

dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found

if I copy and paste the offending line on the command line it executes just fine...

Here is part of the awk script...

BEGIN{
FS = "/";
}
{
fileName = $NF;
split (fileName, tmpFileName, ".");
sysCmd = sprintf ( "cp %s __TEMPORARY_FILES__/tmpFile.%s", $0, tmpFileName[2]);

sysCmd = sprintf ( "convert __TEMPORARY_FILES__/tmpFile.%s __TEMPORARY_FILES__/tmpFile.eps", tmpFileName[2]);
system (sysCmd);

print ">>";
print ">> "sysCmd;
print ">>";
}

And the output...
dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found
>>
>> convert __TEMPORARY_FILES__/tmpFile.pgm __TEMPORARY_FILES__/tmpFile.eps
>>


Thanks for every and anyone's help in advance.

Re: difference between cmd line & script

Posted: 2017-02-12T12:27:07-07:00
by fmw42
try using the full path to convert and to your images

Re: difference between cmd line & script

Posted: 2017-02-12T12:43:52-07:00
by DennyC
just tried it and its still a problem. Output bellow...


dyld: Library not loaded: /ImageMagick-6.8.9/lib/libMagickCore-6.Q16.2.dylib
Referenced from: /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert
Reason: image not found
>>
>> /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert __TEMPORARY_FILES__/tmpFile.pgm __TEMPORARY_FILES__/tmpFile.eps
>>

Re: difference between cmd line & script

Posted: 2017-02-12T12:50:42-07:00
by fmw42
Can you run your IM command in a terminal without error (outside of AWK)?

Are you sure that is the path to convert? What do you get from

Code: Select all

type -a convert
or

Code: Select all

which convert
What do you get from

Code: Select all

convert -version

What is your platform?

Re: difference between cmd line & script

Posted: 2017-02-12T13:39:05-07:00
by DennyC
Yes... I can run my IM command (convert) in a terminal without any errors outside of AWK. Works very nicely

here is the answers to your questions...

type -a convert
convert is /Users/dennis/Applications/ImageMagick-6.8.9/bin/convert

which convert
/Users/dennis/Applications/ImageMagick-6.8.9/bin/convert

convert -version
Version: ImageMagick 6.8.9-3 Q16 x86_64 2014-06-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib jng jpeg lcms png tiff xml zlib


I am using the Mac version, and I'm running OSX 10.12.2

Re: difference between cmd line & script

Posted: 2017-02-12T14:51:49-07:00
by DennyC
I simplified the problem to a two line script...

A script of the following fails with the errors listed above.

#!/bin/sh
convert tmpFile.pgm tmpFile.eps


but "convert tmpFile.pgm tmpFile.eps" on the command line works.

Re: difference between cmd line & script

Posted: 2017-02-12T15:17:38-07:00
by snibgo
Does the script run under the same username, with all the same privileges and environment variables as the interactive user?

Re: difference between cmd line & script

Posted: 2017-02-12T16:23:25-07:00
by fmw42
try

Code: Select all

#!/bin/bash
/Users/dennis/Applications/ImageMagick-6.8.9/bin/convert/convert tmpFile.pgm tmpFile.eps
Do you have the path to IM in your PATH environmental variable?

Re: difference between cmd line & script

Posted: 2017-02-12T16:25:32-07:00
by fmw42
Delegates: bzlib jng jpeg lcms png tiff xml zlib
You have no delegates for eps. You probably need ghostscript (and if you have text, then freetype, fontconfig ?)

How did you install IM for you Mac? If from source, then you need to install relevant delegates first. If from binary, then the delegates should be there.

I would recommend installing a binary from MacPorts (or Homebrew).

I install all my delegates from MacPorts and then install IM from source. See viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202

Re: difference between cmd line & script

Posted: 2017-02-12T18:10:36-07:00
by DennyC
figured it out kids...

its all about... export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"

it exists in my .bash_profile so anything I do on the command line it works. Anything I execute in a script (with #!/bin/bash or with awk), the system bash profile has the line missing. If I add the above line to my script it works.