LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   alternative to less with user input (http://www.linuxquestions.org/questions/programming-9/alternative-to-less-with-user-input-4175422798/)

ZetaNet 08-18-2012 03:07 PM

alternative to less with user input
 
I am doing a bash script that need to show a long long file with selections, i need something like less but with easyer search, horisontal scroll and (MAIN) user input for variable.

User input is really needed but does nothing to the list

NevemTeve 08-18-2012 04:33 PM

What 'user input' means when the user is reading a long file on the screen?

ZetaNet 08-18-2012 05:05 PM

Script opens a file.
User can scroll it, search in it and do stuff like that (something like less command)
And bottom line of console waits for user input
When user writes something, this something is saved as variable and and script continues

NevemTeve 08-19-2012 01:01 AM

Step 1: less/more/etc
Step 2: read

Note: external programs cannot modify their caller's environment, only built-in commands like read.

unSpawn 08-19-2012 09:07 AM

Quote:

Originally Posted by ZetaNet (Post 4757779)
I am doing a bash script that need to show a long long file with selections, i need something like less but with easyer search, horisontal scroll and (MAIN) user input for variable. User input is really needed but does nothing to the list

...or alternatively you could rethink your scripts flow. Breaking up choices and grouping them in one or more menu structures may make things easier for both programmer and user. (Re)structuring things is easier for some so if unsure you could show us some part of your "long long file with selections"?

pan64 08-19-2012 09:42 AM

I made a similar task using perl and the Pager module

theNbomr 08-19-2012 02:35 PM

Quote:

Originally Posted by ZetaNet (Post 4757870)
Script opens a file.
User can scroll it, search in it and do stuff like that (something like less command)
And bottom line of console waits for user input
When user writes something, this something is saved as variable and and script continues

Reading between the lines, I sense that you are expecting to have a child process (less, or whatever alternative you settle on) modify the environment ('saved as variable') of your script. This is not possible. This question comes up over and over again in these and other forums, in one form or another.
You will need to re-think your approach if the primary solution would involve what I suspect.

--- rod.

David the H. 08-20-2012 02:35 PM

Actually, it sounds to me more like he wants some kind of dialog where he can both display text and receive user input at the same time.

To which I respond, have look at the dialog command. I believe it can do something like that, perhaps with the --inputbox option?


All times are GMT -5. The time now is 01:00 AM.