T4EA  AIG_19.2 C8891 A24697
Teamcenter Gateway for Enterprise Applications API Reference
CORE tcl enhancements in the T4x kernel

Functions

 rcwd
 This function returns the T4x installation path. More...
 
 source
 This function overloads the tcl function source. More...
 
 tpco_appendfile
 This function appends a string on a file. More...
 
 tpco_buildfilechecksum
 This function calculates a checksum for a file. More...
 
 tpco_clearbinstring
 This function replaces all characters that are smaller than 32 and larger than 128 by a fill-char. More...
 
 tpco_clearbinstring2
 This function replaces all characters that are larger than 128 and 0xA,0xD,0x9 by a fill-char. More...
 
 tpco_copyfile
 This function copies a file. More...
 
 tpco_createSNDID
 This function generates a ~unique~ ID 32Bit string. More...
 
 tpco_filedelete
 This function deletes a file. More...
 
 tpco_filediff
 This function compares the content of two files. More...
 
 tpco_fileexists
 This function checks if a file exists. More...
 
 tpco_fixstring
 This function fills a string with chars. More...
 
 tpco_ftimeinfo
 This function gets the time-info for a file. More...
 
 tpco_getHostName
 This function resolves the hostname via DNS. More...
 
 tpco_getHostName2
 This function resolves the hostname via DNS without the domainname. More...
 
 tpco_getpidname
 This function gets the process/image name from a PID. More...
 
 tpco_getprocessinfo
 This function gets the process list from the OS. Similar to "ps" (UNIX) or the "taskmanager" (Windows). More...
 
 tpco_getTPFSFile
 This function gets a file from a T4x server filessytem. More...
 
 tpco_H16Bin2File
 This function decodes a HEX16 string and writes the result into a file. More...
 
 tpco_httpClient
 This function is an http(s) client. More...
 
 tpco_isdirectory
 This function checks if a file is a directory. More...
 
 tpco_killpid
 This function kills a process. More...
 
 tpco_loadRFDT
 This function loads a RFDT file in the TCL cache. More...
 
 tpco_mkdir
 This function creates a directory. More...
 
 tpco_putTPFSFile
 This function puts a file from a local filesystem to the T4x server filessytem. More...
 
 tpco_readfile
 This function reads the content of a file. More...
 
 tpco_readfileb64
 This function reads the content of a file. More...
 
 tpco_readfileH16
 This function reads the content of a file. More...
 
 tpco_readflag
 This function reads a flag-file. More...
 
 tpco_renamefile
 This function renames a file. More...
 
 tpco_scandirectory
 This function scans a directory. More...
 
 tpco_str2entxml
 This function replaces all 'special' characters within a unicode string, i. e. all but decimals 0-9 and basic alphabet characters a-z and A-Z, with HTML hexadecimal characters of the form '�' and returns the resulting string. More...
 
 tpco_testipv6
 This function tests whether an IPv6 connection is possible. More...
 
 tpco_touchfile
 This function touches a file. More...
 
 tpco_urldecode
 URL-decodes a given string. More...
 
 tpco_urlencode
 URL-encodes a given string. More...
 
 tpco_usectime
 This function determines the time in microsecond resolution. More...
 
 tpco_usectime2int
 This function converts a 64BitHEX16 time (tpco_usectime) to integer. More...
 
 tpco_webfileinfo
 This function gets the size and time-info for a file. More...
 
 tpco_writeflag
 This function writes a flag-file. More...
 

Detailed Description

Function Documentation

◆ rcwd()

rcwd

This function returns the T4x installation path.

Returns
the T4x installation path
1 puts [rcwd]
2 
3 output:
4 /home/joerg/work/TR1491/tp_core_Linux_x86_64

◆ source()

source

This function overloads the tcl function source.

Parameters
filenamename of the tcl file
-relax(optional) evaluate the file from the tcl-cache (default= file system)
-debug(optional) include runtime debug information in the tcl-code
-nocerr(optional) suppress error messages
Returns
0= ok 1=error

◆ tpco_appendfile()

tpco_appendfile

This function appends a string on a file.

