Can you explain me a tclsh file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can you explain me a tclsh file?
# 1  
Old 11-03-2008
Can you explain me a tclsh file?

Hello,

I got a file I am using, but I cannot understand what this file is doing...

Can someone explain?

Here is a part of the file:

Code:
#! /usr/bin/tclsh
set mctal [open mctal.[lindex $argv 0] r]
set pow [lindex $argv 1]
set SS [lindex $argv  2]
set a  [lindex $argv  3]
set b  [lindex $argv  4]
set c  [lindex $argv  5]
set d  [lindex $argv  6]
set e  [lindex $argv  7]
set f  [lindex $argv  8]
set g  [lindex $argv  9]
set h  [lindex $argv 10]
set i  [lindex $argv 11]
set j  [lindex $argv 12]
set k  [lindex $argv 13]
set l  [lindex $argv 14]
set m  [lindex $argv 15]
set n  [lindex $argv 16]
set o  [lindex $argv 17]
set p  [lindex $argv 18]
set q  [lindex $argv 19]
set r  [lindex $argv 20]
set s  [lindex $argv 21]
set t  [lindex $argv 22]
set u  [lindex $argv 23]
set c  [lindex $argv 24]
set v  [lindex $argv 25]
set w  [lindex $argv 26]
set x  [lindex $argv 27]
set y  [lindex $argv 28]
set z  [lindex $argv 29]
set aa  [lindex $argv 30]
set ab  [lindex $argv 31]
set ac  [lindex $argv 32]
set ad  [lindex $argv 33]
while {![regexp \^tally\ \*\($a\|$b|$c|$d|$e|$f|$g|$h|$i|$j|$k|$l|$m|$n|$o|$p|$q|$r|$s|$t|$u|$v|$w|$x|$y|$z|$aa|$ab|$ac|$ad\) [gets $mctal] line cell]} {
}
while {![regexp \^vals [gets $mctal] line]} {
}
regexp {^ *([0-9]\.[0-9]*[Ee][+-][0-9]*)} [gets $mctal] line $cell
...
[30 times the same sequence]
...
while {![regexp \^tally\ \*\($a\|$b|$c|$d|$e|$f|$g|$h|$i|$j|$k|$l|$m|$n|$o|$p|$q|$r|$s|$t|$u|$v|$w|$x|$y|$z|$aa|$ab|$ac|$ad\) [gets $mctal] line cell]} {
}
while {![regexp \^vals [gets $mctal] line]} {
}
regexp {^ *([0-9]\.[0-9]*[Ee][+-][0-9]*)} [gets $mctal] line $cell

eval set cella [expr $$a/($$a+$$b+$$c+$$d+$$e+$$f+$$g+$$h+$$i+$$j+$$k+$$l+$$m+$$n+$$o+$$p+$$q+$$r+$$s+$$t+$$u+$$v+$$w+$$x+$$y+$$z+$$aa+$$ab+$$ac+$$ad)]
eval set cellb [expr $$b/($$a+$$b+$$c+$$d+$$e+$$f+$$g+$$h+$$i+$$j+$$k+$$l+$$m+$$n+$$o+$$p+$$q+$$r+$$s+$$t+$$u+$$v+$$w+$$x+$$y+$$z+$$aa+$$ab+$$ac+$$ad)]
...
[30 times...]
...
eval set cellad [expr $$ad/($$a+$$b+$$c+$$d+$$e+$$f+$$g+$$h+$$i+$$j+$$k+$$l+$$m+$$n+$$o+$$p+$$q+$$r+$$s+$$t+$$u+$$v+$$w+$$x+$$y+$$z+$$aa+$$ab+$$ac+$$ad)]

close $mctal

exec sed -e "1,$ s/$pow/[expr $cella*$pow]/g" skele.$SS.a > skeleton.a
exec sed -e "1,$ s/$pow/[expr $cellb*$pow]/g" skele.$SS.b > skeleton.b

[30 times]

