Crontab and interactive script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crontab and interactive script
# 1  
Old 06-28-2011
Crontab and interactive script

Hi all,
I'm trying to execute from crontab a script that uses an interactive shell (swmml, Signalware MML Commands).

I think the problem is about the crontab environment which miss tty/console/terminal etc...

After many tryings and searches I didn't come to a solution.

The program is launched from crontab this way:
Code:
15 * * * * su - omniusr -c "swmml -e \'DISPLAY-PROCESS\'" > swmml_D_PROCESS.log 2>&1

I always get this error message in the logfile:
Quote:
ERROR: STDIN is a character special file
The code in swmml (which is a perl script) that cause the error is:

Code:
   if (-t STDIN) {
    } elsif (-p STDIN) {
        if (-B STDIN) {
            die 'STDIN is a binary file';
        } else {
            return 1;
        }
    } elsif (-S STDIN) {
        die 'STDIN is a socket';
    } elsif (-c STDIN) {
        die 'STDIN is a character special file';
    } elsif (-f STDIN) {
        if (-B STDIN) {
            die 'STDIN is a binary file';
        } else {
            return 1;
        }
    } else {
        die $baIlaIlI.' doesn\'t know what STDIN is';
    }

Does anybody has a suggestion for this issue?
How can I run such command from crontab?

Thanks for your help!!!
# 2  
Old 06-28-2011
Did you try to run the script "swmml" manually ?

If it is an interactive script, what input does it wait for ?

If you post only a part of the code and not the wholle code, we may miss some things.
# 3  
Old 06-28-2011
Sorry, I didn't explained very well.

Running from command line:
Code:
su - omniusr -c "swmml -e \'DISPLAY-PROCESS\'"

works fine and I get a list of processes and then back to the cli.

While when I run it from crontab I get:
Code:
ERROR: STDIN is a character special file

I say interactive because I didn't know how to call it ... to me it looks like a problem related to the crontab environment and the nature of the swmml script, which is interactive.

I'm not sure I can send the whole code ...

Thanks,
Evan
# 4  
Old 06-28-2011
1) When you run the script from the command line does the script ask any questions which require keyboard input?

2) When you run the script from the command line, what user are you? root? omniusr? other?

3) Is this a root cron?
This User Gave Thanks to methyl For This Post:
# 5  
Old 06-28-2011
Quote:
1) When you run the script from the command line does the script ask any questions which require keyboard input?
When I run this:
Code:
su - omniusr -c "swmml -e 'DISPLAY-PROCESS'"

from command line I just get some text and then back to cmd line.

Quote:
2) When you run the script from the command line, what user are you? root? omniusr? other?
I run the above command as root user

Quote:
3) Is this a root cron?
Yes I'm working from root crontab
# 6  
Old 06-28-2011
Maybe try making a cron version of the program and comment out the block of code which is testing STDIN.

It's unusual to issue "su - username" rather than "su username" from root cron. This is because the profile for the user may contain commands which are inappropriate for cron (e.g. stty commands). You'd normally create a script containing a preamble to set up a suitable environment to run the program (including a shebang line to get the right shell).
# 7  
Old 06-28-2011
@Evan ,

You missunderstood Methyl and I .

1) First do this :
Code:
su - omniusr

2) Now that you are user omniusr, run the script :
Code:
swmml -e 'DISPLAY-PROCESS'

3) Are you prompted by the script to manually enter some values ??? if so, which ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Interactive Shutdown script

Hello folks. I will start out by saying as far as unix/linux scripting goes I know less about it than i do about giving birth (I'm a guy hehe). I am looking to make a shutdown script that will either shut down the system or reboot it using one of the shutdown run methods IE init 2 - 5 or a base... (1 Reply)
Discussion started by: azurie
1 Replies

2. Shell Programming and Scripting

Interactive script with background

I have script, which need some variable from user and i use below command for this read this script works fine while running without background, but when i run this script in background, it ask first variable then immediately it show below error KSH variable not found please let me... (1 Reply)
Discussion started by: pallvi_mahajan
1 Replies

3. Shell Programming and Scripting

Non interactive su in bash script

Hi, I have a python gui which allow users entering the root password, then a bash script is called to run "su" with the root password on the background. I could find a way to run "su" with a password. How to run "su" in a bash script without password prompt? Thank you. (4 Replies)
Discussion started by: hce
4 Replies

4. Shell Programming and Scripting

Interactive script – if then

Hi, I am writing an interactive shell script (ksh) but I have no idea how I could make a condition on it : Variables : rep_config="${rep_tools}/_CONFIG" rep_config_old="${rep_config}/_PROTO_OLD" Here is the interactice part : lst_proto=$(cat... (2 Replies)
Discussion started by: Aswex
2 Replies

5. Shell Programming and Scripting

Interactive script

Greetings gurus I have this simple scripts #!/bin/bash find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" > data_schema find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" >> data_schema <data.schema awk '{print NR, "inVol=" $0, "setDt=4000",... (1 Reply)
Discussion started by: Marjan
1 Replies

6. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

7. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

8. Shell Programming and Scripting

Automating Interactive script

I have a script that will install software on all remote host. At the end of the script it starts the install.sh part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are... (7 Replies)
Discussion started by: soupbone38
7 Replies

9. Shell Programming and Scripting

script to non interactive mode

Gud morning everybody, I need small help form you people,Please advice me. I have a utility(adpatch) which takes 10-15 prompts, i want to automate this by calling this utility in shell script. Now my qiestion i want to run the script in non interactive mode. An example. $adpatch... (1 Reply)
Discussion started by: swetham.apps
1 Replies

10. Shell Programming and Scripting

Wrap Interactive Script

Does anyone know of a program to wrap an interactive script into an application..I tried using platypus but i want a utility to allow interactive scripts to be run in a stand-alone window to avoid .profile settings on multiple computers...platypus provides the option of a text window output but... (0 Replies)
Discussion started by: meskue
0 Replies
Login or Register to Ask a Question