Parameters
filethe path+filename
valuethe append string
Returns
0= OK 1= ERROR
1 tpco_appendfile text.txt "hello world"

◆ tpco_buildfilechecksum()

tpco_buildfilechecksum

This function calculates a checksum for a file.

Parameters
file
Returns
the checksum
1 puts [tpco_buildfilechecksum pipeserver.tcl]
2 
3 output:
4 2f6d

◆ tpco_clearbinstring()

tpco_clearbinstring

This function replaces all characters that are smaller than 32 and larger than 128 by a fill-char.

Parameters
stringthe input string
fillchar(optional) fill char (default=.)
Returns
the new string
1 puts [tpco_clearbinstring Hello\nTest\rX]
2 Hello.Test.X
3 tpco_clearbinstring Hello\nTest\rX _
4 Hello_Test_X

◆ tpco_clearbinstring2()

tpco_clearbinstring2

This function replaces all characters that are larger than 128 and 0xA,0xD,0x9 by a fill-char.

Parameters
stringthe input string
fillchar(optional) fill char (default=.)
Returns
the new string
1 puts [tpco_clearbinstring2 Hello\nTest\tX]
2 Hello.Test.X
3 tpco_clearbinstring2 Hello\nTest\tX _
4 Hello_Test_X

◆ tpco_copyfile()

tpco_copyfile

This function copies a file.

Parameters
filethe path+filename
new-filethe new path+filename
Returns
0= OK != 0 ERROR
1 tpco_copyfile 9ada3e.sig 9ada3e.copy

◆ tpco_createSNDID()

tpco_createSNDID

This function generates a ~unique~ ID 32Bit string.

Returns
the id-string

Unique within one BGS/GS instance and amongst other things depending on time.

1 puts [tpco_createSNDID]
2 
3 output:
4 1406599169

◆ tpco_filedelete()

tpco_filedelete

This function deletes a file.

Parameters
filefilename
Returns
1= OK 0=can't delete
1 tpco_filedelete test.txt

◆ tpco_filediff()

tpco_filediff

This function compares the content of two files.

Parameters
file_athe first file
file_bthe second file
Returns
0= equal 1= diff
1 puts [tpco_filediff testa.xml testb.xml]
2 
3 output:
4 0

◆ tpco_fileexists()

tpco_fileexists

This function checks if a file exists.

Parameters
file
Returns
1= exists 0= not exists
1 puts [tpco_fileexists pipeserver.tcl]
2 
3 output:
4 1

◆ tpco_fixstring()

tpco_fixstring

This function fills a string with chars.

Parameters
stringthe input string
fillfill char
lengthoutput string length
Returns
the new string
1 puts [tpco_fixstring MYSTRING x 50]
2 puts [tpco_fixstring MYSTRING x 5]
3 
4 output:
5 MYSTRINGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
6 MYSTR

◆ tpco_ftimeinfo()

tpco_ftimeinfo

This function gets the time-info for a file.

Parameters
file
Returns
tcl list {atime mtime ctime} 1= ERROR
1 puts [tpco_ftimeinfo pipeserver.tcl]
2 
3 output:
4 1342589724 1342589722 1342589722

◆ tpco_getHostName()

tpco_getHostName

This function resolves the hostname via DNS.

Returns
the hostname
1 puts [tpco_getHostName]
2 
3 output:
4 nihil.tesis.de

◆ tpco_getHostName2()

tpco_getHostName2

This function resolves the hostname via DNS without the domainname.

Returns
the hostname
2 
3 output:
4 nihil

◆ tpco_getpidname()

tpco_getpidname

This function gets the process/image name from a PID.

Parameters
pidthe process pid
Returns
the process/image name
1 puts [tpco_getpidname 32373]
2 
3  output:
4  bash

◆ tpco_getprocessinfo()

tpco_getprocessinfo

This function gets the process list from the OS. Similar to "ps" (UNIX) or the "taskmanager" (Windows).

