Re: expect - problem split argv 0, then send each item as command
- From: vitick@xxxxxxxxx
- Date: Sun, 20 Apr 2008 08:50:27 -0700 (PDT)
On Apr 20, 7:23 am, inetquestion <inetquest...@xxxxxxxxxxx> wrote:
When I execute the following script via: ./go.exp
"date;hostname;uname"
I only get output from the puts line, instead of actually sending the
commands to a shell. What am I missing? Is there a problem putting an
expect block inside a foreach loop?
-Inet
#!/usr/bin/expect
foreach element [ split [lindex $argv 0] ";" ] {
puts "sending: $element\n"
expect {
-re ".*$" { send -- "$element\r" }
}
}
-------
-------
./go.exp "date;hostname;uname"
sending: date
sending: hostname
sending: uname
You need to do [ spawn /bin/bash ] first. Expect has to talk to a
process, you cannot just send commands from Expect to Expect, it
doesn't know where you want to send it.
As I mentioned it before in this group, do use autoexpect, you would
have seen that right away in it's output script.
---Victor
.
- Follow-Ups:
- Re: expect - problem split argv 0, then send each item as command
- From: inetquestion
- Re: expect - problem split argv 0, then send each item as command
- References:
- expect - problem split argv 0, then send each item as command
- From: inetquestion
- expect - problem split argv 0, then send each item as command
- Prev by Date: Re: XOTCLIDE with SQLite
- Next by Date: Re: ANN Tloona 1.3.0 released
- Previous by thread: expect - problem split argv 0, then send each item as command
- Next by thread: Re: expect - problem split argv 0, then send each item as command
- Index(es):
Relevant Pages
|