# 'system' and windows and an external program

**URL:** <https://www.ruby-forum.com/t/system-and-windows-and-an-external-program/100905>\
**Category:** Ruby\
**Created:** [August 1, 2006, 10:05pm UTC](https://www.ruby-forum.com/t/system-and-windows-and-an-external-program/100905 "2006-08-01T22:05:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 1, 2006, 10:05pm UTC](https://www.ruby-forum.com/t/system-and-windows-and-an-external-program/100905/1 "2006-08-01T22:05:04Z")

</div>

Dear all,

I have a Ruby program that does some lengthy calculations and outputs  
a matrix, which I’d like to write to a Postscript or PDF using Latex  
file  
for readability  
(and re-usability in some lengthier text).  
I have managed to put together the Latex code using Ruby, so I can  
start  
Latex using the system command

system(‘latex ’ + filename[0…filename.index(’.’)] + ‘.tex’)

This works.  
To turn it into a Postscript file, I need another command

```
   system('dvips ' + filename[0...filename.index('.')])

```

This works also and creates a new Postscript file.  
But now, I’d like to open a Ghostview window to show the output in the  
Postscript file automatically from the same Ruby script that did all  
the  
previous work and I’d like Ghostscript to stay open even after the Ruby  
program finishes.

I’ve tried  
system(‘gsview32 ’ + filename[0…filename.index(’.’)] +  
‘.ps’),

but here nothing happens - no Ghostscript window pops up and nothing  
else happens. So I still need to call Ghostscript by hand.  
How could this problem be solved in Windows XP?  
Is the solution any different under Linux ?

Thank you very much!

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 1, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/system-and-windows-and-an-external-program/100905/2 "2006-08-01T22:11:47Z")

</div>

On Wed, 2 Aug 2006 removed\_email\_address@domain.invalid wrote:

> I’ve tried  
> system(‘gsview32 ’ + filename[0…filename.index(’.’)] + ‘.ps’),  
> ^^^^^  
> ^^^^^  
> rindex

perhaps? eg does your pathname have two extensions?

-a
