tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Neil Movold <nmovold () ibl ! bm>
To: tru64-unix-managers
Subject: Calling tcl/expect script from Perl with arguements?
Date: Thu, 28 Sep 1995 00:08:44 +0000	[thread overview]
Message-ID: <96075323306745.tru64-unix-managers.marc@archive.invalid> (raw)

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
#
   @proglist = ("./create_account.exp","jdoe","WILLLY","The Wilster");
   $rc = system(@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@ibl.bm     
P.O. Box HM2445
Hamilton, Bermuda
HM JX

                 reply	other threads:[~1995-09-28  0:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox