Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a4c4cd8

Browse files
Create AutomateLoginSSH.sh
Expect command examples
1 parent b4552a9 commit a4c4cd8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎AutomateLoginSSH.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/expect -f
2+
## Testing expect command
3+
4+
## echo the test
5+
puts "\nGet HostName\n"
6+
7+
## execute ssh command to connect to remote host
8+
spawn ssh 192.168.175.130 "hostname"
9+
10+
## Look for password string
11+
expect "password:"
12+
13+
## Send the password
14+
send "redhat\r"
15+
16+
puts "\nGet df command output\n"
17+
spawn ssh 192.168.175.130 "df -h"
18+
expect "password:"
19+
send "redhat\r"
20+
interact

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /