Borrar filtros
Borrar filtros

Change working directory on a Linux based server

7 visualizaciones (últimos 30 días)
Nicola Dall'Osto
Nicola Dall'Osto el 22 de Abr. de 2024
Editada: Nicola Dall'Osto el 23 de Abr. de 2024
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 comentarios
Mario Malic
Mario Malic el 23 de Abr. de 2024
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.
Nicola Dall'Osto
Nicola Dall'Osto el 23 de Abr. de 2024
Editada: Nicola Dall'Osto el 23 de Abr. de 2024
In this step I'm not trying to create a folder. The folder needed for the MedicalLabelingSession already exists. I was only wandering why in Windows there is a certain behaviour and in Linux it is different. As I've explained before, in Windows, if I use cd to point to the folder where I want to store the MedicalLabelingSession, in this popup window, that opens when Medical Image Labeber starts, the folder is already the one that i've set with cd.
On the contrary, on linux, the folder that appears in the box in this popup window is not the folder set with cd, but it is the MATLAB installation folder. If I want to save the MedicalLabelingSession in the folder I want, I have to browse the folder and select it manually.

Iniciar sesión para comentar.

Respuesta aceptada

Nicola Dall'Osto
Nicola Dall'Osto el 23 de Abr. de 2024
Editada: Nicola Dall'Osto el 23 de Abr. de 2024
I resolved the issue by using userpath instead of cd.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by