windows gs detection

M

Martin DeMello

Is there a nice way under windows to determine if the user has
ghostscript installed? Do I have to rely on his having it in his path?

martin
 
S

Shashank Date

Hi Martin,

Martin DeMello said:
Is there a nice way under windows to determine if the user has
ghostscript installed?

Searching for the registry is one way to do it ... see attached
screen-shot of how it looks on my machine. Of course, you would
want to determine this programmatically, right? Hint: You will have
to require 'win32/registry.rb'
Do I have to rely on his having it in his path?

Well, path will tell you that gswin32.exe is available as a command
without requiring explicit full path-name. It does not prove the
existence (or lack thereof) of the software.

HTH,
-- shanko
PS> I am curious to know how your postscript generation is coming
along .. are you also generating PDFs?
 
M

Martin DeMello

Shashank Date said:
Hi Martin,



Searching for the registry is one way to do it ... see attached
screen-shot of how it looks on my machine. Of course, you would
want to determine this programmatically, right? Hint: You will have
to require 'win32/registry.rb'

Thanks, I'll dig into that. Is it guaranteed that ghostscript will make
a registry entry when it's installed, do you know? I'm optimistic about
this because cutepdf
[http://www.acrosoftware.com/Products/CutePDF/writer.asp] says it'll
autodetect a ghostscript installation; I just didn't know how it was
done.
Well, path will tell you that gswin32.exe is available as a command
without requiring explicit full path-name. It does not prove the
existence (or lack thereof) of the software.

I don't get this bit. What I meant was, need a solution depend on gs
being in the path, and test directly if I can run ps2pdf or if it
returns an error.
HTH,
-- shanko
PS> I am curious to know how your postscript generation is coming
along .. are you also generating PDFs?

Coming along very nicely, and yes, it's doing pdfs too (once I figured
out I had to call "ps2pdf.bat" rather than "p2spdf"). Right now it relies
on the fact that both ps2pdf.bat and gswin32.exe are in my path, which
from the point of view of a non-techie user is suboptimal; I'm looking
into autodetecting the ghostscript install and adding it to ENV['PATH']
before calling system().

You can see the code and sample output at http://zem.novylen.net/ruby

martin
 
S

Shashank Date

Hi Martin,

Martin DeMello said:
Thanks, I'll dig into that. Is it guaranteed that ghostscript will make
a registry entry when it's installed, do you know?

Assuming that the installation procedures get properly executed,
yes, I am reasonably sure that the registry entry will be there.
I'm optimistic about this because cutepdf
[http://www.acrosoftware.com/Products/CutePDF/writer.asp]
says it'll autodetect a ghostscript installation; I just didn't know how it was
done.

Don't know how they do it but thanks for the link. Will check it out.

I meant that the installation does not seem to add the component to
the path so the end-user has to do it manually. And any time there is
manual intervention, things be messed up ;-)

So, in my case, for example I have installed GS but did not add it to
the path. OTOH, you may add it to the path and then uninstall GS.
Relying on the PATH environment variable will be risky.
I don't get this bit. What I meant was, need a solution depend on gs
being in the path, and test directly if I can run ps2pdf or if it
returns an error.

Again, if you run ps2pdf and the test comes back with error it does
NOT imply that the s/w is not installed.

Hope I'm not missing the point.
Coming along very nicely, and yes, it's doing pdfs too (once I figured
out I had to call "ps2pdf.bat" rather than "p2spdf"). Right now it relies
^^^^^^^^^
He he, saw your tip on this a while back ;-)
on the fact that both ps2pdf.bat and gswin32.exe are in my path, which
from the point of view of a non-techie user is suboptimal; I'm looking
into autodetecting the ghostscript install and adding it to ENV['PATH']
before calling system().

Then registry is the way to go ... but still "guaranteed" is too strong a
word.
You can see the code and sample output at http://zem.novylen.net/ruby

Cool ! Thanks will check it out.
-- shanko
PS> Did not know your IITB (sorry IITM) lineage :)
 
M

Martin DeMello

Shashank Date said:
Again, if you run ps2pdf and the test comes back with error it does
NOT imply that the s/w is not installed.

Hope I'm not missing the point.

No, I was the one who missed the point. I wasn't sure if the registry
thing was guaranteed, and it seemed then that the only perfectly sure
way was (i) to require it in the path and (ii) to test that I could
actually call it.
PS> Did not know your IITB (sorry IITM) lineage :)

:) Which year?

martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top