Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

TCL scripting: errorInfo=integer value too large to represent

Shell Programming and Scripting


Tags
scripting, tcl, tcl regexp

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
Shaibal_bp Shaibal_bp is offline
Registered User
 
Join Date: Feb 2014
Last Activity: 19 April 2017, 9:58 AM EDT
Posts: 5
Thanks: 2
Thanked 1 Time in 1 Post
Code TCL scripting: errorInfo=integer value too large to represent

The username is of the format : 123456789110000-1234@something.com
With this below TCL procedure, I am trying add first and Sec Id and get third Id.
I checked in online compiler and it seems to work and add. However, when I am running this in my lab, I get error as "integer value too large to represent"

I alo tried removing the "int" from this line > $environ put New-Third [ expr int($FirstId+$SecId) ] to $environ put New-Third [ expr ($FirstId+$SecId) ] still error persists

TCL version: 8.5

Error
Code:
handleException: errMsg=integer value too large to represent; errorInfo=integer value too large to represent
    while executing
"expr int($FirstId+$SecId) "
    (procedure "disUser" line 11)
    invoked from within
"disUser $environ [ $request get User-Name ]"
    while executing
"expr int($FirstId+$SecId) "
    (procedure "disUser" line 11)
    invoked from within

Procedure
Code:
proc disUser { environ username } {
                if { [ regexp {^(\d{15})-(\d{1,4})@([a-zA-Z0-9\.\-]{1,50})$} $username dummy FirstId SecId Arn ] } {
                        $environ put New-First-Id $FirstId
                        $environ put New-Sec $SecId
                        ############Add the First and Sec Id to generate the Third
                        $environ put New-Third [ expr int($FirstId+$SecId) ] 
                        $environ put New-Arn $Arn   
                } else {
                        error "INVALID_USERNAME" \
                        "Source=[$environ get IP-Address];UserName=$username"
                }
        }


Moderator's Comments:
TCL scripting: errorInfo=integer value too large to represent
Please wrap all code, files, input & output/errors in CODE tags.
It makes them far easier to read and preserves multiple spaces for indenting or fixed-width data.

Last edited by rbatte1; 1 Week Ago at 08:59 AM.. Reason: Added CODE tags
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 27 April 2017, 5:09 PM EDT
Location: Aachen, Germany
Posts: 10,703
Thanks: 263
Thanked 3,284 Times in 3,025 Posts
Without any TCL knowledge, I guess that 123456789110000 really seems a bit large for integer representation (in any tool / language / system). If you just want to concatenate the two variables, make them strings. If you need to do math with them, try float representation.
Sponsored Links
    #3  
Old Unix and Linux 1 Week Ago
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is online now Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 27 April 2017, 9:57 PM EDT
Location: San Jose, CA, USA
Posts: 10,220
Thanks: 512
Thanked 3,546 Times in 3,019 Posts
Assuming that expr in the code you showed us is the expr utility (and not a tcl built-in), you could use bc or dc instead of expr.

It's been a long time since I've written any TCL code, but to see how to use bc in shell code, try:

Code:
$ x=$(echo 123456789110000 + 1234 | bc) 
$ echo $x
123456789111234
$ 

    #4  
Old Unix and Linux 1 Week Ago
drl's Unix or Linux Image
drl drl is offline Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 27 April 2017, 5:02 PM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,093
Thanks: 187
Thanked 374 Times in 326 Posts
Hi.

Noting that:
Quote:
int arg
The argument may be any numeric value. The integer part of arg is determined, and then the low order bits of that integer value up to the machine word size are returned as an integer value. For reference, the number of bytes in the machine word are stored in the wordSize element of the tcl_platform array.
mathfunc manual page - Tcl Mathematical Functions

Stripping the statements down to this:

Code:
#!/usr/bin/env tclsh

# @(#) tcl1     Demonstrate tclsh feature.

puts stdout ""
set version [ info tclversion ]
set message " Hello, world from tclsh ($version)"
puts stdout $message

set first 123456789110000
set next  1234

set sum [expr {$first+$next}]
puts " Sum of $first plus $next is $sum"

produces:

Code:
./tcl1

 Hello, world from tclsh (8.6)
 Sum of 123456789110000 plus 1234 is 123456789111234

On a system like:

Code:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.7 (jessie) 
tclsh 8.6

Best wishes ... cheers, drl

Last edited by drl; 1 Week Ago at 01:30 PM.. Reason: Correct minor typo
The Following User Says Thank You to drl For This Useful Post:
jim mcnamara (1 Week Ago)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
TCL scripting: errorInfo=integer value too large to represent Shaibal_bp Shell Programming and Scripting 1 1 Week Ago 08:56 AM
How to convert string into integer in shell scripting? deeptis Shell Programming and Scripting 2 04-12-2013 01:02 PM
how to compare string integer with an integer? h0ujun Shell Programming and Scripting 4 02-09-2012 10:05 AM
Scripting the process to edit a large file makkar4u Shell Programming and Scripting 5 01-19-2009 01:26 AM
expr: Integer argument too large iamgeethuj Shell Programming and Scripting 12 12-10-2008 05:08 AM



All times are GMT -4. The time now is 10:20 PM.