Re: [OT] call gifsicle via Java process
Re: [OT] call gifsicle via Java process
- Subject: Re: [OT] call gifsicle via Java process
- From: "Jerry W. Walker" <email@hidden>
- Date: Sat, 10 Feb 2007 15:04:59 -0500
Hi, Ute,
On Feb 10, 2007, at 11:58 AM, Ute Hoffmann wrote:
Hi Jerry,
thank you very much for your help. I did as you told me, tried to
su to appserver but could not. (I was still root after the su).
I haven't tried this as root, but if you can log in as a non-root
user with admin and sudo privileges, execute the following command:
sudo -u appserver sh
That should put you in a unix shell as appserver. You can confirm
this by going into a directory for which appserver has no write
permissions and trying the Unix touch command to create a new file.
When you've confirmed that you're appserver, try to execute your
gifsicle command again within the directory that WO tries to execute
it. If that works, then you should start examining appserver's shell
environment (which should have been printed out by the small shell
script I gave you.
So I made the sh and executed it and got this as whoami:
I am:
appserve tty?? Feb 10 17:45
Is it right that it says appserve? Is that just shortened or is the
user really appserve (without r)?
No, it's not right, it just truncates to 8 characters. You were
right, it's appserver.
I am executing within the directory:
/Library/WebObjects/Applications/ttcmsboard.woa
right. The image files I try to work on are created previously by
the same WOApp via another exec talking to imageMagick. The user
appserver has all rights on them, they belong to him, to be precise.
Yes, but does appserver have permissions at the directory level to
create a new file in that directory?
I use imageMagick extensively in this component and all calls work
fine, overwriting the existing image whenever needed. So
ImageMagick seems to have read and write rights.
Though I doubt it, it's possible that ImageMagick has the suid bit
set and is running as an suid program with root permissions set.
Any idea? The call? perhaps the call is faulty?
I tend to doubt it, but it's possible.
Regards,
Jerry
Am Samstag, 10.02.07 um 15:43 Uhr schrieb Jerry W. Walker:
HI, Ute,
This sounds very much like a permissions problem. It looks like
gifsicle is throwing that first "Error with conversion" because it
can't open a file which is cascading to the other errors.
You say that you are logged in as root. I presume you mean that
when you "...open a terminal on the server and copy..." you are
logged in as root. If that's the case, my first question is what
user is your WO app running under?
When your WO app is running, do a ps command on Terminal to see
what user it is running under. Then do an "su" command to that
user on your terminal and try running the gifsicle command
manually again as that user.
The other possibility (less likely) is that the user environment
for your running WO app is missing some critical parameter for
gifsicle. To test that, you might copy the following to a shell
script:
#! /bin/sh
{
echo "I am:"
who am i
echo "\nI am executing within the directory:"
pwd
echo "\nMy environment is:"
env
} > /tmp/testoutput.txt
If you exec that little shell script from within your WOApp
instead of gifsicle, it should answer all of the above questions.
You will find the answers, of course, at /tmp/testout.txt.
Regards,
Jerry
On Feb 10, 2007, at 5:56 AM, Ute Hoffmann wrote:
Hallo,
I'm sorry for this off topic post, but im pulling my hair after
hours of testing and looking and perhaps someone sees what I miss.
I need to call gifsicle from a java process to optimize .gif
images (as imageMagick fails to do so and getting it working with
ImageMagick seems to either need a very old IM version or some
tuning of the tifflib. I looked into it but descided not to).
This is what I want to do:
call a exec from my java function which hands over the correct
infos to gifsicle and gifsicle reading the file in and writing it
optimized back to disk.
This is the error I get:
Fehler bei der KonversionTTGifsicle$Exception: Could not exec
process: /usr/local/bin/gifsicle < /Library/WebServer/Documents/
cmsboard/ttwcmsdaten/bilder/tmp/26basispaket9.gif > /Library/
WebServer/Documents/cmsboard/ttwcmsdaten/bilder/tmp/ute_nn.gif:
not found. invocation line: /usr/local/bin/gifsicle < /Library/
WebServer/Documents/cmsboard/ttwcmsdaten/bilder/tmp/
26basispaket9.gif > /Library/WebServer/Documents/cmsboard/
ttwcmsdaten/bilder/tmp/ute_nn.gif. error output: null
The file is there. When I open a terminal on the server and copy
/usr/local/bin/gifsicle < /Library/WebServer/Documents/cmsboard/
ttwcmsdaten/bilder/tmp/26basispaket9.gif > /Library/WebServer/
Documents/cmsboard/ttwcmsdaten/bilder/tmp/ute_nn.gif
into the terminal gifsicle does as asked. Only difference aside
from java involved/not involved: I'm logged in as root
So:
a) Do you think that what I see here is a permission problem
b) Has someone experience with calling gifsicle from java and
could perhaps give me a code example of the call.
Thank you for some insight.
Regards
Ute
P.S:
This is my call:
String[] cmdArray = new String[] {
"/usr/local/bin/gifsicle "+"< "+sourceFilePath+" > "+outFilePath
};
NSMutableArray stdErrContents = new NSMutableArray();
NSMutableArray stdOutContents = new NSMutableArray();
int resultCode;
try {
resultCode = exec( cmdArray, stdOutContents, stdErrContents );
}
catch ....
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@gmail.com
This email sent to email@hidden
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden