Sponsored Content
Top Forums Shell Programming and Scripting Crontab and interactive script Post 302534632 by Evan on Tuesday 28th of June 2011 10:30:39 AM
Old 06-28-2011
Dear all,
it seems that today I can't explain myself very well.
Please forgive me and let me try one last time.
I'll try to start from the beginning:

#1
I need to retrieve some information with the following script:
Code:
swmml_D_PROCESS.sh
#!/usr/bin/bash
su - omniusr -c "swmml -e 'DISPLAY-PROCESS'" | /usr/bin/awk -F" " '{if ( $11 ==  "TRUE" || $11 == "FALSE" ) print $11,$3,$1}' > /tmp/swmml_D_PROCESS.tmp
chmod 777 /tmp/swmml_D_PROCESS.tmp

If I execute the script from command line (root user) it works fine and outputs something like the following:
Quote:
FALSE hostname SWCTRL
TRUE hostname iwf_SCMG
TRUE hostname iwf_TCMG
TRUE hostname iwf
FALSE hostname SWCTRL
#2
Now I want to launch the swmml_D_PROCESS.sh script in root's crontab:
Code:
15 * * * * /scripts/swmml_D_PROCESS.sh > /scripts/swmml_D_PROCESS.log 2>&1

#3
All I get from the above is the following swmml_D_PROCESS.log:
Quote:
ERROR: STDIN is a character special file
instead of the expected output (#1).

#4
Since the above didn't work I tryed to reduce at minimum the commands being executed, this lead to the "su - omniusr ...." in crontab, but no success.

#5
I tryed one more thing in crontab:
Code:
15 * * * * . /etc/profile; /scripts/swmml_D_PROCESS.sh > /scripts/swmml_D_PROCESS.log 2>&1

But nothing changed.

Please, let me know if I miss some informations.

Thanks to all of you for helping me Smilie

---------- Post updated at 04:30 PM ---------- Previous update was at 04:29 PM ----------

Bravo Skrynesaver!

Now that we made one step forward can anybody explain why if I launch the script from command line it works while if I put it in crontab it doesn't work?

Maybe something is missing from the crontab environment?

I cannot figure it out.

Thanks Skrynesaver!!!
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CRON(8) 						      System Manager's Manual							   CRON(8)

NAME
cron - daemon to execute scheduled commands (Vixie Cron) SYNOPSIS
cron DESCRIPTION
Cron should be started from /etc/rc or /etc/rc.local. It will return immediately, so you don't need to start it with '&'. Cron searches /var/spool/cron for crontab files which are named after accounts in /etc/passwd; crontabs found are loaded into memory. Cron also searches for /etc/crontab and the files in the /etc/cron.d/ directory, which are in a different format (see crontab(5)). Cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When execut- ing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists). Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Note that the Crontab(1) command updates the modtime of the spool directory whenever it changes a crontab. SEE ALSO
crontab(1), crontab(5) AUTHOR
Paul Vixie <paul@vix.com> 4th Berkeley Distribution 20 December 1993 CRON(8)
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy