Expect behaving weirdly on AIX 
Author Message
 Expect behaving weirdly on AIX

I've written a script on an AIX 4.3 machine owned by a friend of mine. I
don't know how standard it is, because it runs his medical clinic's
billing software and doesn't seem to have things that I'd expect on a
unix box (eg. man pages, a version of top, etc.).

Anyway, I installed expect 5.31, tcl, and tk 8.2 on it from binaries
primarily because it's C compiler doesn't seem to behave very nicely
with alot of source distribustions and I don't know enough C to debug
the problems.

I then wrote him an expect script as part of a larger system (the
biggest part, but still only part) to run a monthly report for him. Here
are the steps.

1) Run a ksh script to eliminate some environment variables that{*filter*}
up the perl interpretor.
2) Run a perl script that generates a couple of strings (1 for the first
of this month, and one for the first of this month last year). These are
passed to the expect script when it's run from within this perl script.
(forgive me if there's a more "expecty" way of doing this, but I have
limited resources and time so I did what I knew would work)
3) Run the expect script from within perl.

Now here's the problem. It all works wonderfully when run from the
command line. However, when I plug it into cron and execute it, the
expect script goes into a completely different set of menus.

Does anyone have any clue why (more importantly, how to fix it)?

I've tried spawing the user's .profile file instead of the program
directly. I would think this would set up the environment exactly the
same as on the command line. I've tried disabling the auto run of the
program in .profile and running .profile then the program.

I've even tried telnetting into the system with the script (having it
log in and do it's thing before logging out).

I'm completely at a loss. I don't know enough expect to do anything
extremely fancy. My code basically looks like the below example with a
bunch more options to go into the appropriate menu and fill in
parameters.

Again, it works from the command line and NOT from cron. I don't know if
I should blame AIX, expect, my script, or what. Is there a switch to
spawn that maybe I missed. I've run through the man page for expect on a
Linux box (remember no manpages work on the AIX box) and tried all of
those that made sense to try (in my thinking). What else can I do?

spawn /path/to/program

expect {
    "[]" {
        send "1\r"
    }

Quote:
}

expect {
    "What Company?" {
        send "1\r"
    }

Quote:
}

Sent via Deja.com http://www.*-*-*.com/
Before you buy.


Sat, 08 Mar 2003 03:00:00 GMT  
 Expect behaving weirdly on AIX

Quote:

> I've written a script on an AIX 4.3 machine owned by a friend of mine. I
> don't know how standard it is, because it runs his medical clinic's
> billing software and doesn't seem to have things that I'd expect on a
> unix box (eg. man pages, a version of top, etc.).

> Anyway, I installed expect 5.31, tcl, and tk 8.2 on it from binaries
> primarily because it's C compiler doesn't seem to behave very nicely
> with alot of source distribustions and I don't know enough C to debug
> the problems.

> I then wrote him an expect script as part of a larger system (the
> biggest part, but still only part) to run a monthly report for him. Here
> are the steps.

> 1) Run a ksh script to eliminate some environment variables that{*filter*}
> up the perl interpretor.
> 2) Run a perl script that generates a couple of strings (1 for the first
> of this month, and one for the first of this month last year). These are
> passed to the expect script when it's run from within this perl script.
> (forgive me if there's a more "expecty" way of doing this, but I have
> limited resources and time so I did what I knew would work)
> 3) Run the expect script from within perl.

> Now here's the problem. It all works wonderfully when run from the
> command line. However, when I plug it into cron and execute it, the
> expect script goes into a completely different set of menus.

> Does anyone have any clue why (more importantly, how to fix it)?

> I've tried spawing the user's .profile file instead of the program
> directly. I would think this would set up the environment exactly the
> same as on the command line. I've tried disabling the auto run of the
> program in .profile and running .profile then the program.

> I've even tried telnetting into the system with the script (having it
> log in and do it's thing before logging out).

> I'm completely at a loss. I don't know enough expect to do anything
> extremely fancy. My code basically looks like the below example with a
> bunch more options to go into the appropriate menu and fill in
> parameters.

> Again, it works from the command line and NOT from cron. I don't know if
> I should blame AIX, expect, my script, or what. Is there a switch to
> spawn that maybe I missed. I've run through the man page for expect on a
> Linux box (remember no manpages work on the AIX box) and tried all of
> those that made sense to try (in my thinking). What else can I do?

> spawn /path/to/program

This doesn't sound like an Expect problem.  Rather, it sounds like the
spawned program is sensitive to the difference in the two environments
(interactive vs cron).  Since you have the source to the program of
interest (you said it's a perl script, right?), simply inspect it to
find out what conditions generate the other menus that you say you are
seeing.

Don



Sun, 09 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OS/2 REXX not behaving as I expect

2. begin/end doesn't behave as expected

3. os.execv does not behave as I expected ...

4. pipe to tclsh not behaving as expected

5. expect global match behaves inconsistent

6. namespace import/export not behaving as expected

7. Expect script behaves unpredictably

8. Expect on RedHat behaving inconsistantly

9. Expect not behaving predictably

10. expect + telnet hangs on AIX

11. AIX and expect

12. Using tcl and Expect in AIX

 

 
Powered by phpBB® Forum Software