cauchi
cauchi

Reputation: 1543

execute system command on rails - not working in production

On development everything works great. On production however, this line of code in a controller is no working:

    output = `mclines #{paramFileName} #{logFileName} #{outputFileName}`

where mclines is a c program, and the rest are names of files. mclines is not executed on the production server, but it does on my laptop. I have no idea about what to fix. Have been trying different things for hours, but the truth is that I'm quite lost. In production the ssl in on, that's the only major difference.

If I execute the command on the shell, it gets executed. When I say it doesn't gets executed is because the first thing it should do is print some info in a file, and it doesn't. The server -as my laptop- is running ubuntu, but I have no idea about what logs could be usefull to read. systemlog had nothing usefull.

Any ideas that can lead to find the culprit are welcome.

Upvotes: 0

Views: 463

Answers (2)

eugen
eugen

Reputation: 9226

Make sure mclines really exists on the production server, and use the full path to the mclines executable, as in

output = `/full/path/to/mclines #{paramFileName} #{logFileName} #{outputFileName}`. 

Upvotes: 1

Rahul garg
Rahul garg

Reputation: 9362

Reference this

Try to print out your exit status code as:

$?.to_i

after the command...

or as pointed out in this link you can always use popen3/popen4 for better handling of input/output for system commands...

Upvotes: 0

Related Questions