Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-28-2009
wiseguy wiseguy is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 30 January 2009, 5:47 AM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo,

i need a Prompting read in my script:

Code:
read -p "Enter your command: " command

But i always get this Error:

Code:
-p: is not an identifier

When I run these in c-shell i get this error

Code:
/usr/bin/read[8]: read: bad option(s)

How can I use a Prompt in the read command?
Sponsored Links
    #2  
Old Unix and Linux 01-28-2009
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
What's your OS and shell? The -p (prompt) option is available only in bash AFAIK.
Sponsored Links
    #3  
Old Unix and Linux 01-28-2009
wiseguy wiseguy is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 30 January 2009, 5:47 AM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Okay, its a solaris 10

Quote:
The -p (prompt) option is available only in bash AFAIK
Is there any alternative possible, which allowes an input from keyboard and where I can use a prompt?
    #4  
Old Unix and Linux 01-28-2009
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
A (very) simple substitute would be
Code:
printf "Prompt: "
read command

Sponsored Links
    #5  
Old Unix and Linux 01-28-2009
wiseguy wiseguy is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 30 January 2009, 5:47 AM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
yes, thats what I have now. But i want to get this later: "prompt: _"
("_" is the cursor Linux)

I have to do many inputs and I want to "save" lines - so i want to have mor space on the screen - do you now what I mean?

[EDIT]
Sorry - I now realized that you wrote "printf" instad of "echo"... thats a good idea ;-)
Sponsored Links
    #6  
Old Unix and Linux 01-28-2009
wiseguy wiseguy is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 30 January 2009, 5:47 AM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
I have an other Problem with this read command:
(Even thats not a problem with read, I ask anyway in this thread)

When i make inputs (bechaue of a read command) I cant use curser direction (left oder right), or I want to make a backspace, I get some signes like this:
Backspace => ^?
left => ^[[D
right => ^[[C
Delete => ^[[3~
Pos1 => ^[[1~
End => ^[[4~

Can anybody tell me what I have to do in the script before the read command, that the user can use this keys, two?
Sponsored Links
    #7  
Old Unix and Linux 01-28-2009
NewBean NewBean is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 5 March 2009, 1:32 AM EST
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Try setting the variable

EDITOR=vi

and export it.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 12:52 AM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 03:15 AM
Use "read" with a text file with comments mbarberis Shell Programming and Scripting 3 03-30-2005 01:24 AM
Does "gzip" have a no prompt option on it for overwriting if file exists? LordJezo UNIX for Dummies Questions & Answers 1 07-29-2004 09:39 AM
how to request a "read" or "delivered" receipt for mails plelie2 Shell Programming and Scripting 1 08-06-2002 03:26 PM



All times are GMT -4. The time now is 02:22 PM.