Forum: Ruby on Rails Shell command execution problem!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ce14206b729afc6ac1d4c454eb434af0?d=identicon&s=25 CiriusMex (Guest)
on 2009-05-20 21:48
(Received via mailing list)
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.
6883e5ef03484d4fcef507d7b4f1d243?d=identicon&s=25 Matt Jones (Guest)
on 2009-05-21 21:32
(Received via mailing list)
What user is your Rails app running as on the server? That would be my
first suspect...

--Matt Jones
Bb71d4877b2f770208509ea5933eaaac?d=identicon&s=25 Michael Steinfeld (Guest)
on 2009-05-21 21:45
(Received via mailing list)
try piping it to STDOUT see if you get anywhere. Ex:
sh.system("ls", "-l") | sh.head > STDOUT
Ce14206b729afc6ac1d4c454eb434af0?d=identicon&s=25 CiriusMex (Guest)
on 2009-05-21 23:45
(Received via mailing list)
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 ;)

Olivier.
This topic is locked and can not be replied to.