Bonjour,

En premier lieu, je ne sais pas si je suis sur le bon forum car je dois travailler sous Windows avec cet outils Linux

J'ai un petit soucis avec le programme expect

Voici mon script « myscript.tcl » :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
#!/usr/bin/expect -f
 
log_user 0
 
set force_conservative 1;
 
set timeout 15
 
set host [lindex $argv 0]
set user [lindex $argv 1]
set pass [lindex $argv 2]
 
send_user "host=<$host>\n"
send_user "user=<$user>\n"
send_user "pass=<$pass>\n"
 
# Open an ftp session to a remote server, and wait for a username prompt.
spawn ftp ${host}
expect_background -re .+
expect -re "Utilisateur(.*):"
 
# Send the username, and then wait for a password prompt.
send "${user}\n"
expect -re "(.*)Mot de passe(.*):"
 
# Send the password, and then wait for an ftp prompt.
send "${pass}\n"
expect "ftp>"
 
# Turn off prompting.
send "prompt\n"
expect "ftp>"
 
# Get all the files
send "get .profile\n"
expect "ftp>"
 
# Exit the ftp session, and wait for a special end-of-file character.
send "bye\n"
expect eof
 
log_user 1
 
exit
Je lance alors la commande :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
expect -d myscript.tcl myhost itsme xxxxxx
Et voici ce que j'obtiens à l'écran :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
expect version 5.26
argv[0] = ../bin/expect.exe  argv[1] = -d  argv[2] = myscript.tcl  argv[3] = myhost  argv[4] = itsme  argv[5] = xxxxxx
set argc 3
set argv0 "myscript.tcl"
set argv "myhost itsme xxxxxx"
executing commands from command file myscript.tcl
host=<myhost>
user=<itsme>
pass=<xxxxxx>
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {1001}
expect: does "" (spawn_id 4) match regular expression "Utilisateur(.*):"? no
expect: does "Utilisateur (myhost.toto.titi:(none)) : " (spawn_id 4) match regular expression "Utilisateur(.*):"? yes
expect: set expect_out(0,string) "Utilisateur (myhost.toto.titi:(none)) :"
expect: set expect_out(1,string) " (myhost.toto.titi:(none)) "
expect: set expect_out(spawn_id) "4"
expect: set expect_out(buffer) "Utilisateur (myhost.toto.titi:(none)) :"
send: sending "itsme\n" to { 4 }
expect: does " " (spawn_id 4) match regular expression "(.*)Mot de passe(.*):"? no
expect: does " itsme\n" (spawn_id 4) match regular expression "(.*)Mot de passe(.*):"? no
Mot de passe :
Pas moyen de passer la frontière du mot de passe, alors qu'en simulation, tout se passe bien

Quelle est mon erreur ?
Quelqu'un peut-il m'aider ?

Merci.