|
Home > Archive > Unix Shell > May 2007 > Easy question about expect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Easy question about expect
|
|
| Atropo 2007-05-18, 1:23 pm |
| I'm a really newbie on this. I wish a simple script to switch a user
and executes a command as the other user.
#!/usr/local/bin/expect
set ACCION [lindex $argv 0]
spawn su - workflow
expect "Password:*" {
send "workpass\n"
}
expect "workflow@*.*" {
send "echo workflow $ACCION\n"
sleep 5
}
exit
it does log in, but does not execute the command.
so i put a logfile, but i don't understand it.
when you log into the user it usually show you a "[YOU HAVE NEW
MAIL]"
does it affect the expect behavior??
why those " match glob pattern ?" says "NO"
expect: does "" (spawn_id 7) match glob pattern "Password:*"? no
workflow's Passw
expect: does "workflow's Passw" (spawn_id 7) match glob pattern
"Password:*"? no
ord:
expect: does "workflow's Password: " (spawn_id 7) match glob pattern
"Password:*"? yes
expect: set expect_out(0,string) "Password: "
expect: set expect_out(spawn_id) "7"
expect: set expect_out(buffer) "workflow's Password: "
send: sending "workpass\n" to { 7 }
expect: does "" (spawn_id 7) match glob pattern "workflow@*.*"? no
expect: does "\r\n" (spawn_id 7) match glob pattern "workflow@*.*"? no
[YOU HAVE NEW MAIL]
expect: does "\r\n[YOU HAVE NEW MAIL]\r\n" (spawn_id 7) match glob
pattern "workflow@*.*"? no
workflow@cofeerd1b>
expect: does "\r\n[YOU HAVE NEW MAIL]\r\nworkflow@cofeerd1b>
" (spawn_id 7) match glob pattern "workflow@*.*"? no
expect: timed out
| |
| Bill Marcum 2007-05-18, 1:23 pm |
| On 18 May 2007 07:22:51 -0700, Atropo
<lxvasquez@gmail.com> wrote:
>
>
> I'm a really newbie on this. I wish a simple script to switch a user
> and executes a command as the other user.
>
> expect: does "" (spawn_id 7) match glob pattern "workflow@*.*"? no
>
>
> expect: does "\r\n" (spawn_id 7) match glob pattern "workflow@*.*"? no
> [YOU HAVE NEW MAIL]
>
> expect: does "\r\n[YOU HAVE NEW MAIL]\r\n" (spawn_id 7) match glob
> pattern "workflow@*.*"? no
> workflow@cofeerd1b>
> expect: does "\r\n[YOU HAVE NEW MAIL]\r\nworkflow@cofeerd1b>
> " (spawn_id 7) match glob pattern "workflow@*.*"? no
> expect: timed out
>
The user's prompt does not contain '.' Change the pattern to
'workflow@*'
--
A halted retreat
Is nerve-wracking and dangerous.
To retain people as men -- and maidservants
Brings good fortune.
| |
| Atropo 2007-05-18, 1:23 pm |
| On 18 mayo, 10:39, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On 18 May 2007 07:22:51 -0700, Atropo
>
>
>
> <lxvasq...@gmail.com> wrote:
>
>
>
>
>
> The user's prompt does not contain '.' Change the pattern to
> 'workflow@*'
>
> --
> A halted retreat
> Is nerve-wracking and dangerous.
> To retain people as men -- and maidservants
> Brings good fortune.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
Thanks a lot Bill. I'll do that.
this regular expression thing it's a whole treat for a newbie
| |
| Glenn Jackman 2007-05-18, 7:17 pm |
| At 2007-05-18 01:50PM, "Atropo" wrote:
> On 18 mayo, 10:39, Bill Marcum <marcumb...@bellsouth.net> wrote:
[...][vbcol=seagreen]
[...][vbcol=seagreen]
> this regular expression thing it's a whole treat for a newbie
Pedantically speaking, glob patterns are not regular expressions.
They're different languages.
Expect is implemented over Tcl. Glob patterns are documented here:
http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm#M35
and regular expressions here:
http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm
Also, if you haven't seen it, the indispensible Expect book is
"Exploring Expect" by Don Libes.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
| |
| Atropo 2007-05-18, 7:17 pm |
| On 18 mayo, 13:56, Glenn Jackman <gle...@ncf.ca> wrote:
> At 2007-05-18 01:50PM, "Atropo" wrote:
>
> [...]
> [...]
>
> Pedantically speaking, glob patterns are not regular expressions.
> They're different languages.
>
> Expect is implemented over Tcl. Glob patterns are documented here:
> http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm#M35
> and regular expressions here:
> http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm
>
> Also, if you haven't seen it, the indispensible Expect book is
> "Exploring Expect" by Don Libes.
>
> --
> Glenn Jackman
> "You can only be young once. But you can always be immature." -- Dave Barry
Thanks for the info Glenn, I'll RTFM. meanwhile I would like to
achieve this goal. would you please point me where my errors are?
| |
| Glenn Jackman 2007-05-18, 7:17 pm |
| At 2007-05-18 04:47PM, "Atropo" wrote:
[...]
> Thanks for the info Glenn, I'll RTFM. meanwhile I would like to
> achieve this goal. would you please point me where my errors are?
Bill already did a few hours ago.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
|
|
|
|
|