Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

expect part II

Original Message
Name: iancaem02
Date: May 1, 2008 at 20:37:41 Pacific
Subject: expect part II
OS: linux
CPU/Ram: 256
Model/Manufacturer: dell
Comment:
Hi, I have file trial.txt that contain several lines :

a111
a112
a113
....
axxx

I have a second file (expect file) coba.exp, i want to get those strings as parameter from the first file

so on my expect file can doing some looping :

#!/usr/bin/expect

#expect command

send "a111\r"
send "axxx\r"
send "a113\r"
.....
send "a114\r"

#end expect

what should i wrote on coba.exp

any direction would be greatly appreciated.

BEST REGARDS
ADRIAN


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: May 2, 2008 at 07:24:15 Pacific
Subject: expect part II
Reply: (edit)
I'm assuming you want to call your expect script once per file entry. First, create a shell script that reads the trial.txt


# UNTESTED
while read myvar
do
cobra.exp $myvar
done < trial.txt

In order for the expect file to read the parameter, do something like this:

set sendvar [lindex $argv 0 ]

send "$sendvar\r"

Second, if you know the actual number of variables passed to the expect script you could read each of the variables and then call the expect script like this:

cobra.exp $myvar1 $myvar2 $myvar3

Then change the expect script to something like this:

set sendvar0 [lindex $argv 0 ]
set sendvar1 [lindex $argv 1 ]
set sendvar2 [lindex $argv 2 ]


Report Offensive Follow Up For Removal

Response Number 2
Name: iancaem02
Date: May 2, 2008 at 09:57:42 Pacific
Subject: expect part II
Reply: (edit)
i create new shell script to read trial.txt called ian.sh
and i put command:

while read myvar
do
coba.exp $myvar
done < trial.txt

after im doing like ur advice i found some message

ian.sh: line 39: coba.exp: Permission denied

what happen and how to fixed it??

BEST REGARDS
ian caem


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: May 2, 2008 at 10:34:05 Pacific
Subject: expect part II
Reply: (edit)
Since I can not see line 39 of ian.sh, it's not possible for me to tell for sure. It looks like you've set ian.sh to execute, but ian.sh doesn't have permission to execute coba.exp.

post the output of:

ls -l coba.exp
ls -l ian.sh

and I might be able to tell you.


Report Offensive Follow Up For Removal

Response Number 4
Name: ernie
Date: May 4, 2008 at 12:54:07 Pacific
Subject: expect part II
Reply: (edit)
Sounds to me as if bash is telling you that
coba.exp is not executable. You may need to
change the files permissions:

chmod +x (path to)coba.exp

I do not use expect here, so this may be
wrong ...

HTH,

Ernie Registered Linux User 247790


Report Offensive Follow Up For Removal

Response Number 5
Name: iancaem02
Date: May 5, 2008 at 03:19:54 Pacific
Subject: expect part II
Reply: (edit)
i have doing this

chmod 700 coba.exp and chmod 700 ian.sh

and everything works..thanx pals!?

BEST REGARDS
ian caem


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: expect part II

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC