SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Nov 19, 2007, 17:56 #1
- Join Date
- Aug 2004
- Location
- Novi Sad, Serbia
- Posts
- 60
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
System call different when calling from controller and from console
Hello,
I have a problem with making a system call to a Java program via Rails. When I call it through controller it doesn't seem to work, but when I do the same thing in console it works perfectly.
There are two models Order and Payment (Order has one Payment). Payment model that has following method:
Code Ruby:def transaction_register() output_raw = `java -jar #{JAR} #{MERCHANT} -a #{(self.amount*100).to_i.to_s} #{CURRENCY} #{self.ip_address}` output = YAML.parse output_raw # ...removed rest of the code... end
Code Ruby:def save_order order = Order.new order.order_items << @cart.items order.payment = Payment.new order.payment.ip_address = request.env["REMOTE_ADDR"] order.payment.amount = order.total_cost order.payment.transaction_register # ...removed rest of the code... end
The problem is that when this code is run through a controller it doesn't seem to execute, but when I do almost (I only fake ip_address) the same thing in console it works.
Does anyone has any ideas what might be the problem?
Thanks."Strategy without tactics is the slowest route to victory.
Tactics without strategy is the noise before defeat."
- Sun Tzu
Icebergist - a web dev blog | Orange Iceberg Web App Development
-
Nov 20, 2007, 06:34 #2
It may be that java is in your PATH environment var when you run it from the console, but not when run from the webserver, with a different user.
I'd try adding the whole path to your command line, for example `/usr/bin/java ...`.
-
Nov 20, 2007, 07:35 #3
- Join Date
- Aug 2004
- Location
- Novi Sad, Serbia
- Posts
- 60
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks. That helped.
I should have thought of that sooner."Strategy without tactics is the slowest route to victory.
Tactics without strategy is the noise before defeat."
- Sun Tzu
Icebergist - a web dev blog | Orange Iceberg Web App Development
-
Nov 20, 2007, 08:37 #4
That kind of thing is pretty hard to spot without a second, rested pair of eyes.
I'm glad I could help.
Bookmarks