Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

How to run an expect script in parallel rather than sequentially?

$
0
0
#!/bin/expect --set vm_num [lindex $argv 0]puts "``````````````````````````````````````````````````````````````"puts "``````````````````````````````````````````````````````````````"puts "Registering Stations on VM"puts "Tarts to be Registered: $vm_num"puts "``````````````````````````````````````````````````````````````"puts "``````````````````````````````````````````````````````````````"for { set index 0 } { $index < [llength $vm_num] } { incr index } {puts "Registering Tart Num: [lindex $vm_num $index]"switch -- [lindex $vm_num $index]\1 {        spawn telnet 10.171.0.10 6187        set timeout -1        expect {                puts "``````````````````````````````````````````````````````````````""*traffic*" { puts "Registering Group1, Group2"                send "traffic map rate reg_group1 30000\r"                send "traffic map rate reg_group2 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group3, Group4"                send "traffic map rate reg_group3 30000\r"                send "traffic map rate reg_group4 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group5, Group6"                send "traffic map rate reg_group5 30000\r"                send "traffic map rate reg_group6 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group7, Group8"                send "traffic map rate reg_group7 30000\r"                send "traffic map rate reg_group8 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                }                puts "wait 3 seconds"                sleep 3                send -- "^]"                expect -exact "^\]\rtelnet> "                send -- "close\r"                expect eof                wait        }} 2 {        spawn telnet 10.171.0.11 6187        set timeout -1        expect {"*traffic*" {                puts "``````````````````````````````````````````````````````````````"                puts "Registering Group1, Group2"                send "traffic map rate reg_group1 30000\r"                send "traffic map rate reg_group2 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group3, Group4"                send "traffic map rate reg_group3 30000\r"                send "traffic map rate reg_group4 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group5, Group6"                send "traffic map rate reg_group5 30000\r"                send "traffic map rate reg_group6 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                puts "Registering Group7, Group8"                send "traffic map rate reg_group7 30000\r"                send "traffic map rate reg_group8 30000\r"                puts "wait 100 seconds .."                send "traffic go\r"                sleep 100                }                puts "wait 3 seconds"                sleep 3                send -- "^]"                expect -exact "^\]\rtelnet> "                send -- "close\r"                expect eof                wait        }} 3 {        spawn telnet 10.171.0.12 6187        set timeout -1        expect {"*traffic*" {                puts "``````````````````````````````````````````````````````````````"                puts "Registering Group1, Group2"                send "traffic map rate reg_group1 50000\r"                puts "wait 220 seconds .."                send "traffic go\r"                sleep 220                puts "Registering Group2"                send "traffic map rate reg_group2 50000\r"                puts "wait 220 seconds .."                send "traffic go\r"                sleep 220                }                puts "wait 3 seconds"                sleep 3                send -- "^]"                expect -exact "^\]\rtelnet> "                send -- "close\r"                expect eof                wait        }}default {puts "$vm_num is not a valid tart"}}

Can someone please guide me I have the above expect script which is executed when we run the script for instance ./vmSetup.ex "1 2 3" but this is executed sequentially. I had created this expect script but now I want to run the cases in the script i.e. 1, 2 and 3 in parallel. Can someone also tell me how to run for instance 8 cases in parallel? Futhermore I am also using similar cases from 1 to 3 the only difference is the IPs. I have 25 such cases. Can someone also tell me how can I use just one case for all the 25 VMs of them?


Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>