Re: bash скрипты и expect(empty)
- To: Debian-Russian2 <debian-russian@lists.debian.org>
- Subject: Re: bash скрипты и expect(empty)
- From: Aleksey Cheusov <vle@gmx.net>
- Date: Tue, 14 Apr 2009 11:57:06 +0300
- Message-id: <s93ws9npq8t.fsf@chel.imb.invention.com>
- In-reply-to: <cqpS0-5Bq-1@gated-at.bofh.it> (Shabanov Paul's message of "Mon, 13 Apr 2009 10:40:08 +0200")
- References: <cq8eu-7rY-3@gated-at.bofh.it> <cq9aD-5Kb-21@gated-at.bofh.it> <cqpS0-5Bq-1@gated-at.bofh.it>
> Да, годится. Но с expect--ом тоже хотелось бы разобраццо..
Чем большэ тибе хочиццца разабраццо, тем меньше шансафф, что тибе
атветят в следущий рас!
Два простейших примера для expect-а
expect_putftp - копирует файлы на ftp сервер.
#!/usr/bin/env expect
# usage: expect_ftpput host username password files
set timeout 20
set host [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set files [lindex $argv 3]
spawn ftp -n $host
expect "ftp> "
send "user\n"
expect "(username)"
send "$user\n"
expect "Password:"
send "$password\n"
expect "ftp> "
send "cd ~\n"
expect "ftp> "
send "mput $files\n"
expect "mput "
send "a\n"
expect "ftp> "
expect_runcmd - запускает команду по telnet-у.
#!/usr/bin/env expect
# usage: expect_runcmd host username password cmd
set timeout 20
set name [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set command [lindex $argv 3]
spawn telnet $name
expect "login:"
send "$user\n"
expect "Password:"
send "$password\n"
expect "prompt>"
send "$command\n"
expect "prompt>"
--
Best regards, Aleksey Cheusov.
Reply to: