Re: How to format the command output like MySQL output

2013-10-22 Thread Jonathan Dowland
On Mon, Oct 21, 2013 at 11:07:44AM -0400, Jerry Stuckle wrote:
 And how is busybox going to solve the op's problem?

The odds are he has it on the machine already, or can have it; if he
doesn't have it, it can replace some things he does (thus saving space
and memory); it can be compiled to have built in sh, awk and sed, so the
OP can make a choice between e.g. including awk and sacrificing
something else, relatively easily.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20131022131314.gc28...@bryant.redmars.org



Re: How to format the command output like MySQL output

2013-10-21 Thread Lars Noodén
On 21.10.2013 01:33, Shawn Wilson wrote:
 
 
 Lars Noodén lars.noo...@gmail.com wrote:
 On 20.10.2013 04:17, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote: [snip]
 I think it seems good like this, but I do not know how to
 make out it.(someone says awk, sed may help, but the
 environment does not permit it). Is there some libs or tools
 can help make output result good and elegent?
 [snip]
 
 Perl would be the next step up, but if awk is not allowed then
 perl certainly won't be.
 
 Regards, /Lars
 
 yes, the whole system size a extremely limited, so the only
 possible
 way
 is to find a suitable C lib to handle this.
 
 What a big task
 
 What about the PCRE library?
 
 http://www.pcre.org/
 
 That's written in C and gives you the power of perl's regular 
 expressions.
 
 
 We use libpcre in some projects and it might be useful but it does
 not give a perl compatible regex engine. It might have up to perl 4
 regex support but there might even be some missing features there
 too. So no, not the power of perl regex here.
 

Ok.  My mistake.  I see it in all kinds of package dependencies and
thought it was further along than it was.

Regards,
/Lars


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/5264c42f.3020...@gmail.com



Re: How to format the command output like MySQL output

2013-10-21 Thread Dan Ritter
On Sat, Oct 19, 2013 at 11:17:44PM -0400, Jerry Stuckle wrote:
 On 10/19/2013 9:17 PM, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote:
 [snip]
 I think it seems good like this, but I do not know how to make out
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
 [snip]
 
 Perl would be the next step up, but if awk is not allowed then perl
 certainly won't be.
 
 Regards,
 /Lars
 
 
 
 yes, the whole system size a extremely limited, so the only possible way
 is to find a suitable C lib to handle this.
 
 What a big task
 
 
 How do they expect you do to your job if they won't give you the
 necessary tools?

While that's a reasonable question to ask for most jobs, I
suspect that the poster is developing (or developing on) an
embedded system with extremely limited storage space.

-dsr-


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20131021112348.gy4...@randomstring.org



Re: How to format the command output like MySQL output

2013-10-21 Thread Jonathan Dowland
On Sat, Oct 19, 2013 at 08:54:25PM -0600, Bob Proulx wrote:
 Check out perl formats.

Great suggestion, it's a shame the user has (since) ruled out Perl.
Hardly anyone seems to discuss perl formats anymore ☺


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20131021120152.ga5...@bryant.redmars.org



Re: How to format the command output like MySQL output

2013-10-21 Thread Jerry Stuckle

On 10/21/2013 7:23 AM, Dan Ritter wrote:

On Sat, Oct 19, 2013 at 11:17:44PM -0400, Jerry Stuckle wrote:

On 10/19/2013 9:17 PM, 陶治江 wrote:

于 2013-10-20 0:53, Lars Noodén 写道:

On 19.10.2013 19:35, 陶治江 wrote:
[snip]

I think it seems good like this, but I do not know how to make out
it.(someone says awk, sed may help, but the environment does not
permit it). Is there some libs or tools can help make output result
good and elegent?

[snip]

Perl would be the next step up, but if awk is not allowed then perl
certainly won't be.

Regards,
/Lars




yes, the whole system size a extremely limited, so the only possible way
is to find a suitable C lib to handle this.

What a big task



How do they expect you do to your job if they won't give you the
necessary tools?


While that's a reasonable question to ask for most jobs, I
suspect that the poster is developing (or developing on) an
embedded system with extremely limited storage space.

-dsr-




That could be.  But if it's so limited he can't load AWK or SED, then he 
won't be able to load scripting languages.  He'll have to write 
something in C or a similarly compiled language.  But then it's also 
obvious from the question that he's not familiar enough with programming 
to know how to do it.


