Best way to publish an app that depends on an executable

I’m interested in creating an app that would use a command line executable (it’s available for Linux, Windows and OSX, so it’s reasonably portable). What is the recommended way to do this? Some ideas that come to mind are:

  1. Use exec or shell_exec but I’m not sure if most NextCloud installations have those enabled. Do they?
  2. Call the executable remotely via ssh but that would make installation more complicated and make it harder for the executable to access files stored in NextCloud.

Are there other/better ways to do it?

Are there any existing apps that use command line executables I could use as a model? I can certainly find a way to make it work but the goal of this question is to learn how to do it so installation is easiest on admins. Ideally they could just install the NC app and not have to do any external setup. If they have to do external setup, the easier the better.

Perhaps no better way …
But your “app” can put the command e.g. in a “text-file” and CRON execute it.
Then you do not have the problems with php and exec.
But there could be some security risks :wink:

I think you can program it outside nextcloud with a 10 lines php script.

I would have to call the exe on demand when the page loads, not periodically. I use hledger for personal finance/accounting and I keep the journal/ledger files in NextCloud. I’d like to make a NextCloud app that provides a web interface to this.

I decided to use shell_exec. The app just won’t work if it’s not enabled in the server.

1 Like

Look at kitinerary-bin/BinaryAdapter.php at master · ChristophWurst/kitinerary-bin · GitHub

shell_exec is a bit … scary, especially if you pass user provided data into it. Be careful.

1 Like

Thanks! I agree, I would like to avoid it if possible.