Re: running a perl script with RunTime.Exec causes perl script to die
Re: running a perl script with RunTime.Exec causes perl script to die
- Subject: Re: running a perl script with RunTime.Exec causes perl script to die
- From: Johan Henselmans <email@hidden>
- Date: Wed, 8 Nov 2006 13:28:31 +0100
Op 8-nov-2006, om 12:18 heeft Patrick Middleton het volgende geschreven:
On 7 Nov 2006, at 23:46, Johan Henselmans wrote:
Thanks everyone for the reply. As always, the problem is in the
spaces and commas. When I looked at the syslog of the program, I
suddenly noticed that the ordernr was zero. As it happens, the third
commands[] argument (--ordernr) had a space in front of it, that
caused the perl script to run without arguments. No arguments, no sql
query that could run, hence the error.
Logical, actually.
I have produced a perl script to do some printing and database
housekeeping, which is called using Runtime.Exec.
The script connects to a postgresql database, selects a parent-
record via an argument and then prints some information from the
children records.
When I run this script from a shell, it runs fine.
However, when I call the script from the webobjects application, I
get an error message:
...
The java code that calls the script is:
****************************************
commands[0] = "/usr/bin/perl";
commands[1] = "/usr/local/bin/printorder.pl";
commands[2] = " --ordernr";
^^^^^^^^^^
Here is the order.
commands[3] = order.orderid().toString();
vars[0] = "PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/
bin";
vars[1] = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH";
...
********************************************************
Is there anybody that has experienced something similar and has
come up with a solution?
You are setting the perl script's environment variables in a way
that doesn't work.
If you run the perl script from a shell, the interpreter inherits a
suitable environment.
If run from java.lang.Runtime, LD_LIBRARY_PATH will be set to
'$LD_LIBRARY_PATH'. The dollar expansion is something done for you
by the shell; but there is no shell, so no substitution is done.
Rewrite your code to initialize vars[0] and vars[1] using explicit
values, perhaps obtained via java.lang.System.getenv().
Thank s for the remark. You are right, although it did not aggravate
the problem I had ;-)
--
Patrick Middleton
OneStep Solutions plc
351 London Road Phone: +44 (0)1702 426400
Hadleigh Fax: +44 (0)1702 556855
Essex. SS7 2BT Email: email@hidden
England (MIME welcome)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40netsense.nl
This email sent to email@hidden
Regards,
Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6273852
_______________________________________________
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