Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9161409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:57:39+00:00 2026-06-17T13:57:39+00:00

I am trying to ping 4 different IP address after login to a remote

  • 0

I am trying to ping 4 different IP address after login to a remote switch using expect,login part works fine and the first 2 ping command (send); but it skips the 3rd ping command and go for 4th ping. And most of the time before showing the ping summary it exits the script.

My Script:

 #!/usr/bin/expect
 spawn telnet 192.168.xx.xx
 expect "Username:" 
 send "username\r"
 expect "Password:"
 send "password\r"
 expect ">"
 send "ping -c 20 192.168.1.10\r"
 expect ">"
 send "ping -c 20 192.168.10.22\r"
 expect ">"
 send "ping -c 20 192.168.10.33\r"
 expect ">"
 send "ping -c 20 192.168.11.10\r"
 expect ">"
 send "quit\r" # command to exit from switch 
 expect eof

I have tried adding “sleep 4” before every send command but the results are same.

Output:

<switch>ping -c 20 192.168.1.20
  PING 192.168.1.20: 56  data bytes, press CTRL_C to break
    Reply from 192.168.1.20: bytes=56 Sequence=1 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=3 ttl=255 time=101 ms
    Reply from 192.168.1.20: bytes=56 Sequence=4 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=5 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=6 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=7 ttl=255 time=102 ms
    Reply from 192.168.1.20: bytes=56 Sequence=8 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=9 ttl=255 time=3 ms
    Reply from 192.168.1.20: bytes=56 Sequence=10 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=11 ttl=255 time=108 ms
    Reply from 192.168.1.20: bytes=56 Sequence=12 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=13 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=14 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=15 ttl=255 time=130 ms
    Reply from 192.168.1.20: bytes=56 Sequence=16 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=17 ttl=255 time=2 ms
    Reply from 192.168.1.20: bytes=56 Sequence=18 ttl=255 time=1 ms
    Reply from 192.168.1.20: bytes=56 Sequence=19 ttl=255 time=160 ms
    Reply from 192.168.1.20: bytes=56 Sequence=20 ttl=255 time=1 ms

  --- 192.168.1.20 ping statistics ---
    20 packet(s) transmitted
    20 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/31/160 ms

<switch>ping -c 20 192.168.10.22
  PING 192.168.10.22: 56  data bytes, press CTRL_C to break
    Reply from 192.168.10.22: bytes=56 Sequence=1 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=2 ttl=255 time=12 ms
    Reply from 192.168.10.22: bytes=56 Sequence=3 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=4 ttl=255 time=35 ms
    Reply from 192.168.10.22: bytes=56 Sequence=5 ttl=255 time=2 ms
    Reply from 192.168.10.22: bytes=56 Sequence=6 ttl=255 time=16 ms
    Reply from 192.168.10.22: bytes=56 Sequence=7 ttl=255 time=2 ms
    Reply from 192.168.10.22: bytes=56 Sequence=8 ttl=255 time=29 ms
    Reply from 192.168.10.22: bytes=56 Sequence=9 ttl=255 time=4 ms
    Reply from 192.168.10.22: bytes=56 Sequence=10 ttl=255 time=39 ms
    Reply from 192.168.10.22: bytes=56 Sequence=11 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=12 ttl=255 time=57 ms
    Reply from 192.168.10.22: bytes=56 Sequence=13 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=14 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=15 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=16 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=17 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=18 ttl=255 time=2 ms
    Reply from 192.168.10.22: bytes=56 Sequence=19 ttl=255 time=1 ms
    Reply from 192.168.10.22: bytes=56 Sequence=20 ttl=255 time=2 ms

  --- 192.168.10.22 ping statistics ---
    20 packet(s) transmitted
    20 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/10/57 ms

<switch>ping -c 20 192.168.11.10
  PING 192.168.11.10: 56  data bytes, press CTRL_C to break
    Reply from 192.168.11.10: bytes=56 Sequence=1 ttl=255 time=4 ms
    Reply from 192.168.11.10: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=3 ttl=255 time=44 ms
    Reply from 192.168.11.10: bytes=56 Sequence=4 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=5 ttl=255 time=57 ms
    Reply from 192.168.11.10: bytes=56 Sequence=6 ttl=255 time=3 ms
    Reply from 192.168.11.10: bytes=56 Sequence=7 ttl=255 time=4 ms
    Reply from 192.168.11.10: bytes=56 Sequence=8 ttl=255 time=4 ms
    Reply from 192.168.11.10: bytes=56 Sequence=9 ttl=255 time=3 ms
    Reply from 192.168.11.10: bytes=56 Sequence=10 ttl=255 time=3 ms
    Reply from 192.168.11.10: bytes=56 Sequence=11 ttl=255 time=3 ms
    Reply from 192.168.11.10: bytes=56 Sequence=12 ttl=255 time=2 ms
    Reply from 192.168.11.10: bytes=56 Sequence=13 ttl=255 time=2 ms
    Reply from 192.168.11.10: bytes=56 Sequence=14 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=15 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=16 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=17 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=18 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=19 ttl=255 time=1 ms
    Reply from 192.168.11.10: bytes=56 Sequence=20 ttl=255 time=1 ms
    [rousseau@localhost script]$ 

As you can see, it skips the 3rd ping (checked several times) and exited before the 4th ping summery. Can anyone please help fixing this? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:57:40+00:00Added an answer on June 17, 2026 at 1:57 pm

    You may be running into a timeout issue. Default timeout for Expect is 10 seconds. 20 pings will take more than that approx.

    use the following command in the beginning of the script:

    set timeout 60

    to set it to 1 min.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to ping a server using the Ping class, but after like
I'm trying to ping a server after an interval using jquery. I found jquery
I have been trying to write a bare-bones ping scanner using Perl for internal
Having and issue with an ejabberd cluster. While trying ping the first node from
I am trying to ping a Socomec meter using the Modbus protocol, having researched,
I am trying to ping a series of servers frequently using the PingReply class.
I'm trying to ping a server based on an IP Address and a port,
I am trying to implement ping using HttpGet but behavior is random. I am
I'm trying to ping the broadcast address 255.255.255.255 on WinXP SP3. If I use
I am trying to ping a server using Rails. I found this Check HTTP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.