Also, SED is only about 52K and mawk about 95K (plus any necessary 
.so's, of course).  Even on embedded systems that isn't a lot.  If he's 
that tight, it's going to be hard to even get a C program in there.


And what's he going to do with something gets upgraded and needs more space?

P.S. Please do not CC me. I am subscribed to the list.

Jerry


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/526523e1.2040...@attglobal.net



Re: How to format the command output like MySQL output

2013-10-21 Thread shawn wilson
On Mon, Oct 21, 2013 at 8:01 AM, Jonathan Dowland j...@debian.org wrote:
 On Sat, Oct 19, 2013 at 08:54:25PM -0600, Bob Proulx wrote:
 Check out perl formats.

 Great suggestion, it's a shame the user has (since) ruled out Perl.
 Hardly anyone seems to discuss perl formats anymore ☺


I think most people prefer printf formatting vs formats. I think
you'll even find some in the perl community that think formats ended
up being a bad idea (something stuck in a real long time ago - ~20
years ago now probably - that can't be removed). Ask on irc if you're
interrested.

printf is pretty portable and I've only seen perl formats in code once
or twice and never used them. FWIW.


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/cah_obicdjs2v+3ilthvryghmkwbcs1qor-0s6bbw+mayg8d...@mail.gmail.com



Re: How to format the command output like MySQL output

2013-10-21 Thread John Hasler
Jerry Stuckle writes:
 But if it's so limited he can't load AWK or SED, then he won't be able
 to load scripting languages.  He'll have to write something in C or a
 similarly compiled language.

That's what busybox is for.  He can modify it to add features he needs
and remove those he doesn't.  Much easier than writing an interpreter
from scratch.
-- 
John Hasler 
jhas...@newsguy.com
Elmwood, WI USA


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/87li1mk98c@thumper.dhh.gt.org



Re: How to format the command output like MySQL output

2013-10-21 Thread Jerry Stuckle

On 10/21/2013 10:08 AM, John Hasler wrote:

Jerry Stuckle writes:

But if it's so limited he can't load AWK or SED, then he won't be able
to load scripting languages.  He'll have to write something in C or a
similarly compiled language.


That's what busybox is for.  He can modify it to add features he needs
and remove those he doesn't.  Much easier than writing an interpreter
from scratch.



And how is busybox going to solve the op's problem?

Jerry


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/52654340.4060...@attglobal.net



Re: How to format the command output like MySQL output

2013-10-21 Thread Joel Rees
On Mon, Oct 21, 2013 at 8:23 PM, Dan Ritter d...@randomstring.org wrote:
 On Sat, Oct 19, 2013 at 11:17:44PM -0400, Jerry Stuckle wrote:
 On 10/19/2013 9:17 PM, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote:
 [snip]
 I think it seems good like this, but I do not know how to make out
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
 [snip]
 
 Perl would be the next step up, but if awk is not allowed then perl
 certainly won't be.
 
 Regards,
 /Lars
 
 
 
 yes, the whole system size a extremely limited, so the only possible way
 is to find a suitable C lib to handle this.
 
 What a big task
 

 How do they expect you do to your job if they won't give you the
 necessary tools?

 While that's a reasonable question to ask for most jobs, I
 suspect that the poster is developing (or developing on) an
 embedded system with extremely limited storage space.

 -dsr-

Yeah, the format he showed looks like the target might even use 16 bit
addressing. About the only 16 bit CPU I know of that can run anything
close to Linux is the 6809. Cross developing, maybe?

Of course, it might also be that some shared memory device he's
querying uses a 64Kbyte buffer.

--
Joel Rees

Be careful where you see conspiracy.
Look first in your own heart.


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/caar43iod-o9q0hu1dx-djux9h5acz_0fmruuvhf8b1k7dz8...@mail.gmail.com



Re: How to format the command output like MySQL output

2013-10-20 Thread Linux-Fan
On 10/20/2013 03:17 AM, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote:
 [snip]
 I think it seems good like this, but I do not know how to make out
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
 [snip]

 Perl would be the next step up, but if awk is not allowed then perl
 certainly won't be.

 Regards,
 /Lars


 
 yes, the whole system size a extremely limited, so the only possible way
 is to find a suitable C lib to handle this.
 
 What a big task

You could also port my Java solution:
http://pastebin.com/AFuCaQuB

It is most simple but not yet configured to display the lines -- a
feature you might consider to add in order to get your described output.

Another option would be the use of C printf() statements.

HTH
Linux-Fan

-- 
http://masysma.ohost.de/



signature.asc
Description: OpenPGP digital signature


Re: How to format the command output like MySQL output

2013-10-20 Thread Lars Noodén
On 20.10.2013 04:17, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote:
 [snip]
 I think it seems good like this, but I do not know how to make out
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
 [snip]

 Perl would be the next step up, but if awk is not allowed then perl
 certainly won't be.

 Regards,
 /Lars
 
 yes, the whole system size a extremely limited, so the only possible way
 is to find a suitable C lib to handle this.
 
 What a big task

What about the PCRE library?

http://www.pcre.org/

That's written in C and gives you the power of perl's regular expressions.

Regards,
/Lars


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/52639636.60...@gmail.com



Re: How to format the command output like MySQL output

2013-10-20 Thread Joel Rees
On Sun, Oct 20, 2013 at 1:35 AM, 陶治江 taozhiji...@gmail.com wrote:

 Hello everylinuxers:

 I am now focusing on the development of a script interpretor (some thing
 like shell)
 in embedded environment,

Okay, a shell-like programming language. Plenty of those, including
busybox, as John pointed out. Dash, which Debian uses during boot to
reduce the overhead bash would incur, would be another. You could look
at the source for those for inspiration.

But, ...

 and its functions mainly output the data in
 specified
 address.

For some reason, this does not sound to me like a general purpose
shell. Maybe something like a debugger? Or a tool for querying some
hardware device?

In order to make it seems better, I want to format the output
 result like
 MySQL output listed below for example

 ++-+
 |  address| value   |
 ++-+
 |  0x1110 | 0x01|
 ++-+
 |  0x | 0x00|
 ++-+

I think I did a shared memory query tool like this on a data
acquisition project a long time ago. But, ...

 I think it seems good like this, but I do not know how to make out
 it.(someone says awk,
 sed may help, but the environment does not permit it).

And, really, if you are familiar with printf(), the part you have
shown is dead simple.

 Is there some libs or
 tools can
 help make output result good and elegent?

The standard C library?

 Sorry to borther all of you, any info would be appreciated.

Promise me this isn't your homework, and I'll show you maybe three
printf() lines that will do as much as your output sample. Or,

man 3 printf

will get you started. And doing a web search on the string, printf
formatting will get a lot more information.

The query for this particular function shouldn't be hard either. The
hardest part would be picking the approach. Do you want to ask for the
address(es) interactively or do you want to take the addresses from
the command line, or both?

Shoot, if you don't mind postfix syntax, a nice FORTH interpreter
(which I can suggest a few to you) will get you a good start. Some
come in under 200k, including the full runtime execution environment.
More complete FORTHs, like gforth, have an executable object around
130K in debian, and run easily in a 1M or so of run-time. And, again,
the output you describe above is pretty straightforward formatting.

 --
 Thanks  Best Regrads!

 Nicol TAO (taozhijiang)

 Shenzhen, Guangdong Province, P.R. China 518055

 Being Stronger!!!

And remember to have fun!

--
Joel Rees

Be careful where you see conspiracy.
Look first in your own heart.


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAAr43iMedvfqto3GJWb1QmEWCvb2ZPqXqqJ-yEHkxE=rcly...@mail.gmail.com



Re: How to format the command output like MySQL output

2013-10-20 Thread Shawn Wilson


Lars Noodén lars.noo...@gmail.com wrote:
On 20.10.2013 04:17, 陶治江 wrote:
 于 2013-10-20 0:53, Lars Noodén 写道:
 On 19.10.2013 19:35, 陶治江 wrote:
 [snip]
 I think it seems good like this, but I do not know how to make out
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
 [snip]

 Perl would be the next step up, but if awk is not allowed then perl
 certainly won't be.

 Regards,
 /Lars
 
 yes, the whole system size a extremely limited, so the only possible
way
 is to find a suitable C lib to handle this.
 
 What a big task

What about the PCRE library?

   http://www.pcre.org/

That's written in C and gives you the power of perl's regular
expressions.


We use libpcre in some projects and it might be useful but it does not give a 
perl compatible regex engine. It might have up to perl 4 regex support but 
there might even be some missing features there too. So no, not the power of 
perl regex here. 


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/ffb2575f-ee7e-4d58-8b92-29d835c06...@email.android.com



How to format the command output like MySQL output

2013-10-19 Thread 陶治江


Hello everylinuxers:

I am now focusing on the development of a script interpretor (some thing 
like shell)
in embedded environment, and its functions mainly output the data in 
specified
address. In order to make it seems better, I want to format the output 
result like

MySQL output listed below for example

||++-+
|   address|  value  |
++-+|
|   0x1110|  0x01 |
++-+
|   0x  |  0x00  |
++-+|


I think it seems good like this, but I do not know how to make out 
it.(someone says awk,
sed may help, but the environment does not permit it). Is there some 
libs or tools can

help make output result good and elegent?


Sorry to borther all of you, any info would be appreciated.


--
/Thanks  Best Regrads! /

/Nicol TAO (taozhijiang)/

/Shenzhen, Guangdong Province, P.R. China 518055 /

/Being Stronger!!!/



Re: How to format the command output like MySQL output

2013-10-19 Thread Lars Noodén
On 19.10.2013 19:35, 陶治江 wrote:
[snip]
 I think it seems good like this, but I do not know how to make out 
 it.(someone says awk, sed may help, but the environment does not
 permit it). Is there some libs or tools can help make output result
 good and elegent?
[snip]

Perl would be the next step up, but if awk is not allowed then perl
certainly won't be.

Regards,
/Lars


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/5262b8f3.4030...@gmail.com



Re: How to format the command output like MySQL output

2013-10-19 Thread Slavko
Hi,

Dňa Sun, 20 Oct 2013 00:35:49 +0800 陶治江 taozhiji...@gmail.com
napísal:

 I think it seems good like this, but I do not know how to make out 
 it.(someone says awk,
 sed may help, but the environment does not permit it). Is there some 
 libs or tools can
 help make output result good and elegent?

python has some nice libraries.

regards

-- 
Slavko
http://slavino.sk


signature.asc
Description: PGP signature


Re: How to format the command output like MySQL output

2013-10-19 Thread 陶治江

于 2013-10-20 0:53, Lars Noodén 写道:

On 19.10.2013 19:35, 陶治江 wrote:
[snip]

I think it seems good like this, but I do not know how to make out
it.(someone says awk, sed may help, but the environment does not
permit it). Is there some libs or tools can help make output result
good and elegent?

[snip]

Perl would be the next step up, but if awk is not allowed then perl
certainly won't be.

Regards,
/Lars




yes, the whole system size a extremely limited, so the only possible way
is to find a suitable C lib to handle this.

What a big task

--
/Thanks  Best Regrads! /

/Nicol TAO (taozhijiang)/

/Shenzhen, Guangdong Province, P.R. China 518055 /

/Being Stronger!!!/



Re: How to format the command output like MySQL output

2013-10-19 Thread John Hasler
Hack on busybox.
-- 
John Hasler 
jhas...@newsguy.com
Elmwood, WI USA


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/87txgck9ok@thumper.dhh.gt.org



Re: How to format the command output like MySQL output

2013-10-19 Thread Bob Proulx
陶治江 wrote:
 I am now focusing on the development of a script interpretor (some
 thing like shell) in embedded environment, and its functions mainly
 output the data in specified address. In order to make it seems
 better, I want to format the output result like MySQL output listed
 below for example
 ...
 permit it). Is there some libs or tools can help make output result
 good and elegent?

Check out perl formats.

  man perlform

It was one of the original things that put the rl for report
language into perl.

Bob


signature.asc
Description: Digital signature


Re: How to format the command output like MySQL output

2013-10-19 Thread Miles Fidelman

陶治江 wrote:

于 2013-10-20 0:53, Lars Noodén 写道:

On 19.10.2013 19:35, 陶治江 wrote:
[snip]

I think it seems good like this, but I do not know how to make out
it.(someone says awk, sed may help, but the environment does not
permit it). Is there some libs or tools can help make output result
good and elegent?

[snip]

Perl would be the next step up, but if awk is not allowed then perl
certainly won't be.

Regards,
/Lars




yes, the whole system size a extremely limited, so the only possible way
is to find a suitable C lib to handle this.



Maybe a silly thought, but:  Since your model is MySQL output, maybe 
take a look at the MySQL source code and see how it's done there. 
There's actually a tour of the source code here: 
http://dev.mysql.com/doc/internals/en/guided-tour.html - which might 
help you find where that printing is done.


Just took a really quick look at the mysql client code (at 
http://bazaar.launchpad.net/~mysql/mysql-server/5.6/files/head:/client/) 
- and all I saw were printf statements.  Doesn't look like any fancy 
libraries or tools are being used.


Miles Fidelman

--
In theory, there is no difference between theory and practice.
In practice, there is.    Yogi Berra


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/52634724.4050...@meetinghouse.net



Re: How to format the command output like MySQL output

2013-10-19 Thread Jerry Stuckle

On 10/19/2013 9:17 PM, 陶治江 wrote:

于 2013-10-20 0:53, Lars Noodén 写道:

On 19.10.2013 19:35, 陶治江 wrote:
[snip]

I think it seems good like this, but I do not know how to make out
it.(someone says awk, sed may help, but the environment does not
permit it). Is there some libs or tools can help make output result
good and elegent?

[snip]

Perl would be the next step up, but if awk is not allowed then perl
certainly won't be.

Regards,
/Lars




yes, the whole system size a extremely limited, so the only possible way
is to find a suitable C lib to handle this.

What a big task

--
/Thanks  Best Regrads! /

/Nicol TAO (taozhijiang)/

/Shenzhen, Guangdong Province, P.R. China 518055 /

/Being Stronger!!!/



How do they expect you do to your job if they won't give you the 
necessary tools?


Jerry


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/52634b58.1050...@attglobal.net