stty error when script is called out of a cronjob

Hello,

I'm trying to implement a script to call a third-party tool every so often and write the results to a file. If I run it interactively it works fine, but when it comes to run it out of a cronjob, I keep getting this error:

stty: tcgetattr: a specified file does not support the ioctl system call

I need to call stty cols 132 so that the third-party tool works at all, otherwise I'd get: "display area must be at least 10 rows and 80 columns press <ctrl-d> to exit" written to my log file.

I have googled the error and people advise that cron does not have a terminal

Any suggestion on how to get the information out?

Here's the code

echo $dateout': Running spsmon now...' > $logfile
stty cols 132
spsmon -state Working > $tmpfile &
echo "PID of job put in backround = $!"
sleep 5
kill -9 $!
cat $tmpfile | awk 'BEGIN{RS=";";ORS="\n"} {print}' | awk '/Working/' | cut -c3-130 >> $logfile

Thanks Much

Well, they're right: You don't have a terminal, and that badly-programmed proprietary app apparently demand one even in batch mode. You'll have to fake the presence of a terminal somehow.

From here:

Unfortunately the relevant section isn't visible on Google Books...

Also, the expect language may be capable of this.

As a long shot, 'export COLUMNS=132' might be sufficient, maybe.

No guarantees but replacing the stty command could do the job.

export TERM=vt220
export COLUMNS=132

Hi,

I tried your suggestions and the script works now. I added the two lines just to be on the safe side and now it's working.

Thanks Corona688 and Methyl, much appreciated