Topic: Starting Acrobat Reader in code

After generating a PDF via prawn, I succeed in automatically displaying the file using Acrobat, in Linux.

I get this error though:

dirname: missing operand
Try `dirname --help' for more information.



The code is:

system '/usr/bin/acroread', 'reports/test.pdf'

What am I missing? Typing dirname --help was of no help.

Last edited by vilanye (2010-07-12 21:46:30)

Re: Starting Acrobat Reader in code

This might not even be a ruby problem.  Before you try and do it with system, can you just do it on the command line first?  If so then what do you type into the command line to get it to work?  AFAIK what you are doing now is equivalent to typing

/usr/bin/acroread "reports/test.pdf"

as the second argument to system is kept wrapped in the string when it is sent to the command line/shell.

What you might mean to do (on the command line) is this

/usr/bin/acroread reports/test.pdf

in which case your system call should put all of the above in a single string, ie

system "/usr/bin/acroread reports/test.pdf"

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: Starting Acrobat Reader in code

oh and as a side note, usually /usr/bin is in your PATH environment variable, so you can call exes in it simply by name, rather than specifying the full path to it.  If it isn't in your path then you should add it as it's a standard location for executables. 

And, also, sometimes you might need to put ./ at the start of the path to a local file you want to open (this always seemed a bit random to me but i'm not a *nix expert). 

Putting these together, an alternative call would be

system "acroread ./reports/test.pdf"

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: Starting Acrobat Reader in code

Putting it all in one string fixed it, thank you.

Re: Starting Acrobat Reader in code

If you are a new linux user and want to read or edit pdf files, here are a review of the most used  linux pdf software