Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exec cmd.exe /c start equivalent for Linux

431 views
Skip to first unread message

keithv

unread,
May 27, 2009, 10:16:06 PM5/27/09
to
I'm porting a Windows tcl program to Linux (and later Mac) and
was wondering if there is some way to automatically
run or view a given file. On Windows I'd do
exec cmd.exe /c start $filename

The information is out there somewhere because the graphical
shell Nautilus allows you to click on an arbitrary file to run it
or view it.

Also, I seem to recall the Mac has the "open" command to
let you do this.

Thanks,
Keith

Robert Heller

unread,
May 27, 2009, 11:46:46 PM5/27/09
to

It is embedded in Nautilus or part of Gnome's Desktop binding (or
something like that). Neither Nautilus, Gnome, or KDE, etc. are
invoking some sort of Linux system service or anything. Outside of the
coded bindings in the Desktop manager or Window manager, there isn't
anything like either the MS-Windows 'cmd.exe /c start' or the MacOSX
'open' command in Linux (or any other UNIX or Posix system. Things like
executable files, whether they are binary machine code (eg ELF) or
things like shell scripts are handled by what the first bytes/line(s)
contain ('magic' codes).

I suspect that Nautilus runs the file command and uses the result to
index into a lookup table to see what to do. Probably using file in
MIME mode (-i, --mime), in which case it might use the same magic as is
typically used by webrowsers to match MIME types with helper
applications.

>
> Thanks,
> Keith
>

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
hel...@deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/

Christian Gollwitzer

unread,
May 28, 2009, 11:29:25 AM5/28/09
to
Robert Heller schrieb:

> At Wed, 27 May 2009 19:16:06 -0700 (PDT) keithv <kve...@gmail.com> wrote:
>
>> I'm porting a Windows tcl program to Linux (and later Mac) and
>> was wondering if there is some way to automatically
>> run or view a given file. On Windows I'd do
>> exec cmd.exe /c start $filename
>>
>> The information is out there somewhere because the graphical
>> shell Nautilus allows you to click on an arbitrary file to run it
>> or view it.
>>
>> Also, I seem to recall the Mac has the "open" command to
>> let you do this.
>
> It is embedded in Nautilus or part of Gnome's Desktop binding (or
> something like that). Neither Nautilus, Gnome, or KDE, etc. are
> invoking some sort of Linux system service or anything. Outside of the
> coded bindings in the Desktop manager or Window manager, there isn't
> anything like either the MS-Windows 'cmd.exe /c start' or the MacOSX
> 'open' command in Linux (or any other UNIX or Posix system. Things like
> executable files, whether they are binary machine code (eg ELF) or
> things like shell scripts are handled by what the first bytes/line(s)
> contain ('magic' codes).

In the dark ages of UNIX desktops, programs usually used the "mailcap"
file to find the correct invocation for a given MIME type. Today the
associations are stored somewhere in the KDE or Gnome settings. There is
also the freedesktop standard which cares about these specifications;
read e.g.

http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec

maybe in KDE it's possible to simply invoke konqueror on any file. You
probably need some heuristics to find out, whether KDE or Gnome is used;
otherwise stick to mailcap.


Christian

Managed Democracy

unread,
Jun 9, 2009, 2:30:33 PM6/9/09
to
Hi,
if you're on a Gnome Desktop, have you tried...

exec gnome-open $filename

?

Robert Heller

unread,
Jun 9, 2009, 3:12:00 PM6/9/09
to

This seems to actually work, even if the Gnome Desktop is not running...

>
> ?

0 new messages