How to run shell script in silent mode


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to run shell script in silent mode
# 1  
Old 12-03-2005
How to run shell script in silent mode

Hi,

I have a AIX shell script that normally runs in an interactive mode. Now there is a need to it in silent mode and take all default answers.

How do I do that?

Thanks.
# 2  
Old 12-04-2005
Running sliently - not interactively

Hi!

Try this idea;

If a script needs to test whether it is running in an interactive shell, it is simply a matter of finding whether the prompt variable, $PS1 is set. (If the user is being prompted for input, then the script needs to display a prompt.)
Code:
if [ -z $PS1 ] # what no prompt?
then
  # non-interactive;   ...
else
  # interactive;   ...
fi

There are other ideas there in this link: http://www.tldp.org/LDP/abs/html/intandnonint.html

One more is that if in background/foreground there is a tty-variable that is set or not set. You could also do something like put a special variable in "~./.profile" that shows that the user is online, eg: $PS1 above. (Just ideas: got no references or clearer ideas on these last ones!)

Hope that was helpful
GrahamB
# 3  
Old 12-04-2005
A Korn shell in interactive mode has the "-i" flag set, hence:

Code:
if [ $(print - "$-" | grep -c "i") -gt 0 ] ; then
     print - "shell is interactive"
else
     print - "shell is non-interactive"
fi

bakunin

Last edited by bakunin; 12-04-2005 at 09:00 PM..
# 4  
Old 12-04-2005
My two cents....

Code:
case $- in
   *i*) echo "Yay" ;;
   *  ) echo "Nay" ;;
esac

Cheers
ZB
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Run a script in silent mode

Hi All, I have a script which calls some other scripts.. When i run the parent script all the status messages are displaying on terminal. I want to know how to suppress dem... or run a script in silent mode Thanks, Firestar (4 Replies)
Discussion started by: firestar
4 Replies

3. Red Hat

identifying SU mode by shell script

the following bash script is not working in fedora-11 Could anyone help me please? #!/bin/bash if -ne 0];then echo " you are in root" else echo " you must be in root -su mode??" fi exit (2 Replies)
Discussion started by: Turtel
2 Replies

4. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

5. Shell Programming and Scripting

Script is not exiting from run mode.

Hi Folks. My script is not exiting after run though its working correctly please suggest. #!/bin/ksh trap '' HUP . /bin/functions config_env PATH=/bin:/usr/bin:/usr/local/bin:$EXEC_PATH:$ORACLE_HOME/bin MONTH=$(control_register month) YEAR=$(control_register year) DATE_NOW="Job... (1 Reply)
Discussion started by: Haque123
1 Replies

6. Shell Programming and Scripting

How to run cmds after changing to a new env (shell) in a shell script

Hi, I am using HP-UNIX. I have a requirement as below I have to change env twice like: cadenv <env> cadenv <env> ccm start -d /dbpath ccm tar -xvf *.tar ccm rcv .... mv *.tar BACKUP but after I do the first cadenv <env> , I am unable to execute any of the later commands . ... (6 Replies)
Discussion started by: charlei
6 Replies

7. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

8. Linux

Wine in silent mode

I want to run through wine the utorrent and I don't want the messages that are usually displayed in the console, so I use the following command wine utorrent.exe > /dev/null & but it doesn't seem to work. Especially the redirection of the messages to the /dev/null doesn't work at all. Do... (1 Reply)
Discussion started by: myle
1 Replies

9. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies
Login or Register to Ask a Question