f



Problem with "Expect" ? "Telnet"? "TclApp"?

Hi,
My script  try to "Telnet" a machine  with "Expect", and it is wrapped
to EXE extension with "TclApp". DEP is turned off, and file
dgbhelp.dll exists. And now, I run the script. It works well in some
PC. However in others,  it turns out that the commands in "Telnet" is
not executed. I capture the packets, and find that the "username" is
not promoted when the server ask for it. Then I try the tcl extension
script, it is OK in every PC.
I have no idea what's going on.It is the problem of "Expect",
"Telnet", or "TclApp", or the OS of my PCs?

zhoujingyu
Regards,
0
4/22/2008 6:59:06 AM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

5 Replies
1292 Views

Similar Articles

[PageSpeed] 6

The problem troubles me so much. I am crying for you help. Can anyone
give me some advice? Thank you very much!

Regards,
zhoujingyu

0
1985zhoujingyu
4/24/2008 12:51:46 AM
At 2008-04-23 08:51PM, "1985zhoujingyu@163.com" wrote:
>  The problem troubles me so much. I am crying for you help. Can anyone
>  give me some advice? Thank you very much!

Show us your Expect script. 

-- 
Glenn Jackman
  "If there is anything the nonconformist hates worse than a conformist, 
   it's another nonconformist who doesn't conform to the prevailing 
   standard of nonconformity." -- Bill Vaughan 
0
glennj (645)
4/24/2008 1:24:37 PM
On 4=D4=C224=C8=D5, =CF=C2=CE=E79=CA=B124=B7=D6, Glenn Jackman <gle...@ncf.c=
a> wrote:
>
> Show us your Expect script.
>
> --
> Glenn Jackman
>   "If there is anything the nonconformist hates worse than a conformist,
>    it's another nonconformist who doesn't conform to the prevailing
>    standard of nonconformity." -- Bill Vaughan

My script as follow:

#code start
package require Expect
set dslam_ip "192.168.1.1"
set dslam_username "admin"
set dslam_password "1234"

spawn telnet $dslam_ip
expect "Username" {
    exp_send "$dslam_username\r\n"
}
expect "Password" {
    exp_send "$dslam_password"
}
exp_log_file dslam_info.txt
expect "ras>" {
    exp_send "statistics adsl show\r\n"
}
expect "" {
}
exp_log_file
exp_close
#code end

Regards,
zhoujingyu
0
1985zhoujingyu
4/25/2008 1:07:38 AM
At 2008-04-24 09:07PM, "1985zhoujingyu@163.com" wrote:
>  On 4??24??, ????9??24??, Glenn Jackman <gle...@ncf.ca> wrote:
> >
> > Show us your Expect script.
> >
> > --
> > Glenn Jackman
> >   "If there is anything the nonconformist hates worse than a conformist,
> >    it's another nonconformist who doesn't conform to the prevailing
> >    standard of nonconformity." -- Bill Vaughan
>  
>  My script as follow:
>  
>  #code start
>  package require Expect
>  set dslam_ip "192.168.1.1"
>  set dslam_username "admin"
>  set dslam_password "1234"
>  
>  spawn telnet $dslam_ip
>  expect "Username" {
>      exp_send "$dslam_username\r\n"

       exp_send "$dslam_username\r"

>  }
>  expect "Password" {
>      exp_send "$dslam_password"

       exp_send "$dslam_password\r"

>  }
>  exp_log_file dslam_info.txt
>  expect "ras>" {
>      exp_send "statistics adsl show\r\n"

       exp_send "statistics adsl show\r"

>  }
>  expect "" {

Here, you should expect the prompt.  is it "ras>" ?
>  }
>  exp_log_file
>  exp_close

Instead of close, you should:

    exp_send "exit\r"
    expect eof


-- 
Glenn Jackman
  "If there is anything the nonconformist hates worse than a conformist, 
   it's another nonconformist who doesn't conform to the prevailing 
   standard of nonconformity." -- Bill Vaughan 
0
glennj (645)
4/25/2008 1:29:27 AM
On 4=D4=C225=C8=D5, =C9=CF=CE=E79=CA=B129=B7=D6, Glenn Jackman <gle...@ncf.c=
a> wrote:
> At 2008-04-24 09:07PM, "1985zhoujin...@163.com" wrote:
>

>
> >  }
> >  expect "" {
>
> Here, you should expect the prompt.  is it "ras>" ?
>
> >  }
> >  exp_log_file
> >  exp_close
>
> Instead of close, you should:
>
>     exp_send "exit\r"
>     expect eof
>
> --
> Glenn Jackman
>   "If there is anything the nonconformist hates worse than a conformist,
>    it's another nonconformist who doesn't conform to the prevailing
>    standard of nonconformity." -- Bill Vaughan- =D2=FE=B2=D8=B1=BB=D2=FD=
=D3=C3=CE=C4=D7=D6 -
>
> - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 -

Hi,
I have tried you advice, and still it doesn't work. In my opinion,
that's not the point. I captured the interactive packets on the PC
while the script was performed. I found that the "username" was not
given at the time the server asked for it, when the script was wrapped
to EXE extension with TclApp. But it works well with tcl extension as
I described above.

Regards
zhoujingyu
0
1985zhoujingyu
4/26/2008 1:08:05 AM
Reply: