Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read -p returns "read: no query process" using korn shell ksh

Tags:

linux

ksh

created a simple shell file that contains this:

read -p ThePrompt TheSomthing
echo $TheSomething

Run it, and it returns

-ksh[1]: read: no query process

I've tried single quotes, double quotes around ThePrompt and the man page specifically says "-p" is to use a prompt but it is not working for me. Can anyone tell me what I'm doing wrong? Thanks!

like image 364
Andrew Grady Avatar asked Sep 14 '25 17:09

Andrew Grady


2 Answers

In Ksh you can use this format:

echo "ThePrompt\c" read TheSomthing echo $TheSomething

like image 137
user3437245 Avatar answered Sep 17 '25 20:09

user3437245


From the googled man page:

The -un and -p options cause input to be read from file descriptor n or the current co-process (see Co-Processes above for comments on this), respectively. If the -s option is used, input is saved to the history file.

To use a prompt, write this instead:

read TheSomething?'ThePrompt'
like image 20
abacabadabacaba Avatar answered Sep 17 '25 21:09

abacabadabacaba