I wrote a little application to merge n pdf files into 1 that executes the bash command bellow:
pdftk $files cat output $output_file
However I get an error of no such file while executing it.
The TCL script is an ad_form that gets all the n files from user input, within the on_submit block it merges the files and returns to the user a single pdf file.
-on_submit {
set files ""
for { set i 0 } { $i < $count } { incr i} {
set tmpfile [set file_${i}]
set filename [ns_tmpnam]
file copy [lindex $tmpfile 1] $filename
append files "$filename "
ns_log Notice "ONSUBMIT $files"
}
set output_file "[ns_tmpnam].pdf"
ns_log Notice "INPUT: $files"
ns_log Notice "OUTPUT: $output_file"
set command "pdftk $files cat output $output_file"
ns_log Notice "$command"
exec $command
#if {![catch { exec $command } errorMsg] {
# do nothing
#}
ns_returnfile 200 application/pdf $output_file
}
It would be a little and easy script if it wasn't for the error I get.
I tested the whole script mannualy, also wrote ns_logs to verify the commands. It seems TCL doesn't parse properly the value within $files.
If I determine static files as in "pdftk pdf_0.pdf pdf_1.pdf cat output $output_file"
It works fine. Moreover I printed the content assgined to $files and there's nothing wrong with it.
Have anyone once faced the same issue?
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Notice: ONSUBMIT
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Notice: INPUT: /tmp/pdf_0.pdf /tmp/pdf_1.pdf
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Notice: OUTPUT: /tmp/fileB5eWgF.pdf
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Notice: pdftk /tmp/pdf_0.pdf /tmp/pdf_1.pdf cat output /tmp/fileB5eWgF.pdf
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Warning: blank-compat: /var/www/mda/www/pdfmerge.adp uses deprecated property title instead of doc(title).
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Warning: blank-compat: /var/www/mda/www/pdfmerge.adp uses deprecated property header_stuff instead of head.
[16/Aug/2011:10:26:50][976.3052518256][-default:0-] Error: POST http://10.0.105.227:8000/pdfmerge?
referred by "http://10.0.105.227:8000/pdfmerge"
couldn't execute "pdftk /tmp/pdf_0.pdf /tmp/pdf_1.pdf cat output /tmp/fileB5eWgF.pdf": no such file or directory
while executing
"exec $command"
("uplevel" body line 24)
invoked from within
"uplevel #$level $on_submit"
("1" arm line 1)
invoked from within
"switch $errno {
0 {
# TCL_OK
}
1 {
# TCL_E..."
Request notifications