TCL scripting: errorInfo=integer value too large to represent


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting TCL scripting: errorInfo=integer value too large to represent
# 1  
Old 04-19-2017
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:
Mod Comment
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 09:59 AM.. Reason: Added CODE tags
# 2  
Old 04-19-2017
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.
# 3  
Old 04-19-2017
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 04-19-2017
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; 04-20-2017 at 02:30 PM.. Reason: Correct minor typo
This User Gave Thanks to drl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: Shaibal_bp
1 Replies

2. Shell Programming and Scripting

How to convert string into integer in shell scripting?

Hi All, sessionid_remote=$(echo "select odb_sessionid from sysopendb where odb_dbname='syscdr';" | sudo -u cucluster ssh ucbu-aricent-vm93 "source /opt/cisco/connection/lib/connection.profile; $INFORMIXDIR/bin/dbaccess sysmaster@ciscounity") for sid in $sessionid_remote;do if * ]];... (2 Replies)
Discussion started by: deeptis
2 Replies

3. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

4. UNIX for Dummies Questions & Answers

What does $ represent in command prompt?

What does $ represent in command prompt? (2 Replies)
Discussion started by: ashok.g
2 Replies

5. Emergency UNIX and Linux Support

TCL scripting - searching for a IP address in a string

Hi All, Can anyone please help me with the regular expression/code snippet to search for an IP address in a string with Tcl scripting. Example string "OSPF_NBRUP OSPF neighbor 16.138.181.15 (realm ospf-v2 e1-0/0/0:37.0 area 0.0.0.0) state changed from Full to Down due to KillNbr" In the... (6 Replies)
Discussion started by: Mr. Zer0
6 Replies

6. Shell Programming and Scripting

Scripting the process to edit a large file

Hi, I need to make a script to edit a file. File is a large file in below format Version: 2008120101 ;$INCLUDE ./abc/xyz/Delhi ;$INCLUDE ./abc/xyz/London $INCLUDE ./abc/xyz/New York First line in the file is version number which is in year,month,date and serial number format. Each... (5 Replies)
Discussion started by: makkar4u
5 Replies

7. Shell Programming and Scripting

expr: Integer argument too large

Hi all, In KSH, I have got an error message like, "expr: Integer argument too large" I received this error message when I mutiply two large values and displaying the resultant output. Is there any other altenative way to go with too large values? Kindly let me know asap... Thanks in... (12 Replies)
Discussion started by: iamgeethuj
12 Replies

8. Solaris

Disk Representation - what is this c1t1d0s2 represent?

Hi All, Can you please advise what the 't' letters stands for? I understand the letter for the following "c1t1d0s2": c = disk Controller t = ? d = disk number ID. s = slice or partition of the disk Thanks (2 Replies)
Discussion started by: tlee
2 Replies

9. Shell Programming and Scripting

How to represent euro sign in unix

how should represent euro sign "€" in Unix (1 Reply)
Discussion started by: akash
1 Replies

10. Shell Programming and Scripting

What is $PROD ? Does it represent some Unix directory?

Hi , Could u tell me What is $PROD ? Does it represent some Unix directory? Regards Ashish Malviya (2 Replies)
Discussion started by: Ashishm
2 Replies
Login or Register to Ask a Question