The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script to execute user command redtiger Shell Programming and Scripting 1 04-30-2008 07:53 PM
execute a command silently or quietly within a shell lumix Shell Programming and Scripting 4 12-15-2007 03:10 PM
pause needed for corn shell dennysavard UNIX for Dummies Questions & Answers 7 12-09-2007 02:16 PM
execute shell command in perlscript amitrajvarma Shell Programming and Scripting 0 11-27-2007 02:49 AM
Urgent!! How to write a shell program to execute command to access internet? firebirdonfire UNIX for Dummies Questions & Answers 2 04-26-2001 12:16 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
vbe,

Quote:
Originally Posted by vbe View Post
Maybe silly question :
Why "printf "Please ..."
All your other lines, you used echo...
That is to avoid the automatic line feed you get at the end of an echo. In other words he wants to read the user input on the same line as the prompt.

neruppu,

Did you try vbe's sh -x suggestion? What exactly happens, does it loop endlessly like this?

Code:
$ ./neruppu
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
...
  #2 (permalink)  
Old 07-04-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Quote:
Originally Posted by Annihilannic View Post
vbe,



That is to avoid the automatic line feed you get at the end of an echo. In other words he wants to read the user input on the same line as the prompt.

neruppu,

Did you try vbe's sh -x suggestion? What exactly happens, does it loop endlessly like this?

Code:
$ ./neruppu
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
Please enter a name : []
...


Nope but i try this solution,
exec 3<&0
while
...............
...............
read response <&3
...............
...............
done <$input


and i get the endlessly like u mention above...
  #3 (permalink)  
Old 07-04-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,576
>That is to avoid the automatic line feed you get at the end of an echo. In other words he wants to read the user input on the same line as the prompt.

But that can also be done with echo... (" \c" )

All the best
  #4 (permalink)  
Old 07-03-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Your code seems to work fine for me as well, both on Linux and HP-UX.

How are you actually running this script? In what shell and on what OS?
  #5 (permalink)  
Old 07-03-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Quote:
Originally Posted by Annihilannic View Post
Your code seems to work fine for me as well, both on Linux and HP-UX.

How are you actually running this script? In what shell and on what OS?
Im running in Putty, my local machine is window but the server is unix..

Using the shell : #!/bin/sh
  #6 (permalink)  
Old 07-04-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Ah! You never mentioned this <$input before! Are you trying to make things more challenging for us or something?? What is contained in $input anyway?

Try read -u3 response instead of read response <&3 if your OS supports it. You still haven't said which OS by the way...
  #7 (permalink)  
Old 07-04-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
I just find out that this problem is happen its enter the main loop command ....

while [ $temp_loop_condition -eq 0 ]
do
next_loop=0

printf "Testing1 " <- its cant pause and wait for user input
read re
....................
....................
....................
done






There is a possible solution for this problem?
Closed Thread

Bookmarks

Tags
linux, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0