Start file with associated prog (windows only?)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Start file with associated prog (windows only?)

Bernhard Lehnert
Hello list,

I believe I am looking for a haskell equivalent to a python library
function called os.startfile(...) which starts any given file with its
associated program.

http://docs.python.org/library/os.html#os.startfile says:
"...this acts like double-clicking the file in Windows Explorer, or
giving the file name as an argument to the start command from the
interactive command shell: the file is opened with whatever application
(if any) its extension is associated.
[...]
startfile() returns as soon as the associated application is launched."

So to show a readme you just write:
import os
os.startfile("README.rtf")

to show your programs documentation you just write
os.startfile("documentation.pdf")
and windows will decide which program to use to open a PDF.

The must urgent thing I actually want to do is open an Internet Browser
with my sponsors URL.

Any good ideas?

Thanks in advance,
Bernhard

Reply | Threaded
Open this post in threaded view
|

Start file with associated prog (windows only?)

Magnus Therning
On Tue, Aug 18, 2009 at 3:12 PM, Bernhard Lehnert<[hidden email]> wrote:

> Hello list,
>
> I believe I am looking for a haskell equivalent to a python library
> function called os.startfile(...) which starts any given file with its
> associated program.
>
> http://docs.python.org/library/os.html#os.startfile says:
> "...this acts like double-clicking the file in Windows Explorer, or
> giving the file name as an argument to the start command from the
> interactive command shell: the file is opened with whatever application
> (if any) its extension is associated.
> [...]
> startfile() returns as soon as the associated application is launched."
>
> So to show a readme you just write:
> import os
> os.startfile("README.rtf")
>
> to show your programs documentation you just write
> os.startfile("documentation.pdf")
> and windows will decide which program to use to open a PDF.
>
> The must urgent thing I actually want to do is open an Internet Browser
> with my sponsors URL.
>
> Any good ideas?

Windows has a command "start" which you can use e.g. via System.Process.proc.

/M

--
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus?therning?org          Jabber: magnus?therning?org
http://therning.org/magnus         identi.ca|twitter: magthe
Reply | Threaded
Open this post in threaded view
|

Start file with associated prog (windows only?)

Bernhard Lehnert
Am Dienstag, den 18.08.2009, 16:07 +0100 schrieb Magnus Therning:

> Windows has a command "start" which you can use e.g. via System.Process.proc.

Thank you, Magnus - this is exactly what I was looking for. (By the way,
someone should implement something like this for GNOME and KDE,
too ;-) )

Reply | Threaded
Open this post in threaded view
|

Start file with associated prog (windows only?)

Isaac Dupree-3
Bernhard Lehnert wrote:
> Am Dienstag, den 18.08.2009, 16:07 +0100 schrieb Magnus Therning:
>
>> Windows has a command "start" which you can use e.g. via System.Process.proc.
>
> Thank you, Magnus - this is exactly what I was looking for. (By the way,
> someone should implement something like this for GNOME and KDE,
> too ;-) )

Well, there is `xdg-open` command, which is not as well-known as it
should be.  OS X calls the equivalent command "open".  I'm not sure what
xdg-open does with executable files (Does it really make sense, in a
unixy context, to just execute them?)

-Isaac
Reply | Threaded
Open this post in threaded view
|

Start file with associated prog (windows only?)

Magnus Therning
Isaac Dupree wrote:

> Bernhard Lehnert wrote:
>> Am Dienstag, den 18.08.2009, 16:07 +0100 schrieb Magnus Therning:
>>
>>> Windows has a command "start" which you can use e.g. via
>>> System.Process.proc.
>>
>> Thank you, Magnus - this is exactly what I was looking for. (By the way,
>> someone should implement something like this for GNOME and KDE,
>> too ;-) )
>
> Well, there is `xdg-open` command, which is not as well-known as it
> should be.  OS X calls the equivalent command "open".  I'm not sure what
> xdg-open does with executable files (Does it really make sense, in a
> unixy context, to just execute them?)

In Gnome there's also 'gnome-open'.

% xdg-open /usr/bin/gedit
Error showing url: No application is registered as handling this file

Same behaviour for gnome-open.

/M

--
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus?therning?org          Jabber: magnus?therning?org
http://therning.org/magnus         identi.ca|twitter: magthe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20090818/dc32ce3c/signature.bin