LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 06-17-2011, 09:01 AM   #1
roekoe
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: 10
interface in shell (bash scripting)


Hello everyone,

I want to create an interface in bash just like the interface from Mysql in shell, with the borders around the text. I´ve tried to search on google but all it comes up with is how to make graphical user interfaces for scripts.

any help is appreciated.

Last edited by roekoe; 06-18-2011 at 08:08 AM. Reason: forgot to add a word
 
Old 06-17-2011, 09:09 AM   #2
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
I wrote a separate awk script to do this, which I often call from bash scripts as a command. It only draws one box layer around the text piped into it. If you want more, like a spreadsheet grid, maybe this would at least be a good starting example.
Code:
#!/usr/bin/gawk -f
BEGIN {
    w=1;
}
{
    a[NR]=$0;
    l=length($0);
    if(w<l)w=l;
}
END {
    b="";
    for(i=1;i<=w;++i)b=b "-";
    print "+-" b "-+";
    for(i=1;i<=NR;++i){
	m=a[i];
	for(j=length(m);j<w;++j)m=m " ";
	print "| " m " |";
    }
    print "+-" b "-+";
}
 
Old 06-17-2011, 09:52 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
This might not be exactly what you're looking for, but what about dialog (http://en.wikipedia.org/wiki/Dialog_(software))?
 
Old 06-18-2011, 08:11 AM   #4
roekoe
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Original Poster
Rep: Reputation: 10
Thanks for the information, now I got something to work with.
 
Old 06-19-2011, 10:08 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
This interesting use of ncurses might be of interest to you.
--- rod.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
My first bash at shell scripting (sorry...) Daws Linux - Newbie 5 03-21-2007 06:20 PM
BASH Shell Scripting tekmann33 Linux - General 4 02-08-2007 05:03 PM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
Help with I/O on bash shell scripting Dave6383 Programming 1 06-03-2004 05:24 PM
Bash Shell Scripting Help Tangerine Programming 6 05-06-2003 02:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:25 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration