mirror of
https://github.com/techarkit/shell-scripting-tutorial.git
synced 2025-07-25 01:28:51 +00:00
Create AutomateLoginSSH.sh
Expect command examples
This commit is contained in:
20
AutomateLoginSSH.sh
Normal file
20
AutomateLoginSSH.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/expect -f
|
||||
## Testing expect command
|
||||
|
||||
## echo the test
|
||||
puts "\nGet HostName\n"
|
||||
|
||||
## execute ssh command to connect to remote host
|
||||
spawn ssh 192.168.175.130 "hostname"
|
||||
|
||||
## Look for password string
|
||||
expect "password:"
|
||||
|
||||
## Send the password
|
||||
send "redhat\r"
|
||||
|
||||
puts "\nGet df command output\n"
|
||||
spawn ssh 192.168.175.130 "df -h"
|
||||
expect "password:"
|
||||
send "redhat\r"
|
||||
interact
|
Reference in New Issue
Block a user