Sanjay
Sanjay

Reputation: 3

file content as a command input on linux

For example, I have a file a.txt with the content "123456" which is my root's password. I input the command "su", then it displays "Password: " to prompt me to input my password.

How can I regard the file content (i.e. "123456") as the input of the password?

Thanks for all of you!

Upvotes: 0

Views: 261

Answers (1)

user1092803
user1092803

Reputation: 3297

If the command expects something on the command line, you can use a syntax like

ls -ll `cat file_list.txt`

but if you just want to automate some commands, maybe you can consider to give a look at expect

In your specific case, I suppose the better solution is to go with expect, since su don't seems to expect a password as a command line argument

Upvotes: 1

Related Questions