Automate the response to command prompt in matlab

11 次查看(过去 30 天)
Hi,
I am using system command([status,cmdout] = system(command,'-echo')) in matlab to access my linux kernel command prompt to execute a command. After the execution of the command in matlab, the matlab command prompt ask me to enter the system password which is the user password. In this case I need to manually type the password in the matlab command prompt to take the code execution further. During this time the whole matlab code execution pauses till I finish typing my password on the command prompt and press enter.
I would just like to know, is there a way where I can keep the password text in matlab window and after the command executes, the password text gets automatically typed in the matlab command prompt from the matlab window. I just want the code execution flow to be continuous on one click of the run button. I do not want to manually enter the password on the command prompt.
Thank you

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2021-4-28
There is a more secure way to do this such as using PuTTY PLINK.But if you don't mind storing and exposing your password, you could type in and save your password in a .txt file and run
system('MyCommand < Password.txt')

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by