My specific problem
My goal is to provide a command-line utility for converting PowerPoint files to PDFs. I have tried solutions that use unoconv, but they don't do the conversion properly. I found a nice workflow which I saved as export_pdf.workflow
. I can run this from the terminal on a file:
/usr/bin/automator -i <some_pptx_file> export_pdf.workflow
which does what I want.
I want to make this into a shell script, but the problem is knowing where to put the workflow. I have included the usage string (so not really a MWE) in order to help express intent.
#!/usr/bin/env bash
function usage()
{
cat <<HEREDOC
Usage: $progname [--delete] PPTX_FILENAME
Converts PPTX_FILENAME into a PDF by launching PowerPoint.
PDF is produced in same directory as PPTX_FILENAME.
optional arguments:
-h, --help show this help and exit
HEREDOC
}
while true; do
case "$1" in
-h | --help ) usage; exit; ;;
-- ) # end argument parsing
shift; break;;
* ) break;;
esac
done
# This is the line I have a question about
/usr/bin/automator -i $1 export_pdf.workflow
This works fine, provided I run it from the directory that contains export_pdf.workflow
. Ideally I would like to distribute this to live in one of the binary files, but I don't think I should move a non-executable file like export_pdf.workflow
into the bin
directory as well.
Solutions that won't work in this case (or at least I am looking for better ones!)
- Supply absolute path: this would work on my machine, but not if I am trying to distribute to others
- Put a shebang on
export_pdf.workflow
and make it executable: In true Apple fashion, this is actually a directory and not just a single file that gets passed to Automator.
The general problem
Outside of my specific use case, the problem I am trying to solve is that I have a file that takes many arguments, and I have a use case where I want to supply some files as arguments by default (e.g. I have a config file that I always want to specify).
Where is the "correct" or "accepted" place to put some_local_file (local to the script, not where the file gets executed) so that I can put the following script in /usr/local/bin/
or add the containing directory to the path:
#!/usr/bin/env bash
some_program -c some_local_file $1