Expect: Difference between revisions

7 bytes removed ,  6 years ago
m
m (Protected "Expect" ([Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite) [Delete=Allow only logged in users] (indefinite)))
(m)
Line 3:
<br />
 
= Basics =
 
Installing Expect
=Expect script to ARP Ping=
<pre>#!/usr/bin/ sudo apt-get install expect
 
{{UC}}
 
= Scripts =
 
=;Expect script to ARP Ping=
 
<pre>
#!/usr/bin/expect
set timeout 20
spawn telnet 192.200.200.201
Line 18 ⟶ 28:
send "0\r"
exit
</pre>
 
Cron Entry
### 0 * * * * /home/ibm/Desktop/expect 2>&1 >> /home/ibm/Desktop/script_output.log</pre>
 
=;Expect script to backup Netscaler config=
 
<pre>
#!/usr/bin/expect
## Need to install "Expect" by below command
## sudo apt-get install expect
##
spawn ssh nsroot@10.107.88.78
expect "Password:"
Line 38 ⟶ 48:
send "^C\r"
exit
</pre>
 
 
 
=;TCP three-way handshake by hand using expect=
 
=TCP three-way handshake by hand using expect=
<pre>
# Some usefulUseful constants
set SYN 0x02
set RST 0x04
Line 52 ⟶ 66:
set window 4096
 
# We'll useUse a ghost IP. Make sure $myip is not being used...
set myip 10.10.10.123
set mymac [random mac]
Line 113 ⟶ 127:
}
 
# We're doneDone with the 3-way handshake. If we want to send more stuffpackets
# we need to use correct sequence numbers. Our sequence number is
# $tcp(ack) and the server's is $tcp(seq) + 1.
#