I need to create a shell script which will login to a unix system with user root. I also need to supply the password for root through script only instead of entering it manually.
After i am logged in to the system i need to excute all the necessary commands.
so far i have done this..but it asks for password to be entered.
ssh -l root HOSTNAME/IP
echo "WELCOME to ROOT"
exit
This is just creating object for expect module, in which you have to give list of regular expression in which format it interacts with you to get the input..
Then it spawns and executes command given (ssh command ), and it matches each interaction message with the given regular expression, and sets the variable exp_match_number with corresponding value.
so if exp_match_number has the value 1, then interaction message matches with the
''want to continue connecting'' then you can give your input by writing into the expect object like
print $command "yes\r".
ssh shell means secure shell. A password in a plain text script isn't, really. A more secure route is generating keys and using an authorized_keys file containing public keys of trusted users on every system (man ssh).