Using system() or ! with deployed executable

I've written a script that allows the user to select multiple folders then sequentially:
1) feed those folders into an external executable (which only accepts one folder at a time) that takes a significant amount of time to run,
2) perform work on the files generated by the external executable once it's done
The script works great on my PC, as does the executable generated by mcc.
My problem is that when I attempt to run this program on other PCs that only have MCR, not full MATLAB, the system calls are not functioning at all. I have ensured that the paths are correct, and verified that the MCR PC can indeed run the command. To verify this, I called the deployed executable from a command line so the output would persist. I included a line that simply writes the argument I'm using for the system() call before making the system call, then running that string directly after the deployed executable finishes.
Unfortunately this is work related and I'm prohibited from posting the actual code, but in my debug process I've tried the following:
c = 'Super\secret\command_line_program arguments';
c
system(c)
dos(c)
eval(['!' c])
I get
ans =
'Super\secret\command_line_program arguments'
ans =
-1
ans =
-1
ans =
-1
I can further verify the super secret command line program is not executing because the files it would generate are not being generated. When I copy the content of variable c and paste it directly to the MCR PC's command line, it executes the program as expected.
Can someone help me figure out what I'm doing wrong?
Bonus question: Any idea why my mcc calls are taking 12+ minutes to run for literally as little as 2 lines of code?
mcc -mv debugTestScript.m
Matlab 2017a, Compiler 6.4
Thanks in advance!

5 件のコメント

Walter Roberson
Walter Roberson 2018 年 5 月 11 日
Try cross-checking with something like
exe = 'Super\secret\command_line_program.exe';
disp( fileattr(exe) )
[status, message] = system( sprintf('attrib "%s"', exe) );
disp(status)
disp(message)
just to be sure that it can find the executable.
Greg
Greg 2018 年 5 月 12 日
編集済み: Greg 2018 年 5 月 12 日
More importantly, I think, just print the message returned from your current system call, rather than the -1 status. I suspect "Super\secret\command_line_program" doesn't exist (at least on the known path) of your target MCR-only system. The message output of system would make that painfully clear.
Current working directory ( pwd ) is not always intuitive when running compiled executables from command lines, not to mention the extra situation of making nested system calls inside that executable.
Jan
Jan 2018 年 5 月 12 日
On one machine such a call to an executable failed unexpectedly, because it tried to write to the users Documents folder. While this works on my machine, the virus scanner on the client machine blocked the access.
So I agree: Use as much error messages as you can get.
J D
J D 2018 年 5 月 14 日
@Walter: I tried that (although I had to replace fileattr() with fileattrib()). MATLAB's fileattrib() output is displayed as expected, but as before status is left with -1 and message is empty. Again, when I call attrib with the full path and filename exactly as it is in the script from the target PC's command line by hand, it shows the correct information.
@Greg: The command line program is confirmed at that location. One thing I didn't make clear in the OP is that I am specifying the full path to the executable to prevent any issues with relative directories since I've had that issue in the past.
Greg
Greg 2018 年 5 月 14 日
So what are the messages returned by the system calls when it is compiled?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeC Shared Library Integration についてさらに検索

質問済み:

J D
2018 年 5 月 11 日

コメント済み:

2018 年 5 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by