Control Cygwin through Matlab script
4 ビュー (過去 30 日間)
古いコメントを表示
Paschalis Garouniatis
2016 年 5 月 12 日
コメント済み: Paschalis Garouniatis
2016 年 5 月 22 日
Hello, I would consider myself as a rookie matlab user. I have installed Cygwin64 on my computer and use it to process .env files. Instead of processing one by one each .env file I want to create a matlab script which will guide Cygwin64 to the specified directory and process each .env file. How can I create this script? Thanks in advance!
2 件のコメント
Walter Roberson
2016 年 5 月 12 日
This confuses me a bit, as cygwin64 provides a shell programming language; you would need a script written in the shell language. Also, env files are associated with environment variables, and it is not common to need to process multiple environment variable files?
採用された回答
Walter Roberson
2016 年 5 月 12 日
The easiest way to handle this is at the shell level, rather than at the MATLAB level.
Create a file that has pairs of items on each line. The first thing on the line should be the directory name, using forward slashes instead of backslashes. If there are any spaces in the directory name, proceed them with spaces. The second thing on the line should be the file name, converted the same way. For illustration I will call this file InputSpecs . For example,
C:/Users/Pas/Documents\ And\ Files/Project1 dataset\ 5a.env
C:/Users/Pas/Documents\ And\ Files/Project7 20150830_second.env
Then prepare a second file, that looks like
while read dirname filename; do cd "$dirname"; COMMANDHERE < "$filename"; done
where COMMANDHERE should be replaced by the name of the executable. If there is some other way to indicate that the file is input, then use that instead of the "<". For illustration I will call this file CommandScript. For example,
while read dirname filename; do cd "$dirname"; afnis -infile "$filename"; done
Then, to run all of those, you can
system("cygwin CommandScript < InputSpecs")
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!