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

Hallo,

i need a Prompting read in my script:

read -p "Enter your command: " command

But i always get this Error:

-p: is not an identifier

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

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

How can I use a Prompt in the read command?

What's your OS and shell? The -p (prompt) option is available only in bash AFAIK.

Okay, its a solaris 10

Is there any alternative possible, which allowes an input from keyboard and where I can use a prompt?

A (very) simple substitute would be

printf "Prompt: "
read command

yes, thats what I have now. But i want to get this later: "prompt: "
("
" is the cursor :))

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 :wink:

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?

Try setting the variable

EDITOR=vi

and export it.

I mean when I run the script on the c-shell...

When I run "export EDITOR=vi" (under c-shell), I get the folllowing error:

export: Command not found.

"Normal" input (cursor keys, etc.) is usually handled by the Shell or the readline library. If your version of read doesn't support any of those it receives them as plain control characters as sent by your terminal (emulation). To set translations for those, use stty on the command line (eg. stty erase ^? to get backspace functionality (Note that ^? isn't two characters, but one, as output when you press backspace))

export is not a csh command. I think you use setenv in csh.