CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
can't execute command line with perl/coldfusion 10

 



charedrive
Novice

Aug 29, 2014, 1:06 PM

Post #1 of 14 (1246 views)
can't execute command line with perl/coldfusion 10 Can't Post

We're attempting to upgrade our application CF9 to CF10 (running on Solaris) and some of our perl scripts have stopped executing command line tasks.

Command line example from perl script:

system("/apps/commonApps/distiller/Distiller/distill -compat 1.3 /apps/edcc/upload//sdg29103588_23.ps");

The distiller is set up to be executable by everyone. I can run the distiller directly and I can execute the perl script directly without issue. It's just when the Coldfusion attempts to execute the perl that we have problems. Does anyone have ideas? I can't find any logs with errors.


FishMonger
Veteran / Moderator

Aug 29, 2014, 1:23 PM

Post #2 of 14 (1244 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

So, the perl script runs fine when executed manually but your coldfussion app can't execute the perl script?

Sounds like a problem with coldfusion and not with perl.

If you do have perl related problem, then we'll need more details on the problem you're having including any error messages the perl script is generating.

Maybe the problem is related to file permissions on the perl scripts (or path leading upto them) are not set correctly.


charedrive
Novice

Aug 29, 2014, 1:27 PM

Post #3 of 14 (1241 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

The perl script has full executable on it as well. The coldfusion is executing the perl script because I added some debugging to the script and I'm seeing the output from that. It's just won't execute the command lines within the perl. I am trying to find an answer over at the Adobe forums but thought someone here might have had a similar experience.


FishMonger
Veteran / Moderator

Aug 29, 2014, 1:42 PM

Post #4 of 14 (1237 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

You'll need to post more of the code so we can see how you're executing the commands and what if any steps you're tacking to verify the execution.

Take a look at perldoc -f system to see some examples on how to test the execution.


charedrive
Novice

Aug 29, 2014, 1:55 PM

Post #5 of 14 (1232 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

This is the coldfusion call: <cfexecute name="#EDRSDIR#/uploadconvertwrapper.pl" arguments="#filedirectory# #finalfilename# #dcnflag# #splflag#" outputFile="/dev/null" timeOut="0" />

uploadconvertwrapper.pl does this:

my($directory,$filename,$dcnflag,$splflag) = @ARGV;

$ENV{'USER'} = "edcc";
$autofile = "/apps/edcc/htdocs/edcc/edrs/uploadconvert.pl";
open(OUTLOG ,">> /apps/edcc/logs/uploadconvert.log");
print OUTLOG "Start of $directory, $filename, $dcnflag, $splflag\n";
unless (fork){# execute JOB file in background
exec '/apps/perl/bin/perl', $autofile, $directory, $filename, $dcnflag, $spl
flag;
}#end unless
print OUTLOG "End of $directory, $filename, $dcnflag\n";
close(OUTLOG);
exit 1;

and uploadconvert.pl does this:

.......

#
print ALEX qq^ps file submitted. prep for distill.\n^;
print ALEX qq^---cmd: $DISTILLCOMMAND $IN_DIR/$newfilename\n^;
#Just distill it
system("$DISTILLCOMMAND $IN_DIR/$newfilename");

sleep 5;
#setup the new filename
($prefix = $newfilename) =~ s/\.\w+$//;
$newfilename = $prefix . ".pdf";
print ALEX qq^new filename is: $newfilename\n^;
#copy it to the correct location

..........


I can follow the progress with the print commands just fine. The ALEX log updates however I execute the perl script (directly or coldfusion) so i know the coldfusion can find and execute the perl. The result is supposed to be a new .pdf file in the same directory but that doesn't happen through coldfusion.


(This post was edited by charedrive on Aug 29, 2014, 1:55 PM)


FishMonger
Veteran / Moderator

Aug 29, 2014, 2:18 PM

Post #6 of 14 (1224 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

The main problem I see is that you're not preforming any kind of error checking/handling.

