There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given.
Specifics: There is a command-line command that displays the table of contents of a netCDF file:
$ ncdump -h yourfile.nc
This command shows the table of contents of the netCDF file to the current terminal.
How can I see the same output when I double click on the file on Finder?
Edit: The following is a description of a failed approach.
I have made some progress toward a solution.
Following this thread
I've been able to create a macOS "app" which is actually a shell script:
#!/bin/sh /usr/local/bin/ncdump -h "$@"
So far, I've been able to verify that I can invoke this "app" from Finder and that the above shell script is actually run. But, I found that the shell script doesn't get the filename as a command line argument. (You can see what's going on by modifying the line to
/usr/local/bin/ncdump -h "$@" > $HOME/tmp/logfile.txt 2>&1)
So, I have two specific questions
How can a shell script (as app) get the filename when invoked from Finder?
To which GUI app should it send its stdout and how?