[expect] euh... un p'tite question...

euh... un p'tite question... [expect] - Programmation

Marsh Posté le 30-05-2001 à 13:57:51    

chalut,
 
j'expecte un peu (linux/expect1.1) mais j'ai un petit souci...
 
je fais un script expect et je voudrais utiliser des arguments que je tape à l'appel de ce script. (toto arg1 arg2 arg3)
 
comment faire pour les faire passer ???
 
pour l'instant j'utilise $argv mais dans ce cas arg1 arg2 et arg3 ne font qu'un seul argument.
 
comment faire pour les découper ??? j'ai essayé $argv[0]... et que dalle...
 
une info ?


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 13:57:51   

Reply

Marsh Posté le 30-05-2001 à 15:48:00    

beuh?!?:??:


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 16:57:47    

Boah, non, c'est pas forcément le mauvais forum, la programmation Shell :)
 
T'as essayé $1, $2 et $3 ?

Reply

Marsh Posté le 30-05-2001 à 17:04:19    

Oui je confirme j'ai vérifié dans un bouquin de prog shell UNIX:
$0 : la commande
$1,$2,... : 1er, 2ème,... paramètre passé au script (jusqu'à 10 maxi en général)
$* : tous les paramètres sous la forme d'un seul argument
$# : le nombre de paramètres passés au script

Reply

Marsh Posté le 30-05-2001 à 17:07:00    

j'essaie.


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 17:14:14    

marche pô...
 
voilà ce que je fais:
 
script speak:
#!/usr/bin/expect -f
send $1
send "\n"
send $2
send "\n"
 
en espérant ceci:
 
$speak 1 2
1
2
$_
 
et beh que dalle...
 
j'ai:
can't read "1": no such variable while executing "send $1" (file "./speak" line 2)
 
gRrRrRrrr... :D
 
soit soit soit... je vais chercher (mieux) dans le man pour découper les arguments.
 
merci quand même ;)


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 17:22:09    

Attends ! $1, $2, ... sivent être utilisés à l'INTERIEUR de la chaîne que tu veux afficher !
Par exemple, ton script devrait être :
send "Premier param : $1 \n"
send "Deuxieme param : $2 \n"

Reply

Marsh Posté le 30-05-2001 à 17:29:46    

o-oh...


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 17:30:26    

nope... no such variable... argv est donc bien une var system pour expect... et à mon avis, il faut trouver l'astuce pour découper en rondelles le String passé en arg...

 

[edit]--Message édité par TBone--[/edit]


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 17:36:38    

Euh, je ne connais pas trop expect, mais la commande echo n'existe pas dans ce shell ?
Parce que la syntaxe que je t'indiquais plus haut marche sans problème avec echo (testé et approuvé :D )

 

[edit]--Message édité par irulan--[/edit]

Reply

Marsh Posté le 30-05-2001 à 17:36:38   

Reply

Marsh Posté le 30-05-2001 à 17:42:47    

echo ~ send
 
en fait; expect te remplace... send c'est comme si tu le tapais quand on le demande...
(sauf si c'est une commande, c'est spawn dans ce cas... :crazy: je débute alors douuuuuucement hein! ;)


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 30-05-2001 à 17:47:41    

Et tu as testé avec echo ?

Reply

Marsh Posté le 31-05-2001 à 08:51:45    

echo n'existe pas dans ma doc...
 
et puis, le but final n'est pas d'imprimer mes args un à un ;) mais de les intégrer à un script plus complet...
 
bon, je vais ...euh... lire... de la doc... mais où ? :??:
 
@+

 

[edit]--Message édité par TBone--[/edit]


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 31-05-2001 à 11:18:56    

j'avance... c'est basé sur TCL... comment passe-t-on des args en ligne de commande en TCL ???


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Marsh Posté le 31-05-2001 à 12:00:54    

ça y est !!!
 
c'est lindex $argv n°argument


---------------
As the plane took off, the pilot turned to the co-pilot and said, “Have you ever flown solo?” Co-pilot: No. Typically I fly much higher than this.
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed