Advice on creating app for Windows and Linux

I use a third party app that functions from identical command line commands on Windows and Linux eg appname -someparameters

I want to create an application that will work on Windows or Linux (web host or Amazon aws) to send the relevant commands via command line.

A web app would be good, but not sure how easy it would be to set up security permissions to allow a browser to generate command line instructions.

So I assume I need some application that will work on both OS, or can be converted with minimal work.

The application needs to connect via Google Sheets API (read only) to receive parameters.

I do not want to set up Linux or a bash script on the Windows machine.

I would appreciate suggestions for a suitable language or framework to build my application.

I have a preference for Php, but assume this is not the most straightforward for Windows.

Thanks ColinK

Based on your statements, Electron might be worth checking out. It will work on all platforms, and you could build it just like a web app with HTML and CSS and call the Google API just like in the browser with node-fetch. PHP is a server-side scripting language, so probably won’t work well in this use scenario.

Running the commands in Electron doesn’t seem to be too big of a problem. You have access to all NodeJS libraries, and you could also try shelljs

This is assuming you want to build a traditional desktop application with a user interface.

1 Like

Thanks for your suggestion Isaac

Primary use is for a Windows desktop app.

Would the same code / app or a version of it work on a Linux web host, accessed by any browser and run command line commands on that Linux server.

ColinK

So for this, you are going to want to create an API microservice you can run on your web host. I suggest using Node if you want to create a desktop app (that way the front and back end would be very similar), but if you know how to create a REST api in PHP, then go for it.

So assuming you create a Node.js microservice (or assuming you understand how in your preferred language), you will need to create the endpoints for the front end to call the api. When the api is called, you can run a command in Node with the child_process library: javascript - Execute a command line binary with Node.js - Stack Overflow

You will then build the front end with HTML, CSS, and JavaScript. You can use electron for the Mac/Windows/Linux desktop apps and I’m guessing you know how to make a basic SPA. You will then just have each frontend call the appropriate link for the api, and your microservice will execute the command.

So, something like this:

Be careful that you don’t allow users to type their own commands as they could easily inject a malicious command into your server. For example, say you just wanted to have them call the ping command for a url (obviously contrived example):

ping google.com

assuming google.com is what you received from them. They could easily just append another command on there to do whatever they wanted, i.e.

ping google.com&&rm -rf some_folder

So, be careful, obviously. If this doesn’t make sense, I suggest making your way through some of the freeCodeCamp curriculum. The front-end section will teach you all the HTML, CSS, and JavaScript you need to know to create the browser and desktop apps. You can do some Node tutorials and you should be ready to create your microservice by the URL shortener in the backend. Good luck!

1 Like

Thanks again for your suggestions. It will be some time before I get to this, If I need more advice I will return.

ColinK