Trapping Enter command !!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trapping Enter command !!
# 1  
Old 12-14-2008
Bug Trapping Enter command !!

Hi I have written a script which works well .. It's divided into a series of jobs one running after another

But on pressing the enter key the whole script goes haywire .. I want a way to trap this enter command and echo it as invalid input ..

Any suggestions highly appreciated...

Thanks Smilie
# 2  
Old 12-14-2008
"read answer" is they keyword. (waits for input)
--
Actual button/command I use:
read answer && host -t ns $answer | while read dom ns server; do dig +short $dom | echo $server "shows an IP of" `dig +short $dom` for $dom ; done | sort

hth.
# 3  
Old 12-14-2008
Quote:
Originally Posted by ultimatix
Hi I have written a script which works well .. It's divided into a series of jobs one running after another

But on pressing the enter key the whole script goes haywire .. I want a way to trap this enter command and echo it as invalid input ..

How do you get any input if the user doesn't press enter?

Do you mean: you have problems if the user presses enter without any other input? If so, just check that the user has entered something:

Code:
read x
case $x in
 "") echo "You must enter something"; exit 1 ;;
esac

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trapping the return status from FIND command

I have the following code in a script: find . \( ! -name . -prune \) -name "cg*" -exec cp -p {} "${temp_dir}" \; ret_stat=$? I think the return status is only captured for the 'find' command and not for the 'cp' command. Is there a way to get the return status for the 'cp' command... (7 Replies)
Discussion started by: vskr72
7 Replies

2. AIX

AIX: How to find down who enter a command?

Hi I'm working on AIX. My question: for example, I'm logging in. I enter command "last" and then I know there are 3 people logging in from 3 different IP at the same time, 2 are in the same account. Then someone enters a command. Is there any way to know exactly who ( which IP ) enters... (9 Replies)
Discussion started by: bobochacha29
9 Replies

3. UNIX for Advanced & Expert Users

Trapping a kill command sent to a script and using it to send an EOF to a subprocess before killing

I originally had a script written in pure shell that I used to parse logs in real time and create a pipe delimited file that only contained errors. It worked but it was using a lot of memory (still not clear on why). I originally got around this by writing a wrapper for the script that ran on cron... (1 Reply)
Discussion started by: DeCoTwc
1 Replies

4. Shell Programming and Scripting

Loop logic, enter into respective IF as per enter input file name

have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value File 1 export SERVER_CONNECTION=//dvlna002:10001/SmartServer File2 export SERVER_CONNECTION=///SmartServer File3 export... (1 Reply)
Discussion started by: Nsharma3006
1 Replies

5. Red Hat

How to create a command to enter into a dir?

Hi all, I want to create a command for entering into a specific dir. for eg if i want to go to /var/spool/postfix/pid at any point if i enter a command suppose "sp" in the command line it should take me to /var/spool/postfix/pid thanks (2 Replies)
Discussion started by: technoman
2 Replies

6. Shell Programming and Scripting

How to enter commands to the command prompt in a program

Hey, So I'm trying to write a program in unix to automate a process for my astrophysics research. Basically I want the program to prompt the user for some information and store the entered string of text as a variable. I know how to do this. This is where I need help: Now lets say I have a... (4 Replies)
Discussion started by: freemoniez
4 Replies

7. Shell Programming and Scripting

Enter the command to capture output--help

&& echo "PLEASE enter the command to capture output" || echo "Processing your command manual" x=$# echo $x while do while man $@ | read -r line do >$@.txt ... (1 Reply)
Discussion started by: rrd1986
1 Replies

8. HP-UX

command su : enter directly

Hi, a simple question : How can I sent user and password to the command su. I need this for a script, but the problem is the command su wait for the password. Thanks. (2 Replies)
Discussion started by: mvaquerm
2 Replies

9. Shell Programming and Scripting

Script 'Enter' Command. Newbie.

Hi, I have the following script which calls a program that asks for user input before progressing. I am new to scripting and this script was written by the previous admin. After $MERGE is executed the application associated with it needs user input - asks for 'Enter' to be pressed. At the... (2 Replies)
Discussion started by: gwhelan
2 Replies

10. HP-UX

Trapping the rm command in UNIX

Hi All, Whoever types rm in the command prompt I need to trap the username, the ip address,timestamp and the rm filename(which file they are removing) and write it to the log file. could anyone help me?. Advanced thanks Suma (1 Reply)
Discussion started by: sumas
1 Replies
Login or Register to Ask a Question