Change working directory on a Linux based server
5 ビュー (過去 30 日間)
古いコメントを表示
Nicola Dall'Osto
2024 年 4 月 22 日
編集済み: Nicola Dall'Osto
2024 年 4 月 23 日
I wrote a script that opens Medical Image Labeler and loads some images in it to be annotated by the user. When the command medicalImageLabeler(gTruth) is executed, the app opens and a popup window (see figure) asks the user to select the path of the new session folder and to enter the name of the session folder. I want the predefined path of the session folder to be the same of the current working directory.
For example: if the current working directory is C:\Users\Myname\Documents, the predefined folder for the new Medical Image Labeler's session has to be C:\Users\Myname\Documents.
On my Windows PC I was able to obtain this behavior by setting the working directory with cd, pointing to the desired path (e.g. cd(userFolder) where userFolder = "C:\Users\Myname\Documents").
The solution above doesn't seem to work in the PCs connected to my department server, which run Linux. In this case the predefined folder for savings in the Medical Image Labeler app is always the MATLAB folder (e.g. C:\Users\Myname\Documents\MATLAB or similar in the linux environment, I don't rememeber exactly the folder path) even if run the code in a different folder and even if I change the working directory with cd before opening Medical Image Labeler.
Could it be a problem due to the different operating system? Is there a way to fix it?
5 件のコメント
Mario Malic
2024 年 4 月 23 日
Alright, took me a while to figure out what are you trying to do.
1. Check write permissions
So, first thing you should check is the write permissions on the Linux server. If app fails to create a folder because it is not permitted to do, it might offer a folder that you have permission to write to (I am not well-versed with Linux, so not sure if this is what is happening)
2. Why would you change the cd, I don't think this is recommended practice (unless you use private functions). What about adding that folder and subfolders to the path? It will add tiny bit of complexity when you open/save files, but it's worth it.
3. Can you add some code to notify you about the r/w permissions to the folder? Such as, when you call mkdir, check if the folder path isfolder, etc.
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!