Sponsored Content
Full Discussion: 20th based convertor
Top Forums Shell Programming and Scripting 20th based convertor Post 302335261 by Dax01 on Saturday 18th of July 2009 03:15:02 AM
Old 07-18-2009
20th based convertor

Hi, I'm new at Linux shell programming so I could use some help. I need to make a 20thdecimal convertor. Is just like hexadecimal, the only difference is that hexadecimal goes from 1-9 and A-F, and I need this one to go from 1-9 and A-J.
I got some already but I get endless loop, please take a look.

Code:
echo -n "insert number to be converted: " 
read decimal 
 
until [ $decimal -eq 0 ] 
do 
div=`echo $decimal /20 | bc` 
res=`echo "$decimal-$div * 20" | bc` 
echo $res $div 
done

At this point I get the two number that I need, then I just add some labels to let it know that A= 11, B= 12, etc. The thing is I cannot stop the loopSmilieAny ideas aprecciated.

I used this Hexadecimal convertor as started and just changed the base from 16 (hexadecimal) to 20 (the one I desire) on lines 6,7.

Code:
echo -n "numbers to be converted: " 
read decimal 
 
while [ $decimal -gt 0 ] 
do 
div=`echo $decimal /16 | bc` 
res=`echo "$decimal-$div * 16" | bc` decimal=$div 
if [ $res -eq 10 ] ; then 
res=a 
if [ $res -eq 11 ] ; then 
res=b 
elif [ $res -lt 9 ] ; then 
res= $res 
fi 
hex= $res $div 
echo $hex


Last edited by DukeNuke2; 07-18-2009 at 04:19 AM.. Reason: added code tags
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to C convertor

Is there one out there that supports Perl/Tk ??? (5 Replies)
Discussion started by: perleo
5 Replies

2. Programming

Binary to Text Convertor

Hey Im starting out in C just recently and Im needing a string that converts binary to text, The only way i know of doing this without knowledge of C entirely. Is Making a sorta of library of the entire alphabet in binary for the program to select the text from it to display a sentence. If that... (2 Replies)
Discussion started by: 01doublehelix10
2 Replies

3. UNIX and Linux Applications

web to wap convertor

cld someone suggest a good web to wap convertor (1 Reply)
Discussion started by: viapillai
1 Replies

4. UNIX for Dummies Questions & Answers

Script ran by job scheduler fails from the 15th to the 20th of the month

Hi, I have a script that finds the application logs from the previous day and sends it to another server via ftp. The code is something like this: yest_date=`TZ=CST+24 date "+%b %d"` logdir=/app/logs logs=app*.log tmpdir=/tmp cd $logdir for i in `ls -1 $logs` do chkstr=`ls -1l $i | grep... (2 Replies)
Discussion started by: tatchel
2 Replies

5. Shell Programming and Scripting

Searching for bash to cshell convertor

Hi ,I have seen this comverters before ,but I was searching today and I can not find them .Is anybody used them before .Any recomendations Thanks (5 Replies)
Discussion started by: lio123
5 Replies
Mojo::Message::Response(3pm)				User Contributed Perl Documentation			      Mojo::Message::Response(3pm)

NAME
Mojo::Message::Response - HTTP 1.1 response container SYNOPSIS
use Mojo::Message::Response; # Parse my $res = Mojo::Message::Reponse->new; $res->parse("HTTP/1.0 200 OKx0ax0d"); $res->parse("Content-Length: 12x0ax0dx0ax0d"); $res->parse("Content-Type: text/plainx0ax0dx0ax0d"); $res->parse('Hello World!'); say $res->body; # Build my $res = Mojo::Message::Response->new; $res->code(200); $res->headers->content_type('text/plain'); $res->body('Hello World!'); say $res->to_string; DESCRIPTION
Mojo::Message::Response is a container for HTTP 1.1 responses as described in RFC 2616. EVENTS
Mojo::Message::Response inherits all events from Mojo::Message. ATTRIBUTES
Mojo::Message::Response inherits all attributes from Mojo::Message and implements the following new ones. "code" my $code = $res->code; $res = $res->code(200); HTTP response code. "message" my $message = $res->message; $res = $res->message('OK'); HTTP response message. METHODS
Mojo::Message::Response inherits all methods from Mojo::Message and implements the following new ones. "cookies" my $cookies = $res->cookies; $res = $res->cookies(Mojo::Cookie::Response->new); $res = $res->cookies({name => 'foo', value => 'bar'}); Access response cookies, usually Mojo::Cookie::Response objects. say $res->cookies->[1]->value; "default_message" my $message = $res->default_message; Generate default response message for code. "fix_headers" $res = $res->fix_headers; Make sure response has all required headers for the current HTTP version. "is_status_class" my $success = $res->is_status_class(200); Check response status class. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Message::Response(3pm)
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy