开发者

Running system call in rails causes error

When I try to run the following code:

system("pdftk #{@@temp_file_path} output #{@@file_path} user_pw #{@@pass}")

I get this error:

Permission denied - /tmp/billing.pdf
开发者_运维知识库

I tried running:

chmod +x /tmp

But that didn't help.

Any suggestions?


What are the permissions on /tmp (you can find this with 'ls -ld /tmp')? Are you trying to create billing.pdf or modify an existing file?

The user executing your rails process probably needs write privilege in addition to execute privilege (which you were adding with the 'chmod +x' command). Also, if there's already a billing.pdf file in /tmp, it would need to allow the rails user to read or write it (whatever you're trying to do).


Adding this system call first fixed the problem:

system("chmod +w @@temp_file_path")

For some reason rails pdf-writer plugin generates files as read only. Maybe it has options to override that. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