Executing Bash Scripts

I have a not very complex bash scripts which executes a java program using java -jar <jar file> <arg0> <arg1> <arg2>. It outputs a latex file which is then compiled by pdflatex. When I run my bash script it executes just fine directly from the command line. However, when I run it with <cfexecute> and my web service, it runs the java program and then trys to execute pdflatex. I get the empty execute log but nothing more. Are there any suggestions on this process? Is there something I am missing? Thanks!!

Are you using <CFExecute>? Can you show some code snippets?

Are you using full file paths. cfexecute doesn’t allow you to set the working directory. Also, try it in bash under the user that Lucee runs as since that should be what’s used for the script.

1 Like

Code below…The weird thing is it will run when I run it from the command line. When running it with lucee it stops at the first pdflatex.

Here is the CFML:

<!--- arguments: database, securityKey, notifyEmail --->
myPostData = ToString(getHTTPRequestData().content);
myPostDataStruct = deserializeJson(myPostData);

<!--- Call bash script to generate and compile LaTex code --->
	Processing: #myPostDataStruct.database# #myPostDataStruct.securityKey# #myPostDataStruct.notifyEmail#
	<cfexecute name="bash /opt/lucee/tomcat/webapps/ROOT/ffllog/reports/compileReport.sh"
		   arguments="#myPostDataStruct.database# #myPostDataStruct.securityKey# #myPostDataStruct.notifyEmail#"
		   outputFile="/opt/lucee/tomcat/webapps/ROOT/ffllog/cfexecute.log" />

Here is the bash script:


cd /opt/lucee/tomcat/webapps/ROOT/ffllog/reports

echo "Create LaTex Source"
java -jar /opt/lucee/tomcat/webapps/ROOT/ffllog/reports/FFLAcqAndDispCloudReport.jar ${CLIENT} ${ENCRYPT_KEY} ${NOTIFY}

echo "Process path: /opt/lucee/tomcat/webapps/ROOT/ffllog/reports/${CLIENT}"

#SOURCE_FILE="$(ls /opt/lucee/tomcat/webapps/ROOT/ffllog/reports/${CLIENT})"
cd /opt/lucee/tomcat/webapps/ROOT/ffllog/reports/${CLIENT}

echo "Compiling round 1: ${SOURCE_FILE}"
pdflatex ${SOURCE_FILE}

echo "Compiling round 2: ${SOURCE_FILE}"
pdflatex ${SOURCE_FILE}

cd /opt/lucee/tomcat/webapps/ROOT/ffllog/reports

echo "Creating directory: ${CLIENT_COMPILED}"

echo "Move pdf: ${CLIENT}/*.pdf ${CLIENT_COMPILED}"

#rm -rf ${CLIENT}

I got this figured out, sort of…I got to thinking about PATH for tomcat maybe…I know very little about tomcat. Anyhow, I changed my call to pdflatex to use the absolute path for the command. It is now working…So I guess java is on the path for lucee and other commands may not be? It is however working now.

I’m glad you have that working, but for what it’s worth, I still have zero idea exactly what it is you’re doing! :slight_smile: Are you calling the shell script manually and it in turn calls the CFML code (if so, how??) or are you running a CF web page, which in turn calls the shell script (if so, how???).

The snippet didn’t really help did it?

I have a .cfml page which received JSON via POST and deserialized it. It in turn used cfexecute to call a bash script passing the arguments from the JSON. The bash script executes an executable jar to create LaTex source code and then I call pdflatex to compile the LaTex source into a .pdf. I would have had the .jar also do the compile, but I was having a time with that as well and then came up with the idea of having the bash script do it instead.

I may have a habit of making not so complex things very complicated. I once heard a podcast say if it isn’t complicated you aren’t doing it right…LOL

1 Like

It may have been hidden in the original post; i edited to apply code formatting.

To post code, you get the best result by fencing with backticks in the markdown.

For example,