On 02Sep2018 14:29, Steven D'Aprano <st...@pearwood.info> wrote:
On Sun, Sep 02, 2018 at 10:01:02AM +1000, Cameron Simpson wrote:
On 02Sep2018 00:31, Steven D'Aprano <st...@pearwood.info> wrote:
>On Sat, Sep 01, 2018 at 11:41:42AM +0000, krishna chaitanya via Tutor
>wrote:
>>Below is my code, i am frequently hitting timeout issue to login to linux
>>or router.
>
>Timeout issues are a network problem. Perhaps your network is too busy,
>or the cable is faulty, or your router is being hammered by attackers
>and can't respond.

No, timeout issues are "the target input didn't arrive in this timeframe".

All his commands are _local_.

Krishna wrote:

"i am frequently hitting timeout issue to login to linux or router."

Given that Krishna says he's trying to login to a router, what tells you
that it is local?

His script, which goes:

 import pexpect
 from pexpect import *
 child = spawn('su xxxxx',timeout = 50)
 child.expect('Password:',timeout = 50)
 child.sendline('XXXXXXX') #child.sendline('ls -l')#
 chasis = child.before.decode('utf-8')
 child.expect('krishna@krishna-desktop:~/python_excercises$',timeout = 50)
 child.sendline('ls -l')
 chasis = child.before.decode('utf-8')
 print(chasis)

 Error :
raise TIMEOUT(msg)pexpect.exceptions.TIMEOUT: Timeout exceeded.<pexpect.pty_spawn.spawn object at 0x7f068506fa20>

All his commands are local, with no remote login. He's probably just slightly misusing the term "timeout issue to login to linux" when tallking about "su".

The expect stuff matches command outputs against an expression. Any command which issues a prompt and pauses indefinitely, and whose prompt isn't matched by the expression, will inherently stall the output and cause a timeout if the expect() call has a timeout setting.

It could easily be that the su is working and that his pattern for his shell prompt is incorrect ("python_excercises" looks misspelled to me). Same situation and same symptom.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to