LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-18-2012, 02:07 PM   #1
ZetaNet
LQ Newbie
 
Registered: Jun 2012
Posts: 13

Rep: Reputation: Disabled
Question 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
 
Old 08-18-2012, 03:33 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,460

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
What 'user input' means when the user is reading a long file on the screen?
 
Old 08-18-2012, 04:05 PM   #3
ZetaNet
LQ Newbie
 
Registered: Jun 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
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
 
Old 08-19-2012, 12:01 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,460

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
Step 1: less/more/etc
Step 2: read

Note: external programs cannot modify their caller's environment, only built-in commands like read.
 
Old 08-19-2012, 08:07 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,543
Blog Entries: 51

Rep: Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606Reputation: 2606
Quote:
Originally Posted by ZetaNet View Post
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"?
 
Old 08-19-2012, 08:42 AM   #6
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,010

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
I made a similar task using perl and the Pager module
 
Old 08-19-2012, 01:35 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
Quote:
Originally Posted by ZetaNet View Post
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.

Last edited by theNbomr; 08-19-2012 at 01:36 PM.
 
Old 08-20-2012, 01:35 PM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
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?
 
1 members found this post helpful.
  


Reply

Tags
bash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Looking for GUI alternative for new user michalng Debian 8 08-29-2011 06:39 AM
New Linux user here looking for XP alternative gchalifoux Linux - Newbie 10 04-25-2011 06:23 PM
User input into Bash scripts and checking validity of user input?? helptonewbie Programming 8 07-07-2008 06:40 PM
LXer: Alternative input devices under Linux LXer Syndicated Linux News 0 01-06-2006 10:46 PM


All times are GMT -5. The time now is 10:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration