Opening my files with a ruby program

i was just wondering if i wanted my program to open a file on my pc what
would i put for example if i wanted to use ruby irb to open media player
thanks

Mark K. wrote:

i was just wondering if i wanted my program to open a file on my pc what
would i put for example if i wanted to use ruby irb to open media player
thanks

You’ve to find out what the Media Player’s executable is named and if it
accepts the filename as a command-line argument. That said, I’m assuming
the executable is called “mplayer” and your file “myfile.ogg”.

system(“mplayer”, “myfile.ogg”)

That blocks until the mplayer process exits, so you may want this
instead:

#On *nix
spawn(“mplayer”, “myfile.ogg”)
#On Windows or *nix
IO.popen(“mplayer myfile.ogg”)

How to find out the executables name:
Right-click on your favourite starting icon, choose something like
“Settings”, look what command it runs or what goal it points to and use
that instead of “mplayer” in my example.

And you may think about using punctuation?

Marvin

Besides the ones Marvin mentioned, you also have a couple of other
options.

the example below will open the JPG image using the default program used
to
handle JPG files
system(‘cmd /c start “”
C:\DOCUME~1\churchil\MYDOCU~1\MYDROP~1\images\SABBAT~1.JPG’)

while this example will open it explicitly with mspaint
system(‘cmd /c start “” C:\WINDOWS\system32\mspaint.exe
C:\DOCUME~1\churchil\MYDOCU~1\MYDROP~1\images\SABBAT~1.JPG’)

And actually, I don’t think you need the “cmd /c”

You can just use system(‘start “”
C:\DOCUME~1\churchil\MYDOCU~1\MYDROP~1\images\SABBAT~1.JPG’)