PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Easy question about expect
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Easy question about expect

Réponse
 
LinkBack Outils de la discussion
Vieux 18/05/2007, 15h22   #1
Atropo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Easy question about expect

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

  Réponse avec citation
Vieux 18/05/2007, 16h39   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easy question about expect

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.
  Réponse avec citation
Vieux 18/05/2007, 18h50   #3
Atropo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easy question about expect

On 18 mayo, 10:39, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On 18 May 2007 07:22:51 -0700, Atropo
>
>
>
> <lxvasq...@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.- 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

  Réponse avec citation
Vieux 18/05/2007, 19h56   #4
Glenn Jackman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easy question about expect

At 2007-05-18 01:50PM, "Atropo" wrote:
> On 18 mayo, 10:39, Bill Marcum <marcumb...@bellsouth.net> wrote:
> > On 18 May 2007 07:22:51 -0700, Atropo

[...]
> > > expect: does "\r\n[YOU HAVE NEW MAIL]\r\nworkflow@cofeerd1b>
> > > " (spawn_id 7) match glob pattern "workflow@*.*"? no
> > > expect: timed out

[...]
> 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
  Réponse avec citation
Vieux 18/05/2007, 21h47   #5
Atropo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easy question about expect

On 18 mayo, 13:56, Glenn Jackman <gle...@ncf.ca> wrote:
> At 2007-05-18 01:50PM, "Atropo" wrote:
>
> > On 18 mayo, 10:39, Bill Marcum <marcumb...@bellsouth.net> wrote:
> > > On 18 May 2007 07:22:51 -0700, Atropo

> [...]
> > > > expect: does "\r\n[YOU HAVE NEW MAIL]\r\nworkflow@cofeerd1b>
> > > > " (spawn_id 7) match glob pattern "workflow@*.*"? no
> > > > expect: timed out

> [...]
> > 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


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?

  Réponse avec citation
Vieux 18/05/2007, 22h04   #6
Glenn Jackman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easy question about expect

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h20.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11445 seconds with 14 queries