ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] Expect
@ 2006-11-22 12:22 Eugene Prokopiev
  2006-11-22 17:12 ` Peter Volkov
  0 siblings, 1 reply; 7+ messages in thread
From: Eugene Prokopiev @ 2006-11-22 12:22 UTC (permalink / raw)
  To: Community

Здравствуйте!

Есть такой expect-скрипт:

#!/usr/bin/expect -f

set timeout 5

spawn telnet localhost

expect {
         "ogin:"         { send -- "test\r" }
         timeout         { abort }
}

expect {
         "assword:"      { send -- "1\r" }
         timeout         { abort }
}

expect {
         "\$"            { send -- "ls\r" }
         timeout         { abort }
}

expect {
         "\$"            { send -- "exit\r" }
         timeout         { abort }
}

exit 0

Вывод:
$ ./login.exp
spawn telnet localhost
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
login: test
Password:
Last login: Wed Nov 22 15:15:13 2006 from localhost.localdomain on pts/7
-bash-2.05b$ invalid command name "abort"
     while executing
"abort "
     invoked from within
"expect -nobrace {$} { send -- "ls\r" } timeout { abort }"
     invoked from within
"expect {
         "\$"            { send -- "ls\r" }
         timeout         { abort }
}"
     (file "./login.exp" line 17)

Вопросы:

1) почему скрипт не дожидется \$ ?
2) почему abort (описанный в мане) - invalid command name?
3) можно ли упростить код, приняв что-то вроде "timeout { abort }" за 
поведение по умолчанию, чтобы в основном коде остались только expect и send?


-- 
С уважением, Прокопьев Евгений



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-11-23  9:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22 12:22 [Comm] Expect Eugene Prokopiev
2006-11-22 17:12 ` Peter Volkov
2006-11-22 17:59   ` Eugene Prokopiev
2006-11-23  7:23   ` Eugene Prokopiev
2006-11-23  7:58   ` Eugene Prokopiev
2006-11-23  8:25   ` Eugene Prokopiev
2006-11-23  9:35   ` Eugene Prokopiev

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git