Bash: Getting standard program for file type -


A web radio station has a background shell script to open the .m3u file. So I want to know inside the script, what is the user's program to open such files. At present, they have to set the environment variable $ player, but obviously this is not a good way.

Optional: Is there a command that takes the file name and searches itself for the appropriate program to handle that file? Such as file , for example,

  open-file my_playlist.m3u  

the script should be portable, at least Run on Ubuntu, Debian and Windows / Signin machines.

Cheers,

This should be done differently on each platform In OS X, the "Open" command will do what you want.

This is messed up in Linux, because the desktop environment (gnome or kde) keeps its list of applications to run for each file type

There are two files that you have to do with Ubuntu / Gene that holds this information: ~ / .local / share / applications / defaults.list and ~ / .local / share / applications / mimeinfo.cache <

Hope someone else That's how to do this in Windows and there might be chimes in it.

Edit: Steal from other answers:

Linux:

<

SIGNVIN:

cygstart [filename]

< P> And for completeness, here is a link to a previous question that you are running on which operating system you are running:


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -