Web app system command

Hi,
I was wondering whether it is possible to use the system command to execute an external program (running on Windows) and wait for a response in a deployed web app on a Matlab web server?
Also, an other question just came to my mind: what's the best practice to store permanent data and access them in a standalone executable of a Matlab program. Should I create a folder in C\\:Programs or something?

2 Comments

Did you ever get a solution?, I am having an error when trying to use the system command in a web app.
Unfortunatly, I didn't get any response and I decided not to use a web app before I could test the system command within such an app.
But still, would be interesting to know.

Sign in to comment.

Answers (1)

J. Alex Lee
J. Alex Lee on 10 Feb 2020

0 votes

To the question:
  • Also, an other question just came to my mind: what's the best practice to store permanent data and access them in a standalone executable of a Matlab program. Should I create a folder in C\\:Programs or something?
Based on the context of your question, maybe worth pointing out that web-deployed and stand-alone-deployed apps will have to deal with paths differently as far as my experience goes.
Not sure about best practices (I would like to know too!), but web apps are run by a guest user on the server (something like MWWebAppClient20XXy), so you just need to make sure whatever path you point to is read-able and/or writeable if you need; so I put a data folder inside its My Documents folder owned by the guest client.

3 Comments

Guillaume
Guillaume on 10 Feb 2020
Edited: Guillaume on 10 Feb 2020
With regards to where to store program data, on Windows, if it's not user specific (e.g global configuration files), best practice is to store it in %ProgramData%\YourProgramName (%ProgramData% is an environment variable, usually pointing to C:\ProgramData). If it's user specific (e.g user preferences), then it should go in %APPDATA%\YourProgramName or %LOCALAPPDATA%\YourProgramName. Again, these are environment variable typically pointing to C:\Users\username\AppData\Roaming and C:\Users\username\AppData\Local respectively).
It is good practice to use environment variables rather than hardcoding paths. Some people may not use the defaults or may not even have a C:\ drive.
Similarly, the path to MyDocuments should be obtained from %USERPROFILE%\My Documents
edit: since it's been asked here are the matlab calls:
getenv('programdata') %directory for program specific data
getenv('appdata') %directory for user specific data (roaming)
getenv('localappdata') %directory for user specific data (local)
getenv('userprofile') %current user profile folder
As to the question of using system, I don't know the specifics of matlab's web apps (never looked into it) but typically any process that can be remotely accessed (e.g web servers) run with very limited privileges so even if system can run it may not have the same effects at all as when it's run under a standard account. And if it does work, you then have to make sure that it doesn't open vulnerabilities in your server. For example if the users can somehow change the path the system call points to, or actually replace the program system invokes, then they can do a lot of damage.
This might be a dumb question but how do you access env variables from matlab? I.e. how would I write a code to compute the user's path?
Use the getenv function.

Sign in to comment.

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Products

Release

R14SP1

Asked:

on 6 Jun 2019

Edited:

on 10 Feb 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!