1834093 Members
2398 Online
110063 Solutions
New Discussion

Re: Expect help needed

 
jagdeesh
Frequent Advisor

Expect help needed

Hello All,

I have a shell level code as follows...

cat hostlist.txt |
whiler read host platform
do
echo "server:$host - OS:$platform"
done


Conside the hostlist.txt host
host1 hp
host2 sun
host3 hp
host4 aix

Can any of get me te equivalent code for expect program please ?

Many Thanks.
4 REPLIES 4
Patrick Wallek
Honored Contributor

Re: Expect help needed

Unless you are doing more in the script than you say, this really isn't a job for expect.

The expect language is good for scripts that are 'expect'ing (get it) input. Expect allows you to automate that.

Using expect for something as simple as what you have above is really a waste.
Olivier Masse
Honored Contributor

Re: Expect help needed

Even if it was one of those cases where I find expect useful, I would recommend against using expect directly unless you already know TCL or really, really want to learn it. In my case, over the years expect went from the "cool" thing to do to the "last resort" thing...

I use perl-expect nowadays, I prefer the syntax and can code faster with it. It's a matter of personal opinion, of course.

Olivier
jagdeesh
Frequent Advisor

Re: Expect help needed

Thanks Patrick, Oliver...

I have good understanding about Tcl and expect. I am trying to execute a code for list of servers reading from a file.

Anyway,, i got the solution from Tcl commands.

Thank you verymuch onceagin. I am not good at perl... but try to learn and see how it is benefitial

...Jags
jagdeesh
Frequent Advisor

Re: Expect help needed

Thanks