Returns
A tcl list (process list)
1 foreach ps [tpco_getprocessinfo] {
2  puts $ps
3  }
4 
5 output:
6 ...
7 11365 doxywizard 11290 0 49848320 751656960 1342422135 1 7 joerg joerg {doxywizard }
8 11385 firefox 1 0 103239680 778559488 1342422209 8 91 joerg joerg {/usr/lib/firefox/firefox /home/joerg/work/TR1491/trunk/tclsrc/ncdoc/.doxy/html/index.html }
9 11441 Thunar 1 0 22233088 1101709312 1342422331 1 19 joerg joerg {Thunar }
10 11488 gedit 1 0 55521280 618250240 1342422351 4 163 joerg joerg {gedit /home/joerg/work/TR1491/trunk/tclsrc/ncdoc/tpco_logging.tcl }
11 11605 chromium-browse 1 0 93696000 620494848 1342422912 16 92 joerg joerg {/usr/lib/chromium-browser/chromium-browser }
12 ...
13 
14 {
15  {PID ProcessName PPID ThreadCNT MemUsage VMemUsage StartTime(ctime) CpuUsage(System) CpuUsage(User) User Group Commandline}
16  {PID ProcessName PPID ThreadCNT MemUsage VMemUsage StartTime(ctime) CpuUsage(System) CpuUsage(User) User Group Commandline}
17  ...
18 }
Remarks
  • ThreadCNT works only with Windows. The value for UNIX/Linux is 0.
  • With Solaris and AIX only the first 80 chars of the commandline are used.

◆ tpco_getTPFSFile()

tpco_getTPFSFile

This function gets a file from a T4x server filessytem.

Parameters
handlethe session handle (see tpco_openSrvSession2)
source-filefile+path in the filesystem of the T4x server (~ is the root dir of the T4x server)
1 ~/tmp/test.xyz -> the file test.xyz in the tmp directory of the T4x server.
target-filefile+path in the local filesystem.
Returns
0= OK != 0 ERROR

Copy the ~/tmp/hello.script from the T4x server filesystem to the local filesystem ./tmp/hello.script.local

1 set hd [tpco_openSrvSession2 demo.example.com 11300 0 0 SOCKET IP6]
2 if {$hd >= 0} {
3  tpco_getTPFSFile $hd ~/tmp/hello.script ./tmp/hello.script.local
5  }

◆ tpco_H16Bin2File()

tpco_H16Bin2File

This function decodes a HEX16 string and writes the result into a file.

Parameters
filenamethe output filename
hex16stringthe input HEX16 string
Returns
0= OK 1=ERROR

◆ tpco_httpClient()

tpco_httpClient

This function is an http(s) client.

