Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1270 connectés 

  FORUM HardWare.fr
  Programmation

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

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

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

n°35604
TBone
Pouet.
Posté le 30-05-2001 à 13:57:51  profilanswer
 

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.
mood
Publicité
Posté le 30-05-2001 à 13:57:51  profilanswer
 

n°35655
TBone
Pouet.
Posté le 30-05-2001 à 15:48:00  profilanswer
 

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.
n°35707
Jak
Back to Slack !
Posté le 30-05-2001 à 16:57:47  profilanswer
 

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

n°35710
irulan
Posté le 30-05-2001 à 17:04:19  profilanswer
 

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

n°35714
TBone
Pouet.
Posté le 30-05-2001 à 17:07:00  profilanswer
 

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.
n°35720
TBone
Pouet.
Posté le 30-05-2001 à 17:14:14  profilanswer
 

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.
n°35726
irulan
Posté le 30-05-2001 à 17:22:09  profilanswer
 

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"

n°35731
TBone
Pouet.
Posté le 30-05-2001 à 17:29:46  profilanswer
 

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.
n°35732
TBone
Pouet.
Posté le 30-05-2001 à 17:30:26  profilanswer
 

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.
n°35734
irulan
Posté le 30-05-2001 à 17:36:38  profilanswer
 

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]

mood
Publicité
Posté le 30-05-2001 à 17:36:38  profilanswer
 

n°35739
TBone
Pouet.
Posté le 30-05-2001 à 17:42:47  profilanswer
 

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.
n°35741
irulan
Posté le 30-05-2001 à 17:47:41  profilanswer
 

Et tu as testé avec echo ?

n°35878
TBone
Pouet.
Posté le 31-05-2001 à 08:51:45  profilanswer
 

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.
n°35945
TBone
Pouet.
Posté le 31-05-2001 à 11:18:56  profilanswer
 

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.
n°35985
TBone
Pouet.
Posté le 31-05-2001 à 12:00:54  profilanswer
 

ç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.

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

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

 

Sujets relatifs
Question nul sur la POO[php/msql] question bidon sur les '
[PHP] Demande d'aide - Question pour les pros du PHP ;-)question à laquelle je suis fière d'avoir répondu !!!!
[C++] Très Urgent !!! Question de vie ou de ...[Oracle] Question URGENTISSIME !! Vite !
Question aux programmeurs JAVA... a propos de GEF...C++, prog Win32, question simple de débutant !
[VC++] question sur gethostbyaddrPour une question C++ qui m'interroge !
Plus de sujets relatifs à : [expect] euh... un p'tite question...


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR