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

scripting, tcl, tcl regexp

Thread Tools Search this Thread Display Modes
Old Unix and Linux 04-19-2017
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

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

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; 04-19-2017 at 08:59 AM.. Reason: Added CODE tags
Sponsored Links
Old Unix and Linux 04-19-2017
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 27 July 2017, 4:41 PM EDT
Location: Aachen, Germany
Posts: 11,067
Thanks: 284
Thanked 3,412 Times in 3,142 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
Old Unix and Linux 04-19-2017
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 23 July 2017, 6:19 PM EDT
Location: San Jose, CA, USA
Posts: 10,412
Thanks: 527
Thanked 3,638 Times in 3,104 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:

$ x=$(echo 123456789110000 + 1234 | bc) 
$ echo $x

Old Unix and Linux 04-19-2017
drl's Unix or Linux Image
drl drl is offline Forum Advisor  
Registered Voter
Join Date: Apr 2007
Last Activity: 28 July 2017, 10:15 AM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,140
Thanks: 211
Thanked 392 Times in 340 Posts

Noting that:
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:

#!/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"



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

On a system like:

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; 04-20-2017 at 01:30 PM.. Reason: Correct minor typo
The Following User Says Thank You to drl For This Useful Post:
jim mcnamara (04-19-2017)
Sponsored Links

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 04-19-2017 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:48 AM.