Shell command execution problem!


#1

Hi, well here comes my problem. I’m working on a function that will
generate PDF files automatically using files already existing. I’m
using pdftk utils to generate those files and everythings is working
just fine when testing in localhost on my laptop (I’m running windows
vista on it). But when I come to deploy the application on my server
(unix of course) and test the function, nothing occurs, seems that the
function is not executed (I don’t even have a error message…). here
comes the code for the execution of the function:

Merging front page and PDF

system("#{RAILS_ROOT}/public/products/pdftk #{RAILS_ROOT}/public/
orders/order#{order.id}/products/frontPage#{product.id}.pdf #
{RAILS_ROOT}/public/products/#{formatedProductName}.pdf cat output #
{RAILS_ROOT}/public/orders/order#{params[:id]}/products/finalPDF#
{product.id}.pdf")

while !File.exist?("#{RAILS_ROOT}/public/orders/order#{params[:id]}/
products/finalPDF#{product.id}.pdf")
# We wait…
end

RAILS_DEFAULT_LOGGER.info("\n\n#{RAILS_ROOT}/public/orders/order#
{params[:id]}/products/finalPDF#{product.id}.pdf created\n")

Generating password protected PDF

system("#{RAILS_ROOT}/public/products/pdftk #{RAILS_ROOT}/public/
orders/order#{params[:id]}/products/finalPDF#{product.id}.pdf output #
{RAILS_ROOT}/public/orders/order#{params[:id]}/products/#
{formatedProductName}#{params[:firstname].tr(’’’,’’)}#{params
[:lastname].tr(’’’,’’)}.pdf owner_pw #{adminAccessPassword} user_pw #
{customerAccessPassword}")

while !File.exist?("#{RAILS_ROOT}/public/orders/order#{params[:id]}/
products/#{formatedProductName}#{params[:firstname].tr(’’’,’’)}#
{params[:lastname].tr(’’’,’’)}.pdf")
# We wait…
end

The files and paths are correct, I verified several times. pdftk is
correctly installed on the server (I tested executing those two
commands manualy on the server, it worked perfectly and I could get
the files generated).

It’s pretty urgent, I’ve tested changing “system” for backquotes and
nothing. Any idea would be welcome ^^?

Olivier.


#2

What user is your Rails app running as on the server? That would be my
first suspect…

–Matt J.


#3

try piping it to STDOUT see if you get anywhere. Ex:
sh.system(“ls”, “-l”) | sh.head > STDOUT


#4

Ok, thanks for the help, I changed the path for the system command
execution and did the trick, I don’t really know what was the problem
but hope it won’t come back…^^

Anyway, thanks for taking time to respond to my question :wink:

Olivier.