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 8027137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:43:36+00:00 2026-06-04T23:43:36+00:00

So I’ve got a program that will ssh on to a remote server and

  • 0

So I’ve got a program that will ssh on to a remote server and start an iperf sever of that end.
When thats running it will iperf that sever from the client side.

It works fine when I give the IP address statically for example:

        p=pexpect.spawn('ssh -t -x paddy@20.20.20.20 ' + iperf)

But not when I use:

        p=pexpect.spawn('ssh -t -x paddy@'+ADDRESS+' ' + iperf)

I get a:

'pexpect.TIMEOUT'

ADDRESS is definitely going in correctly.
Any one have any ideas about whats going wrong?

    #!/usr/bin/env python
import pexpect
import re
import shutil
import getpass
import struct, fcntl, os, sys, signal, time

def start_Server(iperf, password, ADDRESS):
    ssh_newkey = 'Are you sure you want to continue connecting'
    fix = ADDRESS+' ' + iperf
    p=pexpect.spawn('ssh -t -x paddy@'+ fix)
    i=p.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT],1)
    if i==0:
        print "I say yes"
        p.sendline('yes')
        i=p.expect([ssh_newkey,'password:',pexpect.EOF])
    if i==1: 


        pwtp = False
        trysout = True
        while pwtp == False:
            trysout = True
            p.sendline(password)
            loginStuff=p.expect(['Permission denied, please try again.','Permission denied (publickey,password).', '------------------------------------------------------------', pexpect.TIMEOUT,pexpect.EOF],1)
            if loginStuff == 0:
                password = getpass.getpass("Please enter "+ADDRESS+"'s Password")
            elif loginStuff == 1:
                print 'Sorry but you faild to login'
                sys.exit(0)
                pwtp = True
                trysout = False
            elif loginStuff == 2:
                pwtp = True
                i=3
            elif loginStuff == 4:
                pwtp = True
                pass
            else:
                pass       

    elif i==2:
        print "I either got key or connection timeout"
        pass
    elif i==4:
        print "I either got key or connection timeout"
        pass
    if i==3: #timeout
        print fix
        print ADDRESS
        print 'we find outselfs in a timeout'
        print i
        pass
    return p, password


def RepresentsInt(s):
    try: 
        int(s)
        return True
    except ValueError:
        return False

var = raw_input("Enter the destination IP address: ")
ADDRESS = var

password = getpass.getpass("Please enter "+ADDRESS+"'s Password")        

t, password = start_Server('iperf -s', password, ADDRESS)

u, password = start_Server('iperf -u -s', password, ADDRESS)
print ADDRESS
p=pexpect.spawn('ssh -t -x paddy@20.20.20.20 iperf -u -s')
ssh_newkey = 'Are you sure you want to continue connecting'
i=p.expect([ssh_newkey,'password:',pexpect.EOF])
if i == 0:
    print ssh_newkey
elif i == 1:
    print 'password:'
elif i == 2:
    print pexpect.EOF
else:
    print 'Sorry what!?'
    print i
  • 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-04T23:43:37+00:00Added an answer on June 4, 2026 at 11:43 pm

    It worked when I took the pexpect ssh out of the subroutine.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And

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.