Parameters
-user(optional) username
-pass(optional) password
-debug(optional) log channel for debug messages
-proxy(optional) proxy host/ip:port
-agent(optional) change the client agent name
-cert(optional) full path to the server root certificate. This certificate is used to validate, the certificate sent by the server. The function expects a certificate in PEM format.
-clientcert(optional) full path to the client certificate. This certificate will be sent to the server and the server validates this certificate. The function expects a certificate in PEM format.
-exheader(optional) extended header list {name value name value ...}
-ctout(optional) connect time out (sec)
-tout(optional) set maximum time the request is allowed to take (sec)
-callback(optional) use a tcl callback function for download (GET) and handle the download data stream
-ctout(optional) client connection timeout (sec)
-tout(optional) set maximum time (sec) the request is allowed to take
-post/-put/-patch/-connect-get/-delete/-head/-options/ (optional(default get)) HTTP method -post value | -put value | -patch value | -connect server -get (optional / default) -delete / -head / -trace / -option
-H16(optional) return result HEX16 encoded
-HINFO(optional) return result and the HTTP response header [list <payload> <http-header>]
-keepalive(optinal) send keep alive probes every time specified in seconds (sec) 0=disabled
-followlocation(optinal) follow any Location if the response header that the server sends include a 3xx response. 0=disabled
urlservice URL
Returns
http(s) service result or exception
1 Plain http example
2 set val [tpco_httpClient -user t4adm -pass geheim http://t4sdeb.dev.tplocal:11300/pxml/perfticker]
3 puts $val
4 
5 TLS http example -- client accepts any server certificate
6 set val [tpco_httpClient -user t4adm -pass geheim https://t4sdeb.dev.tplocal:11310/pxml/perfticker]
7 puts $val
8 
9 TLS http example -- the client is checking the server certificate (one way ssl)
10 set val [tpco_httpClient -user t4adm -pass geheim -cert [rcwd]/var/conf/cert/root_apps.pem https://t4sdeb.dev.tplocal:11310/pxml/perfticker]
11 puts $val
12 
13 TLS http example -- the client is checking the server certificate and sends the client certificate to the server (two way ssl)
14 set val [tpco_httpClient -user t4adm -pass geheim -cert [rcwd]/var/conf/cert/root_apps.pem -clientcert [rcwd]/var/conf/cert/client_apps.pem https://t4sdeb.dev.tplocal:11310/pxml/perfticker]
15 puts $val
16 
17 output:
18 <?xml version="1.0"?>
19 <arguments>
20 <srvstat>
21 <cpuusage>0</cpuusage>
22 <queuesz>0</queuesz>
23 <appcnt>2643758</appcnt>
24 <httpdcnt>442469</httpdcnt>
25 <nativcnt>2212156</nativcnt>
26 <apperr>33489</apperr>
27 ...
28 
29 GET CALLBACK http example -- the client downloads the file download.bin from var/httpd/apps and handle the stream with an own
30 callback function cb
31 set ::cbhd [open [rcwd]/tmp/download.bin w]
32 proc cb { s } {
33  puts -nonewline $::cbhd [tpco_formatHEXIO $s]
34 }
35 set val [tpco_httpClient -user t4adm -pass geheim -tout 0 -callback cb http://t4sdeb.dev.tplocal:11300/download.bin]
36 close $::cbhd

◆ tpco_isdirectory()

tpco_isdirectory

This function checks if a file is a directory.

Parameters
filefilename
Returns
1= directory 0= other file
1 puts [tpco_isdirectory pipeserver.tcl]
2 
3 output:
4 0

◆ tpco_killpid()

tpco_killpid

This function kills a process.

Parameters
pidthe process pid
pnamethe process/image name
Returns
0= killed 1= not killed

◆ tpco_loadRFDT()

tpco_loadRFDT

This function loads a RFDT file in the TCL cache.

Parameters
filenamename of the RFDT file
-eval(optional) evaluate the tcl source at loadtime.
Returns
0= ok 1=error

◆ tpco_mkdir()

tpco_mkdir

This function creates a directory.

Parameters
directory
Returns
none
1 tpco_mkdir testdir

◆ tpco_putTPFSFile()

tpco_putTPFSFile

This function puts a file from a local filesystem to the T4x server filessytem.

Parameters
handlethe session handle (see tpco_openSrvSession2)
source-filefile+path in the local filesystem.
target-filefile+path in the filesystem of the T4x server (~ is the root dir of the T4x server)
1 ~/tmp/test.xyz -> the file test.xyz in the tmp directory of the T4x server.
Returns
0= OK != 0 ERROR

Copy the ./tmp/hello.script from the local filesystem to the T4x server filesystem ~/tmp/hello.script.remote

1 set hd [tpco_openSrvSession2 demo.example.com 11300 0 0 SOCKET IP6]
2 if {$hd >= 0} {
3  tpco_putTPFSFile $hd ./tmp/hello.script ~/tmp/hello.script.remote
5  }

◆ tpco_readfile()

tpco_readfile

This function reads the content of a file.

Parameters
filethe path+filename
Returns
the content of the file, 1=ERROR
1 set fc [tpco_readfile 9ada3e.sig]
2 puts $fc
3 
4 output:
5 set sign(HEADER:revision) {NAB}
6 set sign(HEADER:hostname) {nihil}
7 set sign(HEADER:cuser) {joerg}
8 set sign(HEADER:cplatform) {Linux_3.2.0-26-generic_x86_64}
9 ....

◆ tpco_readfileb64()

tpco_readfileb64

This function reads the content of a file.

Parameters
filethe path+filename
Returns
the content of the file as B64 string, 1=ERROR
1 set fc [tpco_readfileb64 9ada3e.sig]
2 puts $fc
3 
4 output:
5 c2V0IHNpZ24oSEVBREVSOnJldmlzaW9uKSAge05BQn0Kc2V0IHNpZ24oSEVBREVSOmhvc3RuYW1lKSAge25paGlsfQpzZXQgc2lnbihIRUFERVI6Y3VzZXIp ...

◆ tpco_readfileH16()

tpco_readfileH16

This function reads the content of a file.

Parameters
filethe path+filename
Returns
the content of the file as HEX16 string, 1=ERROR
1 set fc [tpco_readfileH16 9ada3e.sig]
2 puts $fc
3 
4 output:
5 736574207369676e284845414445523a7265766973696f6e2920207b4e41427d0a736574207369676e284845414445523a686f73746e616d652920 ...

◆ tpco_readflag()

tpco_readflag

This function reads a flag-file.

Parameters
filethe path+name of the flag-file
Returns
the content aof the flag-file 1=ERROR
1 tpco_readflag test.flag
2 
3 output:
4 status=OK

◆ tpco_renamefile()

tpco_renamefile

This function renames a file.

Parameters
filethe path+filename
new-namethe new filename
Returns
0= OK 1= ERROR
1 tpco_renamefile text.txt text.lst

◆ tpco_scandirectory()

tpco_scandirectory

This function scans a directory.

Parameters
dirnamethe path to the directory
patterntcl string pattern for all results
typef= files only d= directorys only x= all files
Returns
tcl list of all filename in the directory, 1= ERROR
1 puts [tpco_scandirectory var/httpd *.html x]
2 
3 output:
4 {var/httpd/index.html} {var/httpd/ubajodet.html} {var/httpd/utranslog.html}

◆ tpco_str2entxml()

tpco_str2entxml

This function replaces all 'special' characters within a unicode string, i. e. all but decimals 0-9 and basic alphabet characters a-z and A-Z, with HTML hexadecimal characters of the form '&#x00;' and returns the resulting string.

Parameters
stringunicode string
Returns
the converted string

◆ tpco_testipv6()

tpco_testipv6

This function tests whether an IPv6 connection is possible.

Returns
1= IPv6 is possible 0= no IPv6
1 puts [tpco_testipv6]
2 
3 output:
4 1

◆ tpco_touchfile()

tpco_touchfile

This function touches a file.

Parameters
file
Returns
none
1 tpco_touchfile pipeserver.tcl

◆ tpco_urldecode()

tpco_urldecode

URL-decodes a given string.

Parameters
inputinput string
Returns
url-decoded string
1 tpshell:
2 % tpco_urldecode "test%20me"
3 test me

◆ tpco_urlencode()

tpco_urlencode

URL-encodes a given string.

Parameters
inputinput string
Returns
url-encoded string
1 tpshell:
2 % tpco_urlencode "test me"
3 test%20me

◆ tpco_usectime()

tpco_usectime

This function determines the time in microsecond resolution.

Returns
A 64Bit HEX16 value (32Bit ctime 32Bit microseconds)
2 
3 output:
4 92020450ad1f0900

◆ tpco_usectime2int()

tpco_usectime2int

This function converts a 64BitHEX16 time (tpco_usectime) to integer.

Parameters
usechexa 64BitHEX16 time string
Returns
A tcl list { ctime microseconds }
1 set ut [tpco_usectime2int 92020450ad1f0900]
2 puts [clock format [lindex $ut 0] -format {%Y-%m-%d %H:%M:%S}].[lindex $ut 1]
3 
4 output:
5 2012-07-16 14:01:22.597933

◆ tpco_webfileinfo()

tpco_webfileinfo

This function gets the size and time-info for a file.

Parameters
file
Returns
tcl list {size mtime} 1= ERROR
1 puts [tpco_webfileinfo pipeserver.tcl]
2 
3 output:
4 155 1342589722

◆ tpco_writeflag()

tpco_writeflag

This function writes a flag-file.

Parameters
filethe path+name of the flag-file
valuethe content of the flag-file
Returns
0= OK 1=can't write
1 tpco_writeflag test.flag "status=OK"