Calling tcl/expect script from Perl with arguements?

From: Neil Movold <nmovold_at_ibl.bm>
Date: Wed, 27 Sep 1995 20:08:44 -0400 (EDT)

I have recently picked up TCL/Expect for the purpose of writing a script
to answer the questions asked by the system "adduser" script. As it
turns out, the passwd command under OSF/1 is very picky about receiving
its input from ttys. The expect script I wrote, from some examples that
came with the source, works great when called from the shell prompt.
However, when I call the same script from within a Perl script, it causes
errors.

The following is the small Perl script I used to test this out :

----------------------
#!/usr/local/bin/perl
#
   _at_proglist = ("./create_account.exp","jdoe","WILLLY","The Wilster");
   $rc = system(_at_proglist);
   print("rc = $rc\n");
---------------------

Here is the top part of my Expect script that works fine from the shell
prompt :

--------------------
#!/usr/local/bin/expect
#
   log_user 1 # stop STDOUT messages
   set user [lindex $argv 0] # New userid
   set password [lindex $argv 1] # New password
   set name [lindex $argv 2] # New user full name
# set user [string index $argv 0] # New userid
# set password [string index $argv 1] # New password
# set name [string index $argv 2] # New user full name
#
   spawn /usr/sbin/adduser # spawn off the adduser script
   expect "new user"
---------------------

I tried two approaches which both failed. When I run the Perl script, I
get the following error message :

---------------------
wrong # args: should be "set varName ?newValue?"
    while executing
"set user [lindex $argv 0] # New userid"
    (file "./create_account.exp" line 14)
rc = 256
--------------------

What does this mean?

Unfortunately, I have no reference material to fall back on. I have
ordered a couple of books on tcl and expect, but it will take a few weeks
for them to be delivered over seas from the US. I have looked on the Web
and cannot find anything matching this problem.

Any advice would be appreciated.


                Neil :-)


                     \\\//
                     (o o)
------------------ooO-(_)-Ooo-----------------------------------------
Neil Movold Phone : +1 809 296-1800
Special Operations Consultant Fax : +1 809 295-7269
 ( i.e. the guy who has to
        make it all work :-) )
Internet (Bermuda) Limited E-mail : nmovold_at_ibl.bm
P.O. Box HM2445
Hamilton, Bermuda
HM JX
Received on Thu Sep 28 1995 - 00:31:03 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:46 NZDT