exec sed -e "1,$ s/$pow/[expr $cellac*$pow]/g" skele.$SS.ac > skeleton.ac
exec sed -e "1,$ s/$pow/[expr $cellad*$pow]/g" skele.$SS.ad > skeleton.ad

puts stdout "a = $cella"
puts stdout "b = $cellb"

[30 times]

puts stdout "ac = $cellac"
puts stdout "ad = $cellad"

I can understand the variable definition, the sed command and the output assigning, but not the regular expression part...

Thanks

Last edited by jolecanard; 11-03-2008 at 06:26 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain this logrotate file

Very silly question .. I deleted it .. Please delete this thread too . (0 Replies)
Discussion started by: stunn3r
0 Replies

2. Shell Programming and Scripting

passing arguments to unix command or script inside tclsh

hi everobody kindly consider the following in tclsh I understand that we can do the following %exec UnixCmd arg1 arg2 but if I assinged the arguments to a list insde tclsh how can I use them back i.e %set ArgList %exec UnixCmd %exec Unixcmd $list %exec all the... (1 Reply)
Discussion started by: Blue_shadow
1 Replies

3. Shell Programming and Scripting

need explain

Dear unix team i'm user for a system build on unix system ,so we need to run a lot of scripts not in one sission but every script on the associated terminal , so the script name = the name of the terminal which will run this script on it . and someone create a batch that make as below : 1- but... (4 Replies)
Discussion started by: fofatoti
4 Replies

4. Shell Programming and Scripting

exec tclsh

As a part of learning shell scripting I was just going through some already created scripts there I found- exec tclsh "$0" $(1+"$@") Here I was able to find what exec ,tclsh does & o/p of same but I could not find usage & output of $(1+"$@"). Can anybody pls expalain me usage details of it? (5 Replies)
Discussion started by: rediffmail
5 Replies

5. Programming

exec tclsh $(1+"$@")

As a part of learning shell scripting I was just going through some already created scripts there I found- exec tclsh "$0" $(1+"$@") Here I was able to find what exec ,tclsh does & o/p of same but I could not find usage & output of $(1+"$@"). Can anybody pls expalain me usage... (1 Reply)
Discussion started by: rediffmail
1 Replies

6. Homework & Coursework Questions

Could anyone help explain this?

1. The problem statement, all variables and given/known data: I have a retake assignment to complete for my computer networks and OS class. This isn't really my area, had I known last year I could have swapped it for a different module I would have done so. I'm determined to get through it... (6 Replies)
Discussion started by: Squall Moogle
6 Replies

7. Shell Programming and Scripting

How to set Field Separator for TCLSH??? :S

Hi, I am having a problem, with setting the FS in TCLSH, maybe someone knows the answer. I have a Tclsh/Tk script, and i´m trying to get all (only) the running processes for the given user like this: foreach process { puts stdout $process; } This also works, but... (2 Replies)
Discussion started by: laptop87
2 Replies

8. Shell Programming and Scripting

Forking with Tclsh vs Wish

Hello, I am new to this site, so sorry ahead of time if this is not the right place for this question.......anywhooooo I am having troubles with forking new processes in wish. Take the following code example: **************************** package require Tclx puts "TCL VER: " proc... (3 Replies)
Discussion started by: pghamami
3 Replies

9. Shell Programming and Scripting

tclsh

In bash wen we press tab the name of the files get completed automatically. Likewise there is no auto completion feature in tclsh. Any idea if there is any way to get this feature or should we implement ?? Please suggest (0 Replies)
Discussion started by: Laksmi
0 Replies

10. Shell Programming and Scripting

explain The file Contents

Hi folks, Can anyone of u expalin atleast one of the following contents of the file /etc/passwd I just to want to know how to comprehend it ..say vat does : signify or :: or :/ ?? root:x:0:0:Super-User:/rthome:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3::/:... (3 Replies)
Discussion started by: rajesh28
3 Replies
Login or Register to Ask a Question