Operating System - HP-UX
1834058 Members
2628 Online
110063 Solutions
New Discussion

Re: Expect script cronjob tty problem

 
Craig A. Sharp
Super Advisor

Expect script cronjob tty problem

I am running an expect script from a cronjob. The script runs fine when run manually from a console but when run from cron, I get strange errors tty errors and the scrips fails.

The cronjob calls the expect script as follows:

su - is2prod -c /usr/local/bin/expect /home/is2prod/isbackup.exp

Here is what is happening when the expect script trys to run:

# tail -f isprod.log
ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter
(c)Copyright 1983-1997 Hewlett-Packard Co., All Rights Reserved.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
(c)Copyright 1980, 1984, 1986 Novell, Inc.
(c)Copyright 1986-1992 Sun Microsystems, Inc.
(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology
(c)Copyright 1989-1993 The Open Software Foundation, Inc.
(c)Copyright 1986 Digital Equipment Corp.
(c)Copyright 1990 Motorola, Inc.
(c)Copyright 1990, 1991, 1992 Cornell University
(c)Copyright 1989-1991 The University of Maryland
(c)Copyright 1988 Carnegie Mellon University
(c)Copyright 1991-1997 Mentat, Inc.
(c)Copyright 1996 Morning Star Technologies, Inc.
(c)Copyright 1996 Progressive Systems, Inc.
(c)Copyright 1997 Isogon Corporation


RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the U.S. Government is subject to
restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause in DFARS 252.227-7013.


Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304 U.S.A.

Rights for non-DOD U.S. Government Departments and Agencies are as set
forth in FAR 52.227-19(c)(1,2).
Not a terminal
stty: : Not a typewriter
stty: : Not a typewriter
logout Any ideas would be appreciated.

Thanks,

Craig
3 REPLIES 3
Darren Prior
Honored Contributor

Re: Expect script cronjob tty problem

Hi Craig,

Running su - is2prod will read the user's .profile - which probably contains stty settings and other things that require a tty. The way round it is to use su is2prod without the "-"; then ensure that any relevant parts of .profile are included in a script which is called before you run expect.

regards,

Darren.

PS: Please remember to assign points to people who have helped you - it rewards those that have spent time on solutions, and helps others determine useful answers.
Calm down. It's only ones and zeros...
Craig A. Sharp
Super Advisor

Re: Expect script cronjob tty problem

Expect spawns it own shell with:

spawn $env(SHELL)

If I set the env variables in the script prior to calling the expect script, would the above command spawn a new shell without the variables or would they remain set.
Darren Prior
Honored Contributor

Re: Expect script cronjob tty problem

I believe if you export them, they will be passed through the shell.

ie export MYDATABASE=/data1/blah

regards,

Darren.
Calm down. It's only ones and zeros...