Forum Moderators: coopster & phranque

Message Too Old, No Replies

Problem running IDL from perl

Script doesnt run IDL properly when called from webpage

         

Duncs

2:27 pm on Dec 19, 2003 (gmt 0)

10+ Year Member



Hello,

I have a script that runs IDL. The IDL programme converts a .txt image to an .fit image. THe code is like this:

open(IDL, "¦/usr/local/bin/idl >/dev/null 2>&1") ¦¦ print WRITER "Unable to open idl conversion \n";

print IDL ".r /stage/home/dat/GAIA/gaiasim_requests/idl/image2fits.idl", "\n";
print IDL "/stage/home/dat/GAIA/gaiasim_requests/images/$parameter/image.txt", "\n"; #THIS IS WHERE TO LOOK FOR THE INPUT FILE
print IDL "/stage/home/dat/GAIA/gaiasim_requests/fitsfiles/image_$parameter.fit", "\n"; #THIS IS THE OUTPUT FILE I WANT

close(IDL);

Now when i run this from a shell, just by typing GAIAdatamove.pl, it successfully take the txt file and writes a .fit image into the other folder.

Now this script is just a section of a much larger script, that runs various programmes to produce the .txt file. It is called by procmail, which passes an email to it [which contains variables from a html form].

Now when the script is run on the "SUBMIT" button from the webpage everything runs fine up to the idl bit. The .txt file i produced and idl is called...

This is my log file:

Comments for request at: 191203140759
working directory: /stage/home/dat/GAIA/simulator

program called at: Fri Dec 19 13:38:43 GMT 2003

program completed at: Fri Dec 19 14:08:03 GMT 2003

idl conversion called at: Fri Dec 19 14:08:03 GMT 2003

idl conversion completed at: Fri Dec 19 14:08:05 GMT 2003

Now the call and completion are just print statements b4 and after the running of the various programmes. THey are not linked to its success.

The interesting thing is the IDL program does run, it spends 2 seconds running, only slightly shorter than when it runs successfully and produces the .fit image. This suggests that it is just failing on one of the commands....
maybe the write command.

Ive checked all the folder permissions, and anyway ive written a .txt file from perl to similar folders already in the script and that was fine.

Does anybody know anything about IDL when being run in batch mode?! There was a related post here which looks like
the same problem as mine, but the solution was never posted!

h*ttp://forums.devshed.com/t17555/s.html

[APOLOGIES FOR A LINK 2 A DIFFERENT FORUM!]

anyone got any ideas!?

Thanks,

Duncs

Duncs

4:10 pm on Jan 7, 2004 (gmt 0)

10+ Year Member



Don't worry i finally solved this problem and i thought i'd post the solution just in case of the likely even that some poor soul gets the same problem in the future!

Turns out that IDL is an ass btw, and avoid it if you can!

It was basically that when you try to run IDL in batch mode, through a perl script that had been started remotely there were problems with environmental variables.

I think the perl script runs in a bourne shell, but because it hasn't been opened by a user non of the .profile files have been loaded. This means that when you do a system call to idl, it doesn't know where to find it.

This can be solved in my perl script by adding amongst others:

$ENV{'PATH'} = '/usr/local/bin:/usr/bin:/usr/sbin:/sbin';

i.e. creating the environmental variables applicable to idl manually.

It's odd as when run in this way the perl script is technically running as me [started by MY procmail] but without any things i normally have.

Be careful, to make sure all the paths are in their, for things like where idl can look for all its intrinsic functions! -otherwise it crashes when its loaded.