Calling a .exe in Matlab that requires a passphrase

Hi,
I know how to call an executable from Matlab:
system('name.exe');
However, I have an executable that, once called, asks for a passphrase or password. When I run it in Matlab using the command above, Matlab just freezes.
Does anyone know how to call an executable that requires additional input after being called (i.e. it doesn't execute fully with just one call)? Is this even possible?
Any help would be greatly appreciated!

 採用された回答

Jason Ross
Jason Ross 2011 年 6 月 9 日

0 投票

You can try using some of the redirect functionality to respond to the prompt. It may or may not work, though.
You might want to try "echo passphrase | name.exe" to start with. I'd recommend experimenting in the DOS window alone first and then moving into MATLAB, especially if there are special characters in your passphrase.
If you have access to the source code of the executable, the best thing to do would be to add in support for a command line option to allow you to enter the passphrase, e.g.
name.exe -passphrase <passphrase>
You might also find that you may be better able to do this by making a batch file as a wrapper for your executable. I've done that when things got more complex and the system() call started to look really ugly.
Or, even better, if you can make a API call into a .dll somehow, it's a lot cleaner and you can not have to deal with parsing output so much, which is nicer to deal with.

1 件のコメント

Walter Roberson
Walter Roberson 2011 年 6 月 9 日
As a security note: on multi-user machines, putting the pass phrase on the command line is recommended against, as the other users can examine your command line.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by