How to use Cygwin from MATLAB to execute commands in other directories?

I am using MATLAB and I want to run some C ++ programs using CYGWIN on Windows. They are located in the local CYGWIN directory; C:\cygwin\home\Alex\Community_BGLL_CPP . I can get CYGWIN to execute commands in the local MATLAB directory:

 >> ls . README genlouvainmex.m .. genlouvain.m private >> system('C:\cygwin\bin\ls') README genlouvain.m genlouvainmex.m private ans = 0 

But I can not execute the command, as in the local directory CYGWIN. This means that I can run a C ++ program to create a text file that I can use to process MATLAB. Therefore, in fact, I just need to call it. Here I am experimenting with ls :

 >> system('C:\cygwin\bin\ C:\cygwin\home\Alex\ls') 'C:\cygwin\bin\' is not recognized as an internal or external command, operable program or batch file. ans = 1 

I also tried >> system('C:\cygwin\bin\ls C:\cygwin\home\Alex\') , but it also does not work.

one parameter is to change the directory ( cd ) in CYGWIN, and then run the command:

 >> pwd ans = c:\cygwin\home\Alex\Community_BGLL_CPP\sample_networks >> system('C:\cygwin\bin\ls') arxiv.bin arxiv.txt example.bin example.txt graph.tree graph_list.bin graph_list.txt karate.bin karate.tree karate.txt ans = 0 
+4
source share
1 answer

I do not have cygwin, so I can not verify this for sure. But I think you just need "cd" as part of your system command. For instance:.

 >> system('"C:\Program Files (x86)\Git\bin\bash" -c "cd C:/Python27; C:/Program\ Files\ \(x86\)/Git/bin/ls"') 

creates a list of my python folder because ls is running in that folder.

So you want something like:

 >> system('"C:\cygwin\bin\bash" -c "cd C:/cygwin/home/Alex/Community_BGLL_CPP/sample_networks; C:/some_path/convert"') 
0
source

All Articles