reading variables from an external file using expect 
Author Message
 reading variables from an external file using expect

Hi all,
I'm using this expect script for a simple web output i'm generating later.

----
#!/usr/bin/expect

set timeout -1

spawn /usr/bin/telnet dcm2000

expect "ogin:"
send "username\r"
expect "assword:"
send "password\r"
expect "#"
send "mod map\r"
expect "#"
send "exit\r"

----

I need to know how and if it is possible to read values for username and
password so i'll be able to use

$user
$pass

As i have external file where the user/pass should be put on and could be
changed through a web interface.
I need the expect script to read username & password from that file (it
could be a different file for each) and
set it as variables such as: $user, $pass

I've tried exporting the variables from bash and I've checked some Usenet
messages but I can't find the way of doing it.

thought it might be as "read user < user.file", but still I can't find the
exact way of reading variable from a file.

environment variables are out of the question, I won't use it either way.
all I need is to read variable into an expect script from external file.

Thanks people!

----EOF

- Shay Hugi,
Gilat Satellite Networks (Satcom)


http://www.*-*-*.com/



Sun, 08 Jan 2006 06:39:09 GMT  
 reading variables from an external file using expect

Quote:

> I need to know how and if it is possible to read values for username and
> password so i'll be able to use

> $user
> $pass

> As i have external file where the user/pass should be put on and could be
> changed through a web interface.
> I need the expect script to read username & password from that file (it
> could be a different file for each) and
> set it as variables such as: $user, $pass

> I've tried exporting the variables from bash and I've checked some Usenet
> messages but I can't find the way of doing it.

> thought it might be as "read user < user.file", but still I can't find the
> exact way of reading variable from a file.

Are they available via ftp or http?  You could use the http package
to retreive the file (or the ftp package for ftp).  If they are
somewhere on disk that you know, then you just need to read up on
the 'open' and 'read' command.  It all depends on what is in the
data for who you evaluate it.

--
     Jeff Hobbs                     The Tcl Guy
     Senior Developer               http://www.ActiveState.com/
         Tcl Support and Productivity Solutions



Tue, 10 Jan 2006 23:30:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Reading external variables from a library (BIND)

2. end-of-file during read using unformatted reading

3. Question about Expect - reading in variables.

4. EXPECT reading a caught error into a variable.

5. can an expect program read an environment variable?

6. External variables and component files in Dyalog

7. reading in external file in clarion4 eval

8. Global variables, External DLL and Files

9. Reading External .txt files in Quartus II

10. reading text from external files

11. Parse external file and assign result to a variable

12. reading an external text file

 

 
Powered by phpBB® Forum Software