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 件のコメント
Joaquin REYES
2020 年 2 月 9 日
Did you ever get a solution?, I am having an error when trying to use the system command in a web app.
Julian Schmid
2020 年 2 月 10 日
回答 (1 件)
J. Alex Lee
2020 年 2 月 10 日
0 投票
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 件のコメント
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.
J. Alex Lee
2020 年 2 月 10 日
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?
Steven Lord
2020 年 2 月 10 日
Use the getenv function.
カテゴリ
ヘルプ センター および File Exchange で MATLAB Web App Server についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!