stty error when script is called out of a cronjob


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stty error when script is called out of a cronjob
# 1  
Old 03-05-2010
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

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
# 2  
Old 03-05-2010
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:
Quote:
in the book "Adv. Programming
in the Unix environment" second edition,
on page 694 a program pty is described (source code), with can be used
to connect a programm to a pty, i.e. fake a terminal to the command.
The chapter clearifys a lot of pty/tty miracles to me.
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.

Last edited by Corona688; 03-05-2010 at 11:28 AM..
# 3  
Old 03-05-2010
No guarantees but replacing the stty command could do the job.

Code:
export TERM=vt220
export COLUMNS=132

# 4  
Old 03-05-2010
MySQL It worked!

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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

2. Shell Programming and Scripting

Use of stty vs trap in script-driven login menu

My employers would like me to selectively run one of several different (already-existing) Korn Shell menu-driven scripts out of the user's .profile file, depending on some yet-to-be-specified user critieria. I've never done this kind of thing, but I have the existing scripts (among other... (5 Replies)
Discussion started by: Clovis_Sangrail
5 Replies

3. Shell Programming and Scripting

stty: : I/O Error

Hi all, I am stuck on a shell script issue and need your inputs: I have a parent script A.ksh which call in another script B.ksh. At the start of the B.ksh, we export the .profile of another user and then call Informatica jobs. Issue When I run my jobs from the command prompt, it works... (1 Reply)
Discussion started by: fromrishi
1 Replies

4. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

5. Shell Programming and Scripting

Perl script with rsh gets stty invalid message

I have a Perl script, that does a system call with rsh to a remote machine. #!/usr/bin/env perl system ("rsh remote-machine echo 99"); And I get the following: stty: standard input: Invalid argument 99 I've tried replacing the system call with below, but I still get the same stty... (1 Reply)
Discussion started by: slchin
1 Replies

6. UNIX for Dummies Questions & Answers

stty: : Not a typewriter with AUTOSYS error

(sys10:pt:/pf>) cat 122974qqq.s RUNAS Version 2007.10.07 Run on Dec 11 2008 10:09:36 AM UNIX Process: 26021 Login User : root PFW User : s08280 Not a terminal stty: : Not a typewriter stty: : Not a typewriter ksh: jil: not found ksh: sendevent: not found... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

7. Shell Programming and Scripting

cronjob: Partial script error

Part of my script throws an error. Your "cron" job on mitv-t-voms02 /usr/tlrscr/runhc.sh produced the following output: /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found syntax error on line 1, teletype That part of... (2 Replies)
Discussion started by: sundar63
2 Replies

8. UNIX for Advanced & Expert Users

stty: error occurs when installing rpm

Hello All, when I install rpm rpm --install rpm packagename I got the following errors stty:standard input:invalid argument stty:standard input:invalid argument I dont know what i have to do exactly. I search on google for the same but not a particular standard solution is given... (17 Replies)
Discussion started by: amitpansuria
17 Replies

9. UNIX for Dummies Questions & Answers

expect and stty paths are different and resulting in error.

Hello, i am using expect to automate file transfers to and fro with a sftp server. below is the script i am creating and executing in the main program. but i am getting the following error: the main program that creates and runs this script looks for words like "not found" in... (6 Replies)
Discussion started by: The Nemi
6 Replies

10. UNIX for Advanced & Expert Users

stty erase in a script

does anyone know how to incorporate this in a script so users can actually make use of their backspace button that they've grown accustomed to? stty erase ^H --- this isn't working the script. works on command line but i wanna invoke it whenever this program of mine is run so users can use... (2 Replies)
Discussion started by: Terrible
2 Replies
Login or Register to Ask a Question