Automate the response to command prompt in matlab

11 views (last 30 days)
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

Answers (1)

Fangjun Jiang
Fangjun Jiang on 28 Apr 2021
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')

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!