Author Topic: bash shell programming  (Read 1393 times)

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
bash shell programming
« on: 18 December 2002, 11:15 »
Was playing around with tput in scripts tonight and thought somebody else may be interested in doing some text screen manipulation. Rather than using the tput command you can also use ANSI sequences, tput would be more portable on all the different terminal types but using echo and ANSI strings is a lot more efficient if your terminal is ANSI capable. Here's a simple little example I just created using ANSI:

http://voidmain.kicks-ass.net/files/c2f2c.bash
http://voidmain.kicks-ass.net/files/c2f2c.ksh

[ December 23, 2002: Message edited by: void main ]

Someone please remove this account. Thanks...

dbl221

  • Member
  • **
  • Posts: 253
  • Kudos: 0
bash shell programming
« Reply #1 on: 22 December 2002, 07:08 »
tput ???

never used it.  I cut and pasted your code from mozilla into gvim no problems at all.

------------------
colour chart for bash
-----------------
yes I did spell Colour correctly
--------------------------------
Code: [Select]

[ December 21, 2002: Message edited by: dbl221 ]

dbl221***Comp-Sys walking wounded

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
bash shell programming
« Reply #2 on: 22 December 2002, 07:14 »
I cleaned it up a little more and did a floating point version in ksh:

http://voidmain.kicks-ass.net/files/
Someone please remove this account. Thanks...

dbl221

  • Member
  • **
  • Posts: 253
  • Kudos: 0
bash shell programming
« Reply #3 on: 22 December 2002, 07:49 »
got to love ksh eh!

one little problem...when I enter 33 deg Centagrade it calculates to 297 deg Farenheight

33C is a nice warm summer day in southers Ontario..ok I know Texas is hot but 279...hmm

ps is that ksh93 of pdksh
dbl221***Comp-Sys walking wounded

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
bash shell programming
« Reply #4 on: 22 December 2002, 08:56 »
That's odd, when I run it it calculates to: 91.40F

pdksh must be f00ked up. It works fine with the "real" ksh93. Can you do floating point at all with pdksh? Maybe that's why I ditched it for the real one.

[ December 21, 2002: Message edited by: void main ]

Someone please remove this account. Thanks...

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
bash shell programming
« Reply #5 on: 22 December 2002, 10:08 »
voidmain your to smart, go bash your head on a wall.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
bash shell programming
« Reply #6 on: 22 December 2002, 10:23 »
Yep, just confirmed it. pdksh is brain dead and doesn't support floating point math. Get the real one. There is an RPM for it:

ftp://ftp.rpmfind.net/linux/contrib/libc6/i386/ksh93-2000.10.31.0-1.i386.rpm

or here:

http://www.kornshell.com/

[ December 22, 2002: Message edited by: void main ]

Someone please remove this account. Thanks...

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
bash shell programming
« Reply #7 on: 22 December 2002, 16:10 »
damn even MS basic supports floating point

KernelPanic

  • VIP
  • Member
  • ***
  • Posts: 1,878
  • Kudos: 222
bash shell programming
« Reply #8 on: 22 December 2002, 19:10 »
quote:
Originally posted by dbl221:
tput ???

never used it.  I cut and pasted your code from mozilla into gvim no problems at all.

------------------
colour chart for bash
-----------------
yes I did spell Colour correctly
--------------------------------
Code: [Select]

[ December 21, 2002: Message edited by: dbl221 ][/b]


You spelt colour correctly but not 'standard'  
Contains scenes of mild peril.

dbl221

  • Member
  • **
  • Posts: 253
  • Kudos: 0
bash shell programming
« Reply #9 on: 23 December 2002, 06:39 »
TUX said
quote:
You spelt colour correctly but not 'standard'  


In Canadian English it is "colour"
dbl221***Comp-Sys walking wounded

Doogee

  • VIP
  • Member
  • ***
  • Posts: 774
  • Kudos: 109
    • http://m-db.info
bash shell programming
« Reply #10 on: 23 December 2002, 21:17 »
he meant you spelt the word "standard" wrong, take a closer look.