Start by adding a print statement just before the system call to verify that the command to be executed is exactly what you expect it should be. Oops, I missed your print statement.

Next, add some error checking on the system call to see where it's failing.

Using the example in the documentaion for the system function, you could do this.

Code
print ALEX "$DISTILLCOMMAND $IN_DIR/$newfilename\n"; 

system("$DISTILLCOMMAND $IN_DIR/$newfilename");

if ($? == -1) {
print ALEX "failed to execute: $!\n";
}
elsif ($? & 127) {
printf ALEX "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf ALEX "child exited with value %d\n", $? >> 8;
}



(This post was edited by FishMonger on Aug 29, 2014, 2:20 PM)


charedrive
Novice

Aug 29, 2014, 2:21 PM

Post #7 of 14 (1220 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

Thank you for the example. I was trying to figure out the error handling but was struggling.


charedrive
Novice

Aug 29, 2014, 2:26 PM

Post #8 of 14 (1216 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

And I have no idea what this means: child exited with value 83


FishMonger
Veteran / Moderator

Aug 29, 2014, 2:35 PM

Post #9 of 14 (1214 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

An exit code of 0 would mean it completed successfully. Any other exit code would mean there was some kind of failure. There are some standard/default codes that have specific meaning, but the app is free to define the meanings of their exit codes as the see fit.

Do you have any documentation on your distiller app that tells you the meaning of its exit codes?


charedrive
Novice

Aug 29, 2014, 2:42 PM

Post #10 of 14 (1212 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

Not that I can find so far. There is a log file in the distiller directory but I apparently don't have the permissions to view it. I'll have to get with a server admin on Tuesday. This may be the most progress I've made on this all week. Thank you for following up with me on this, FishMonger.


FishMonger
Veteran / Moderator

Aug 29, 2014, 2:45 PM

Post #11 of 14 (1209 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

Glad I could help.

Hope you figure it out on Tue.


charedrive
Novice

Sep 4, 2014, 1:56 PM

Post #12 of 14 (1074 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

I'm back. The distiller log only reported successful jobs. No error logging. The problem seems to be some kind of conflict between the user account the distiller expects versus the user account the coldfusion is running as. I can execute the perl script with no issue directly from the command line. Is it possible to change the following code to act like it's a command line execution (possibly specifying the user to execute as)?

$autofile = "/apps/edccint/htdocs/edcc/edrs/uploadconvert.pl";
open(OUTLOG ,">> /apps/edccint/logs/uploadconvert.log");
print OUTLOG "Start of $directory, $filename, $dcnflag, $splflag\n";
unless (fork){# execute JOB file in background
exec '/apps/perl/bin/perl', $autofile, $directory, $filename, $dcnflag, $splflag;
}#end unless
print OUTLOG "End of $directory, $filename, $dcnflag\n";
close(OUTLOG);
exit 1;


FishMonger
Veteran / Moderator

Sep 4, 2014, 2:16 PM

Post #13 of 14 (1070 views)
Re: [charedrive] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

The first step would be to add error handling on the open call to verify it was successful and output an error message telling why it fails.


Code
open(OUTLOG, ">>', "/apps/edccint/logs/uploadconvert.log") 
or die "failed to open '/apps/edccint/logs/uploadconvert.log' <$!>";


If you don't see the error msg when it fails, then that would tell me that your coldfusion app is capturing STDERR possibly redirecting it to /dev/null


charedrive
Novice

Sep 9, 2014, 2:41 PM

Post #14 of 14 (930 views)
Re: [FishMonger] can't execute command line with perl/coldfusion 10 [In reply to] Can't Post

Finally found the answer yesterday. The account running the coldfusion changed. When I ran the command line with the new account, I got an error stating I didn't have access to a hidden directory. Once the permissions were updated and a few perl config setting were updated for the new account, I was able to get everything to work. Thanks again for the help, FishMonger.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives