Expect script for automating system v message queue and unix domain socket c program
C program for System V Message Queue vs Unix Domain socket, 50000 messages 'send' timestamp capture
#!/usr/bin/expect -f
# set expect timeout to 80 secs
set timeout 80
# Max no. of iterations for each case 10
set MAX_ITERATION 10
#################################################################################################################
# PROCEDURES / FUNCTIONS
#################################################################################################################
#########################################################
# Terminate the Session
#########################################################
proc terminate_session {} {
# Send special ^] to telnet so we can tell telnet to quit.
expect "# " { send “35\r” }
expect "telnet>" { send "q\r\r" }
expect eof
# You should also, either call "wait" (block) for process to exit or "wait -nowait"
# (don't block waiting) for process exit.
# Without "wait", expect may sever the connection to the process prematurely, this
# can cause the creation zombies in some rare cases. If the application did not get our
# signal earlier (the EOF from close), or if the process doesn't interpret EOF as an exit
# status then it may also continue running and your script would be none the wiser.
# With wait, we ensure we don't forget about the process until it cleans up and exits.
# < in short, wait is to clean up zombies >
wait
sleep 1
}
#########################################################
# connect to RG and restart the Session
#########################################################
proc restart_session {} {
# spawn telnet to RG session
spawn telnet 192.168.1.254
# expect login and password. this is must
expect "*login:*" { send "admin\r"}
expect "*Password:*" {send "admin123\r"
}
expect "NOS/1234567888>" {send "magic\r"}
expect "NOS/1234567888/DEBUG/MAGIC" {send "!\r"}
expect "# " {
send "pwd\r"
send "cd /bin\r"
send "killall udp_server\r"
send "killall mq_server\r"
send "./udp_server &\r"
sleep 1
send "./mq_server &\r"
sleep 1
send "\r\r\r"
}
}
#########################################################
# after every iteration terminate the connection
# to RG and restart the session
#########################################################
proc terminate_and_restart {} {
terminate_session
restart_session
}
#################################################################################################################
# MAIN SCRIPT STARTS HERE
#################################################################################################################
# spawn telnet to RG session
spawn telnet 192.168.1.254
# expect login and password. this is must
expect "*login:*" { send "admin\r"}
expect "*Password:*" {send "admin123\r"
}
expect "NOS/1234567888>" {send "magic\r"}
expect "NOS/1234567888/DEBUG/MAGIC" {send "!\r"}
expect "# " {
send "pwd\r"
send "cd /bin\r"
send "killall udp_server\r"
send "killall mq_server\r"
send "./udp_server &\r"
sleep 1
send "./mq_server &\r"
sleep 1
send "\r\r\r"
}
################################################################################################
# Message queue (client socket mode: Blocking)
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
################################################################################################
# Unix domain sockets (client socket mode: Blocking)
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" {send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf bl no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
################################################################################################
# Message queue (client socket mode: Non-Blocking with no sleep between each send )
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
################################################################################################
# Unix domain sockets (client socket mode: Non-Blocking with no sleep between each send)
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" {send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb no\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
################################################################################################
# Message queue (client socket mode: Non-Blocking with sleep between each send )
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./mq_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
################################################################################################
# Unix domain sockets (client socket mode: Non-Blocking with no sleep between each send)
################################################################################################
##################################
# 100 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 100 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" {send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 1500 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 1500 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
terminate_and_restart
sleep 2
##################################
# 2000 bytes
##################################
expect "# " {
for {set x 1} {$x <= $MAX_ITERATION} {incr x} {
send "echo 2000 bytes Iteration $x\r"
send "./udp_client sjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldfsjkhsdfsdfsfsldakfhsldkfjhsadlfhsldafjkhsladfhsldf nb yes\r"
expect "*Client: bye*" { send "\r\r"}
send "pwd\r"
sleep 2
}
send "\r\r\r"
}
##################### END OF SCRIPT ####################################
interact
Expect script to print the content of files
#!/usr/bin/expect -f# set expect timeout to 80 secs
set timeout 80
# Max no. of iterations for each case 10
set MAX_ITERATION 10
#################################################################################################################
# PROCEDURES / FUNCTIONS
#################################################################################################################
#########################################################
# Terminate the Session
#########################################################
proc terminate_session {} {
# Send special ^] to telnet so we can tell telnet to quit.
expect "# " { send “35\r” }
expect "telnet>" { send "q\r\r" }
expect eof
# You should also, either call "wait" (block) for process to exit or "wait -nowait"
# (don't block waiting) for process exit.
# Without "wait", expect may sever the connection to the process prematurely, this
# can cause the creation zombies in some rare cases. If the application did not get our
# signal earlier (the EOF from close), or if the process doesn't interpret EOF as an exit
# status then it may also continue running and your script would be none the wiser.
# With wait, we ensure we don't forget about the process until it cleans up and exits.
# < in short, wait is to clean up zombies >
wait
sleep 1
}
#########################################################
# connect to RG and restart the Session
#########################################################
proc restart_session {} {
# spawn telnet to RG session
spawn telnet 192.168.1.254
# expect login and password. this is must
expect "*login:*" { send "admin\r"}
expect "*Password:*" {send "admin123\r"
}
expect "NOS/1234567888>" {send "magic\r"}
expect "NOS/1234567888/DEBUG/MAGIC" {send "!\r"}
expect "# " {
send "pwd\r"
send "cd /bin\r"
send "killall udp_server\r"
send "killall mq_server\r"
send "./udp_server &\r"
sleep 1
send "./mq_server &\r"
sleep 1
send "\r\r\r"
}
}
#########################################################
# after every iteration terminate the connection
# to RG and restart the session
#########################################################
proc terminate_and_restart {} {
terminate_session
restart_session
}
#################################################################################################################
# MAIN SCRIPT STARTS HERE
#################################################################################################################
# spawn telnet to RG session
spawn telnet 192.168.1.254
# expect login and password. this is must
expect "*login:*" { send "admin\r"}
expect "*Password:*" {send "admin123\r"
}
expect "NOS/1234567888>" {send "magic\r"}
expect "NOS/1234567888/DEBUG/MAGIC" {send "!\r"}
expect "# " {
send "pwd\r"
send "cd /data/system\r"
send "\r\r"
send "cat mq_client_bl_no_100\r"
send "\r\r"
send "cat mq_client_bl_no_500\r"
send "\r\r"
send "cat mq_client_bl_no_1000\r"
send "\r\r"
send "cat mq_client_bl_no_1500\r"
send "\r\r"
send "cat mq_client_bl_no_2000\r"
send "\r\r"
send "cat udp_client_bl_no_100\r"
send "\r\r"
send "cat udp_client_bl_no_500\r"
send "\r\r"
send "cat udp_client_bl_no_1000\r"
send "\r\r"
send "cat udp_client_bl_no_1500\r"
send "\r\r"
send "cat udp_client_bl_no_2000\r"
send "\r\r"
send "cat mq_client_nb_no_100\r"
send "\r\r"
send "cat mq_client_nb_no_500\r"
send "\r\r"
send "cat mq_client_nb_no_1000\r"
send "\r\r"
send "cat mq_client_nb_no_1500\r"
send "\r\r"
send "cat mq_client_nb_no_2000\r"
send "\r\r"
send "cat udp_client_nb_no_100\r"
send "\r\r"
send "cat udp_client_nb_no_500\r"
send "\r\r"
send "cat udp_client_nb_no_1000\r"
send "\r\r"
send "cat udp_client_nb_no_1500\r"
send "\r\r"
send "cat udp_client_nb_no_2000\r"
send "\r\r"
send "cat mq_client_nb_yes_100\r"
send "\r\r"
send "cat mq_client_nb_yes_500\r"
send "\r\r"
send "cat mq_client_nb_yes_1000\r"
send "\r\r"
send "cat mq_client_nb_yes_1500\r"
send "\r\r"
send "cat mq_client_nb_yes_2000\r"
send "\r\r"
send "cat udp_client_nb_yes_100\r"
send "\r\r"
send "cat udp_client_nb_yes_500\r"
send "\r\r"
send "cat udp_client_nb_yes_1000\r"
send "\r\r"
send "cat udp_client_nb_yes_1500\r"
send "\r\r"
send "cat udp_client_nb_yes_2000\r"
}
send "\r\r"
interact