Pressing enter and script still goes on


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pressing enter and script still goes on
# 1  
Old 10-10-2011
Pressing enter and script still goes on

i have a bash shell script and i press enter and the script still continues on? how do i stop this
# 2  
Old 10-10-2011
Depends what you're doing in the first place. Show your script and show the manner which you're running it.
# 3  
Old 10-10-2011
ok
Code:
read "enter case filename " testfile

ls testfile 2> /dev/null || exit (0 or 1 or 2)
echo "case file found"
cat case

basically they have to enter "case" and if they enter "testfile" it should display an error message(cant figure out how to do that) but then it should display contents of the case file if the user entered case

but i just press enter and it goes through the whole scriptSmilie

Last edited by Scott; 10-10-2011 at 04:15 PM.. Reason: Code tags
# 4  
Old 10-12-2011
First, read doesn't work like that.

Code:
printf "enter case filename "
read filename

Second, variables don't work that way.

Code:
ls $testfile 2> /dev/null

Third, exit doesn't work that way.

Code:
ls $testfile 2> /dev/null || exit 1

Fourth, there's much easier and more efficient ways to do this than ls.

Code:
printf "enter case filename "
read filename

[ -f "$filename" ] || exit 1
echo "Found $filename"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script termination without pressing Enter key[nohup]

I have a script in which we have used nohup. Once script is executed it will be terminated only when enter key is pressed. I want the script to be terminated without pressing enter key nohup imqbrokerd -name user_id port 2>1 1>$home_`date` & I am a newbie to shell, Kindly please help (3 Replies)
Discussion started by: Suganbabu
3 Replies

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

3. Shell Programming and Scripting

Perl - start search by using search button or by pressing the enter key

#Build label and text box $main->Label( -text => "Input string below:" )->pack(); $main->Entry( -textvariable => \$text456 )->pack(); $main->Button( -text => "Search", -command => sub { errchk ($text456) ... (4 Replies)
Discussion started by: popeye
4 Replies

4. Shell Programming and Scripting

Want to write a command that keeps pressing enter key in regular interval

Hi, I m new to linux, can you pls help me to write a command/ script that keeps pressing the enter key in regular interval. Thx, Linux1 (2 Replies)
Discussion started by: mylinux1
2 Replies

5. Shell Programming and Scripting

Script to automatically enter a password

I need to retrieve thousands of lines of information from hundreds of nodes. Each node requires a passowrd in order to retrieve the information. Fortunately, the password is the same for each one of them. So I am trying to come up with a script that would allow me to include the password so I can... (0 Replies)
Discussion started by: Ernst
0 Replies

6. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies

7. Red Hat

su - root , without pressing password

Dear Friends , I want to su the root user from a normal user without pressing any password , is it possible ? Like , oracle# su - root passwd : But here I want to directly enter as root user without pressing any password . I need it , because , I need to run a script where the... (7 Replies)
Discussion started by: shipon_97
7 Replies

8. Shell Programming and Scripting

Pressing Enter (bash)

Hey, I'm writing this BASH script, I recently started learning BASH after I did Java and I'm pretty new to the syntax. Anways, what I want to do is simple, I coudn't find the right information though: Let's say I make a : read -p "Press ENTER to go back to menu" choice ..... What is... (34 Replies)
Discussion started by: Yakuzan
34 Replies

9. UNIX for Advanced & Expert Users

using enter key in shell script

without pressing the enter key ..manually... how can we read the enter key ..from the shell script..so that the script termintes automatically. eg: telnet a.b.c.d xxxx now " how to read the enter key" tho terminate the script (1 Reply)
Discussion started by: bishweshwar
1 Replies

10. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
Login or Register to Ask a Question