f



How to open a pty from Tcl (or "please translate C example to Tcl")

Hello out there,
still struggling with getting TCP/IP to work in my somewhat bizarre
setup (TCP/IP over 10.000 Volt power-line modems) I got a hint to try
to use a pseudo tty. I got the advice
	---
What you would do is write a small C program (or perl, or any of a
number of other languages).  This program would call the "openpty"
function, which:
-  Locates the next available (unused) pseudo-TTY device in the
system,
-  Opens both ends of it, into two different descriptors,
-  Returns the file-descriptor numbers for the two ends (the "slave"
   end which mimics a tty, and the master end that your program will
   be using as the intercept point), and the filename of the slave
   (e.g. "/dev/ptya0").
 	---
Q1: Any way I could accomplish this from Tcl?


Well, knowing nothing about openpty and pseude ttys I hunted around
and found the following code snippet:
	---
/* 
 * Allocate pseudo tty, returns master side fd. 
 * Stores slave name in the first arg(must be large enough).
 */  
int pty_open(char *sl_name)
{
    int  mr_fd;

    char ptyname[] = "/dev/ptyXY";
    char ch[] = "pqrstuvwxyz";
    char digit[] = "0123456789abcdefghijklmnopqrstuv";
    int  l, m;

    /* This algorithm should work for almost all standard Unices */	
    for(l=0; ch[l]; l++ ) {
        for(m=0; digit[m]; m++ ) {
	 	ptyname[8] = ch[l];
		ptyname[9] = digit[m];
		/* Open the master */
		if( (mr_fd=open(ptyname, O_RDWR)) < 0 )
	 	   continue;
		/* Check the slave */
		ptyname[5] = 't';
		if( (access(ptyname, R_OK | W_OK)) < 0 ){
		   close(mr_fd);
		   ptyname[5] = 'p';
		   continue;
		}
		strcpy(sl_name,ptyname);
		return mr_fd;
	    }
	}
	return -1;
} 
	---
Now this looks like it could be easily mimicked in Tcl (where it not
for one small detail):
- The code tries out all pty's in ascending order of their names.
- If it can open one it "checks" (as per the comment above) the
corresponding 'tty' (by temporarily changing ptyXY to ttyXY) via a
call to 'access' on this tty - and here I'm lost. I don't know much
more about Linux than to boot it (needn't to - got Tcl).

Q2: What does 'access(<name of tty>, ...) do and how could I
accomplish the same from Tcl?

Q3: Any other way to get my hands on a pseudy tty from within Tcl?

Any links or hints most heartily welcomed - this project starts to
tear on my nerves a little bit. Best regards
Helmut Giese
0
hgiese (1076)
3/5/2005 9:57:58 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

3 Replies
773 Views

Similar Articles

[PageSpeed] 9

On the off chance that another Tcl'er might one day feel the urge for
a pseudo tty, here's the solution. By chance I found out that 'access'
is not just a function in a run time library but also available as
stand-alone program (at least on my SUSE 9.1 Linux).
	---
#
# Open a pseudo tty 
#
# On success returns a list <file descriptor to master / name of
slave>, else
# returns empty list
#
# The algorithm is modelled after the one found in pty_dev.c from 
#       VTun - Virtual Tunnel over TCP/IP network.
#       by Maxim Krasnyansky <max_mk@yahoo.com> 
#
proc ptyOpen {} {
    set ptyBase "/dev/pty"
    set ttyBase "/dev/tty"
    set chX     "abcdepqrstuvwxyz"  ;# check in /dev which letters
will fit
    set digit   "0123456789abcdef"

    # This algorithm should work for almost all standard Unices
    foreach ch [split $chX ""] {
        foreach dig [split $digit ""] {
            set ptyName ${ptyBase}${ch}${dig}
            # Open the master
            if { [catch {open $ptyName w+} masterFd] } {
                continue
            }
            # open successful: check the slave using 'access'
            set slvName ${ttyBase}${ch}${dig}
            if { [catch {exec access -rw $slvName}] } {
                # no
                close $masterFd
                continue;
            }
            # success
            return [list $masterFd $slvName]
        }
    }
    return [list]
}
	---
Have fun - probably in a somewhat bizarre set of circumstances ...
Helmut Giese
0
hgiese (1076)
3/6/2005 9:18:06 PM
The phrase "almost all standard Unices" is misleading as there is no
standard for pty access.  If you look at the pty allocation code in
Expect, you'll find that there are a LOT more cases to handle other
systems and all sorts of special circumstances, for example, if the
pty is uninitialized or wedged in to some odd state or ownership.

Don

hgiese@ratiosoft.com (Helmut Giese) writes:

> On the off chance that another Tcl'er might one day feel the urge for
> a pseudo tty, here's the solution. By chance I found out that 'access'
> is not just a function in a run time library but also available as
> stand-alone program (at least on my SUSE 9.1 Linux).
> 	---
> #
> # Open a pseudo tty 
> #
> # On success returns a list <file descriptor to master / name of
> slave>, else
> # returns empty list
> #
> # The algorithm is modelled after the one found in pty_dev.c from 
> #       VTun - Virtual Tunnel over TCP/IP network.
> #       by Maxim Krasnyansky <max_mk@yahoo.com> 
> #
> proc ptyOpen {} {
>     set ptyBase "/dev/pty"
>     set ttyBase "/dev/tty"
>     set chX     "abcdepqrstuvwxyz"  ;# check in /dev which letters
> will fit
>     set digit   "0123456789abcdef"
> 
>     # This algorithm should work for almost all standard Unices
>     foreach ch [split $chX ""] {
>         foreach dig [split $digit ""] {
>             set ptyName ${ptyBase}${ch}${dig}
>             # Open the master
>             if { [catch {open $ptyName w+} masterFd] } {
>                 continue
>             }
>             # open successful: check the slave using 'access'
>             set slvName ${ttyBase}${ch}${dig}
>             if { [catch {exec access -rw $slvName}] } {
>                 # no
>                 close $masterFd
>                 continue;
>             }
>             # success
>             return [list $masterFd $slvName]
>         }
>     }
>     return [list]
> }
> 	---
> Have fun - probably in a somewhat bizarre set of circumstances ...
> Helmut Giese
0
libes (272)
3/9/2005 6:36:59 PM
On 09 Mar 2005 13:36:59 -0500, Don Libes <libes@nist.gov> wrote:

>The phrase "almost all standard Unices" is misleading as there is no
>standard for pty access.  If you look at the pty allocation code in
>Expect, you'll find that there are a LOT more cases to handle other
>systems and all sorts of special circumstances, for example, if the
>pty is uninitialized or wedged in to some odd state or ownership.
>
Hi Don,
thanks for the clarification - others may find it helpful. This
comment was not strictly mine, it came from the original C sources.
Me, I wouldn't have _any_ opinion on any Unix whatsoever - being a
Windows man who currently happens to have the tough luck to tackle
rather low-level Linux questions.
Best regards
Helmut Giese
0
hgiese (1076)
3/9/2005 9:04:26 PM
Reply:

Similar Artilces:

"open with" tcl
hi, i just joined here today. have been reading and learning tcl/tk to help convert my VB6/MSwindows programs to tcl/tk on gnu/linux (debian , gnome). i have a tcl script that includes a text widget and menu and i can load, edit, save text files via the menu. but i would also like to start the tcl script and load a text file directly from the gnome file browser utility, using the "open with .... " option on the right mouse button. when i do "open with ...." and select the tcl script, the script starts up but the selected file does not load into the text widget. i understand that i'm missing a piece of the technology here, and any guidance would be appreciated. regards daveleo daveleo wrote: > hi, i just joined here today. > have been reading and learning tcl/tk to help convert my VB6/MSwindows > programs to tcl/tk on gnu/linux (debian , gnome). > > i have a tcl script that includes a text widget and menu and i can > load, edit, save text files via the menu. > but i would also like to start the tcl script and load a text file > directly from the gnome file browser utility, using the "open with .... > " option on the right mouse button. > > when i do "open with ...." and select the tcl script, the script > starts up but the selected file does not load into the text widget. You're going to have to figure out how Gnome is passing that information to your script. You could write a s...

calling "c" from TCL
Hello, To sum vectors i wrote a code like this; it is receiving 3 vectors data1, data2, data3. The diference between data1 and data2 is returned with Tcl_SetObjResult, but i would like modify data3, how can i modify data3?? Thanks #include <tcl.h> #include <iostream> using namespace std; int obj_vecsub(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[]); int obj_vecsub(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[]) { if (argc != 3) { Tcl_WrongNumArgs(interp, 1, objv, (char *)"?x? ?y?"); return TCL_ERROR; } int num1=0, num2=0, num3=0; Tcl_Obj **data1, **data2, **data3; if (Tcl_ListObjGetElements(interp, objv[1], &num1, &data1) != TCL_OK) return TCL_ERROR; if (Tcl_ListObjGetElements(interp, objv[2], &num2, &data2) != TCL_OK) return TCL_ERROR; if (Tcl_ListObjGetElements(interp, objv[3], &num2, &data3) != TCL_OK) return TCL_ERROR; if (num1 != num2) { Tcl_SetResult(interp, (char *)"vecsub: two vectors don't have the same size", TCL_STATIC); return TCL_ERROR; } Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL); Tcl_Obj *tcl_dummy = Tcl_NewListObj(0, NULL); for (int i=0; i<num1; i++) { double d1=0, d2=0, d3=77; if (Tcl_GetDoubleFromObj(interp, data1[i], &d1) != TCL_OK) { Tcl_SetResult(interp, (char *)"vecsub: non-numeric in first argument", TCL_STATIC); ret...

How to do PHP "require()" or TCL "source" in bash script
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone...

Windows "C" vs TCL sockets
Under windows 2000, I have a client server pair written in C that use the winsock library. I also have a client server pair written in TCL. The "C" pair happily communicate with one another. Likewise the TCL pair happily communicate with one another. My problem is that the "C" sockets are not able to connect with the TCL sockets. Is there a fundamental difference between TCL sockets and sockets created via a windows program or should I continue to stare at my code? The windows documentation talks about stream vs datagram sockets. Could that be the difference? "Paul Battersby" <batman42ca@yahoo.ca> wrote: >Under windows 2000, I have a client server pair written in C that use the >winsock library. I also have a client server pair written in TCL. The "C" >pair happily communicate with one another. Likewise the TCL pair happily >communicate with one another. > >My problem is that the "C" sockets are not able to connect with the TCL >sockets. Is there a fundamental difference between TCL sockets and sockets >created via a windows program or should I continue to stare at my code? > >The windows documentation talks about stream vs datagram sockets. Could that >be the difference? > Tcl only does TCP in stock form. Watch that the bound address of the server is on an interface that is routable to by the client. Sometimes this helps: set sock [socket -server -myaddr [info hostname]...

Looking for binary "expect" and "TCL/Tk" (if required) for OpenServer6
Does anybody know where to find "expect" (and related requirements) for OpenServer6? I can download the source files from nist.gov, but they do not compile. The MAN pages are already loaded on the system, so I suspect the programs would be on the distribution media somewhere. Any help would be appreciated. Thanks, Rick On 9 Feb, 17:57, Rick_Hoyle <motosl...@hotmail.com> wrote: > Does anybody know where to find "expect" (and related requirements) > for OpenServer6? I can download the source files from nist.gov, but > they do not compile. The MAN pages are al...

"::tcl::tm::UnknownHandler ::tclPkgUnknown msgcat 1.4" caused by replacing Tcl 8.4.1 with 8.5.7
In the blog http://planet.larrythecow.org/archives/2009-07-26.html "The Twouble with Tcl" Iain Buchanan shows that redefining OPEN proc leads to the errors similar to what I am getting - when I replaced Tcl 8.4.1 with Tcl 8.5.7. In my case I don't know the exact root cause though ... Any ideas how I should proceed with debugging this issue ? Thanks, Alex tclsh c:/Tornado/host/resource/hutils/tcl/makeSymTbl.tcl ppc tmp.o symTbl.c invalid command name "::tcl::tm::UnknownHandler" while executing "::tcl::tm::UnknownHandler ::tclPkgUnknown msg...

TCL "subshell"
Hi, I'm working on a kind of simulator /debugger application for some special multiprocessor hardware. The application has a number of TCL commands which the user can use to drive it. I'd like to implement breakpoints where the user can register TCL scripts to be executed when the breakpoint event is encountered. I really wanted to run these scripts in a "sub-shell" of the TCL environment which runs the main application. The reason for this is I want to provide a number of environment variables which can be accessed by the "subshell" but do not make sense int he main shell - for instance, the break point script could ask which process the breakpoint occured on, or the line number/file, ( there are a number of different things here which would only make sense to those involved in the development of the hardware). My first attempt was to use Tcl_CreateSlave(), but this doesnt "inherit" the commands from the main shell so doesn't work for me - in particular, the scripts registered for the breakpoints are not available in the slave. Does this "subshell" idea which makes sense in TCL or am I flogging a dead horse? dave In article <T66dnUaDisWokVXVnZ2dnUVZ_ofinZ2d@comcast.com>, CockneyWinker <datownsend@comcast.net> wrote: >Hi, > >I'm working on a kind of simulator /debugger application for some special >multiprocessor hardware. >The application has a number of TCL commands which ...

"Vectors" in tcl?
Hi all, What is my "best" alternative in handling vectors in Tcl? ("best" as in using a package available in ActiveTcl. I know about VecTcl, but...) I want to use a vector (potentially large, as in half a million boolean values). If this vector is created with all zeros, and I want to turn some of them (I have their indices as a tcl list) to 1. Right now I am using a tcl list, but I need to loop over this list, and set each one to 1. And I was wondering if there is a faster way (as in doing it with a single tcl command). I was looking at the the math:...

Using "source" vs "package require" for Tcl application files
I would like to divide my Tcl application into separate files. Should I generally use "source" to combine the files, or should I use the package mechanism (package provide, package require, etc.)? What is the generally accepted practice? Thanks, Gregg On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: > I would like to divide my Tcl application into separate files. Should I > generally use "source" to combine the files, or should I use the package > mechanism (package provide, package require, etc.)? > > What is the generally accepted practice? > > Thanks, > > Gregg IMHO use [source]. My reasoning: - The package mechanism is meant for getting access to general-purpose libraries, installed directly under the Tcl installation. - You talk of source files for your own application. So I would expect these files to reside in a directory containing that application. Then [source] is easier to use - and you guarantee that you get the source files from your application (otherwise a random package with the same name from the installation could interfer, if you are not careful with the library path) - Using [source] also makes it clear that these files are meant for your application only, not for more general purposes. Regards, Arjen Arjen Markus wrote: > On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: >> I would like to divide my Tcl application into separate files. Should I >> gen...

"?" in Tcl regexp
Any one can explain why I can not match the character "?" in Expect: expect -re "bala bala\?" Thanks, Dao "Dao" <youdao_du@hotmial.com> wrote in message news:bgt790$aca$1@zcars0v6.ca.nortel.com... > Any one can explain why I can not match the character "?" in Expect: > expect -re "bala bala\?" Backslash substitution in the quoted string is taking away the backslash for you; so the regexp you are using is "bala bala?" Put the string in braces instead of quotes. -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 mail: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. "Dao" <youdao_du@hotmial.com> wrote: # Any one can explain why I can not match the character "?" in Expect: # expect -re "bala bala\?" Because it does backslash substitution before passing into expect? You can try {bala bala\?} or "bala bala\\?". -- Derk Gwen http://derkgwen.250free.com/html/index.html What kind of convenience store do you run here? ...

["a", "b", "c", "d"] to "a, b, c, d"?
I want to process each element of an array, but the last element should be handled special. Here is an example: def p_ary(ary) str = "" ary.each do |elem| str << elem << ", " end str.chomp!(", ") str end so p_ary(["a", "f", "x", "test"]) produces "a, f, x, test". The code works, but isn't there an easier and more general way for this behaviour? martinus On Tue, 06 Apr 2004 04:23:22 -0700, Martin wrote: > I want to process each element of an array, but the last ele...

Using "Open with" in windows to process a file with a tcl/tk scripts?
I have the following problem in windows 2000. I have written a TCL/TK script which process xml files. Now I will like to be able select the xml file using the windows file manager and use "open with" to startup the tcl/tk scripts and pass the xml file as argument. When I do this now I get an error telling that the xml file is not a valid win32 application. Any ideas of how to do this? Thanks in advance Hello, You should enter something similar to: c:\path\to\wish.exe "C:\path\to\xmleditor.tcl" "%1" Regards, -- Ramon Rib� http://gatxan.cimne.upc.es/ramsan "Alfonso Esteban Gonzalez Sencion" <sencion@alcatel.es> escribi� en el mensaje news:1074693766.891577@slbhw0... > I have the following problem in windows 2000. > > I have written a TCL/TK script which process xml files. Now I will like > to be able select the xml file using the windows file manager and use > "open with" to startup the tcl/tk scripts and pass the xml file as argument. > > When I do this now I get an error telling that the xml file is not a > valid win32 application. > > Any ideas of how to do this? > > Thanks in advance > Hello I already do thins in the same way. I define a new action for the file type XML and it works fine. But I wish not to have to define manually a new action. What I would like to do is simply select the xml file, choose the option "open with" in the file m...

bug using TCL command "package require" embedded in C
Hello to all, I m trying to run serveral TCL commands inside C++ source code and when I show the information of the auto_path it is empty. If I put the same command in the tclsh interpreter it runs well. What Am I doing bad? in tclsh I insert: puts $auto_path puts hola package require Tk and runs well. my c souce code is the next: #include <tcl.h> #include <stdlib.h> int main(int argc, char**argv) { Tcl_Interp *interp; int status; char *comandos[] = { "puts $auto_path","set auto_path /usr/ lib/","puts $auto_path","auto_load","puts hola", "package require Tk", "package require clock", , "", NULL }; interp = Tcl_CreateInterp(); if (interp == NULL) { printf("can not create tcl interpreter\n"); exit(EXIT_FAILURE); } int i = 0; Tcl_Obj *obj; while (comandos[i] != NULL) { status = Tcl_Eval(interp, comandos[i]); if (interp->result[0] != 0) { printf("%s\n", interp->result); } i++; } return EXIT_SUCCESS; } The result of the execution is: can't read "auto_path": no such variable /usr/lib/ /usr/lib/ invalid command name "auto_load" hola can't find package Tk can't find package clock can't find package AglClient On 9 oct, 08:27, DCelso <dce...@gmail.com> wrote: > Hello to all, > I m trying to r...

[challenge] : can you invoke "copy a + b c" in tcl on WinXP ?
Hi all I've spent 30 min trying all the variations of eval / exec, trying to invoke a DOS classical "copy a+ b c" command froma tcl shell, with a and b containing spaces (you know, the genius who invented /Document and settings/). Well, if you can successfully invoke this command from a Tcl shell, I'm curious to see how you can do that. For now, I'm forced to merge files myself, using read/write in append mode. Although more portable, it's probably less efficient for large files. Thomas On Mar 6, 9:24=A0pm, Strykaas Van Basten <stryk...@gmail.com> wrote: > Hi all > > I've spent 30 min trying all the variations of eval / exec, trying to > invoke a DOS classical "copy a+ b c" command froma tcl shell, with a > and b containing spaces (you know, the genius who invented /Document > and settings/). > > Well, if you can successfully invoke this command from a Tcl shell, > I'm curious to see how you can do that. > > For now, I'm forced to merge files myself, using read/write in append > mode. Although more portable, it's probably less efficient for large > files. > > Thomas Getting exec to pass the correct quoting to cmd.exe can be a challenge. One simple workaround is to create a temporary batch file and execute that. See http://wiki.tcl.tk/16336 for some other ideas. Mark At Sun, 6 Mar 2011 12:24:28 -0800 (PST) Strykaas Van Basten <strykaas@gmail.com> wrote: > &...

Trouble with "Parsing C" (http://mini.net/tcl/3906)
Hello out there, I had a look at the "Scripted Comiler" project, especially "Parsing C" (http://mini.net/tcl/3906 and related pages), but I am unable to assemble the missing pieces. - At the page mentioned above is a parser generator. A self contained program which works like expected. - At "Lexing C" (http://mini.net/tcl/3891) you find the stuff to build a lexer for C. However, I don't see how the two are to be combined. If somebody knows of a script which combines the different pieces to parse the simplest "hello world" program, I'd be most grateful for a link. Best regards Helmut Giese hgiese@ratiosoft.com (Helmut Giese) writes: > Hello out there, > I had a look at the "Scripted Comiler" project, especially "Parsing C" > (http://mini.net/tcl/3906 and related pages), but I am unable to > assemble the missing pieces. > - At the page mentioned above is a parser generator. A self contained > program which works like expected. > - At "Lexing C" (http://mini.net/tcl/3891) you find the stuff to build > a lexer for C. > > However, I don't see how the two are to be combined. If somebody knows > of a script which combines the different pieces to parse the simplest > "hello world" program, I'd be most grateful for a link. Oh. I never wrote the code to combine the two into a whole. A simple way of doing this would be to do this in two phases. I.e.,...

What's wrong with strcpy/strcat in this "C for Tcl" experiment?
L.S. I'm doing some exercises in C for Tcl (still learning C). One thing I don't understand is why strcpy or strcat cause a segfault when loading the C-extension (see code below) into tclsh. When using the same calls to strcpy and strcat in a stand alone executable (not linked to Tcl), I do not stumble into this problem. Apparently, there is something wrong with the way that I combine these fuctions with Tcl. Could somebody please explain why strcpy or strcat cause problems in my code ? I've been using gcc on Linux and tcl8.4.5 Thanks in advance, Erik Leunissen ======================================= /* * strcpy.c experiment * */ #include <tclInt.h> int Strcpy_Init(Tcl_Interp *interp) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { return TCL_ERROR; } /* * Either call to str[cpy|cat] will cause a segmentation fault * when loading this "package" into tclsh. */ char *str; strcpy(str, "Hick "); // strcat(str, "up."); // printf("%s\n", str2); return TCL_OK; } /* EOF strcpy.c */ ======================================= -- leunissen@ nl | Merge the left part of these two lines into one, e. hccnet. | respecting a character's position in a line. David Gravereaux wrote: > > bogus space to write to probably as it points to nothingness. > > >> char *str; > > str = Tcl_Alloc(50); > >> strcpy(str, "Hick "...

l'C program executing from a tcl script with pipe opened using open command in Tcl
Hi all, I wanted to communicate with a C program from a Tcl script.. The test code i have written is below Both the 'C' program and Tcl script are located in the same directory. The 'C' program is below. I have named it CTCL.C #include<stdio.h> #include<string.h> int main() { int i; char c[30]; printf("Reading..."); scanf("%s",c); printf("String read is :%s\n",c); fflush(stdout); return 0; } I have compiled the program with the command cc CTCL.C -o ctcl So the executable was generated with the name 'ctcl' The Tcl script I have written is. I have named it TCLPIPETEST.tcl #!/usr/add-on/exptools/bin/tclsh set fd [open "|./ctcl" r+] gets $fd tmp1 puts "tmp1 = $tmp1" set stat 0 set tmp2 "Default value... " if { ![catch { puts $fd "abcdef" } res]} { if { ![catch { flush $fd } res] } { if { ![catch { gets $fd tmp2} res ] } { set stat 1 } else { puts "Error 'gets' from pipe : $res" } } else { puts "Error 'flush' from pipe:$res " } } else { puts "Error 'puts' from pipe:$res " } if { $stat == 1 } { puts "Success......:$tmp2 :)" } else { puts "Failure......:$tmp2 :(" } I have given all permissions for both the files above. When i execute the Tcl script My aim is to open a pipe with the 'C' executable 'ctcl', initially read so...

Opening a TCL program from within another TCL program in ANSYS Tcl-Tk
Hi everyone, I have been pulling my hair with this one for a couple of days and still have not found a fix. I'm working within ANSYS Tcl-Tk implementation. I created a Tcl-Tk script that generates a simple window with three buttons. Each button opens another window which is created in a separate Tcl file. The second window have a lot of text entries, variables, procedures, etc. I can open the second Tcl file by itself and everything works as supposed, but when I open it using the button in the first window, it opens but any procedure called by the widgets on the second window are not found... Here's the deal... Since I'm working within the ANSYS implementation of Tcl-Tk, I'm actually using an ANSYS command to open the second window. The command I use is: ### ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' ### It actually sends a command back to ANSYS telling it to execute a Tcl command... I know this is not pretty but its the only way i was able to make it at least show the window. ############################## #Main Tcl (excerpt): ############################## namespace eval Tools { proc IBRCambpell {} { #source O:/mad_projects_2/ANSYS/Macros/IBR_CAS.tcl ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ IBR_CAS.tcl' } proc viewManager {} { ans_sendcommand ~eui,'source O:/mad_projects_2/ANSYS/Macros/ ViewManager.tcl' } proc powerAnnotation {} { ans_sendcommand ~eui,'source ...

Tcl 8,5 tutorial errata on page "More Examples Of Regular Expressions"
Hi, In the Tcl 8.5 tutorial, a page titled "More Examples Of Regular Expressions" may contain errata in the following Tcl code: " set string "Again and again and again ..." if { [regexp {(\y\w+\y).+\1} $string => word] } { puts "The word $word occurs at least twice" } " You can see that the command 'regexp' sets a value into a variable called '=>'. This can be proved by executing the following code: " set string "Again and again and again ..." if { [regexp {(\y\w+\y).+\1} $string => word] } { puts "The word $word occurs at least twice" } upvar #0 "=>" x puts "$x" " I guess that the author meant to write something else? It doesn't make sense to have a variable named "=>". Here's a link to the relevant page in the tutorial: http://www.tcl.tk/man/tcl8.5/tutorial/Tcl20a.html Thank you. On Tuesday, 12 November 2013 08:43:08 UTC+11, dor...@gmail.com wrote: > Hi, >=20 >=20 >=20 > In the Tcl 8.5 tutorial, a page titled "More Examples Of Regular Expressi= ons" may contain errata in the following Tcl code: >=20 >=20 >=20 > " >=20 >=20 >=20 > set string "Again and again and again ..." >=20 > if { [regexp {(\y\w+\y).+\1} $string =3D> word] } { >=20 > puts "The word $word occurs at least twic...

tcl 8.5.2 gives error on runtime arg "-c"
Hi. I'm getting this error when launching a tcl script from a shell with "-c some_argument" with tcl 8.5.2 Application initialization failed: bad window path name "some_argument" I've searched the manpage and several documentation sources and have not found any restrictions over supplying runtime flag/arguments. Is this a bug or a hidden feature? dewuf wrote: > Hi. I'm getting this error when launching a tcl script from a shell > with "-c some_argument" with tcl 8.5.2 > > Application initialization failed: bad window path name > "some_argument" > > I've searched the manpage and several documentation sources and have > not found any restrictions over supplying runtime flag/arguments. Is > this a bug or a hidden feature? see http://www.tcl.tk/man/tcl8.5/UserCmd/wish.htm use a -- to prevent the interp from even looking at the options Bruce On Feb 9, 2:36=A0pm, Bruce Hartweg <Bruce-DoNot...@example.com> wrote: > dewuf wrote: > > Hi. =A0I'm getting this error when launching a tcl script from a shell > > with "-c some_argument" with tcl 8.5.2 > > > Application initialization failed: bad window path name > > "some_argument" > > > I've searched the manpage and several documentation sources and have > > not found any restrictions over supplying runtime flag/arguments. =A0Is > > this a bug or a hidden featu...

Intriguing reference to "TclDOM example directory" at http://wiki.tcl.tk/3895
I'm looking for examples of code involving parsing XML and/or HTML documents. In the 4th from last entry, Mr. Ball makes reference to "the TclDOM example directory". Where might I find that directory? TIA On Feb 15, 11:59=A0am, Richard Owlett <rowl...@pcnetinc.com> wrote: > In the 4th from last entry (of < http://wiki.tcl.tk/3895 >), Mr. Ball mak= es reference to "the > TclDOM example directory". > > Where might I find that directory? On http://wiki.tcl.tk/1407 , the same writer says: Version 2.5 of TclDOM adds a couple of new example scripts that may be useful: domtext: displays a DOM document in a Tk Text widget domtree: displays a DOM document's tree structure in a BWidget Tree widget. Version 3.0 includes the source script for tkxmllint (http:// tclxml.sourceforge.net/tkxmllint.html) application. Larry W. Virden wrote: > On Feb 15, 11:59 am, Richard Owlett <rowl...@pcnetinc.com> wrote: >> In the 4th from last entry (of < http://wiki.tcl.tk/3895 >), Mr. Ball makes reference to "the >> TclDOM example directory". >> >> Where might I find that directory? > > On http://wiki.tcl.tk/1407 , the same writer says: > Version 2.5 of TclDOM adds a couple of new example scripts that may be > useful: > domtext: displays a DOM document in a Tk Text widget > domtree: displays a DOM document's tree structure in a > BWidget ...

problem with "sorting" in tcl
Hi, Not a master of tcl, I would like to find a solution to the following problem asap. I want to sort a list of numbers. Please see this code ################## set bw [list] set b 6 puts "length: [llength $bw]" for {set i 0} {$i < $b } {incr i} { lappend bw [expr $b-$i] } puts "length: [llength $bw]" lsort -real $bw puts "list is: $bw" ################### Problem: I expect (and I need) that it should give the list as 1 2 3 4 5 6 but the output produced is length: 0 length: 6 list is: 6 5 4 3 2 1 Can anyone advice on what do I need to do so that after sorting the output is "sorted" really..?? thank you. On 2006-03-13, Kamal <kamal.program@gmail.com> wrote: > lsort -real $bw Here's your problem. The lsort man page states: This command sorts the elements of list, returning a new list in sorted order. You're sorting the contents of variable "bw" as a list -- and throwing the sorted list (ie. the return value) away. The above should read: set bw [lsort -real $bw] Also, you don't actually need the "-real" option here, unless you're expecting floating-point values. "-integer" works just fine for the example dataset you presented. - Adrian Kamal wrote: > Hi, > Not a master of tcl, I would like to find a solution to the following > problem asap. I want to sort a list of numbers. Please see this code > > ################## > set bw [list] > se...

Are Tcl and Tk "inseparable"?
Hi, I am a Ruby user and probably I will have to use Tk in order to get nice GUIs. Now, the problem is that: Learning a new language (Ruby) is already time consuming enough. Do I have to learn also Tcl in order to use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with Ruby, I mean) Thanks in advance. Surgeon schrieb: > Hi, > > I am a Ruby user and probably I will have to use Tk in order to get > nice GUIs. Now, the problem is that: Learning a new language (Ruby) is > already time consuming enough. Do I have to learn also Tcl in order to > use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with > Ruby, I mean) The Perl community ripped Tcl from their PerlTk package, but it was just slower, less up to date and more memory hungry. So in principle one could separate Tk from Tcl, but its not worth it. But your question goes in a different direction: The Ruby/Tk binding wraps Tk into a set of Ruby Objects, so you are using Ruby when you create Ruby/Tk programs. So you do not need to learn Tcl to be able to use RubyTk, but it could help in translating advanced Tk examples found on the Tcl'ers wiki (http://wiki.tcl.tk). But you have to learn the options and functions of your libraries, as you have to do for any other package. Michael Surgeon <biyokuantum@gmail.com> wrote: > Hi, > I am a Ruby user and probably I will have to use Tk in order > to get nice GUIs. Now, the problem is that: Learning a ...

"Sayonara Tcl/Tk"
It seems that someone is really upset about Tcl/Tk. http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 Στις 29/4/2013 11:49, ο/η saxo3800@gmail.com έγραψε: > It seems that someone is really upset about Tcl/Tk. > > http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 > I think that he has a point regarding threads. George On Apr 29, 11:02=C2=A0am, Georgios Petasis <peta...@iit.demokritos.gr> wrote: > =CE=A3=CF=84=CE=B9=CF=82 29/4/2013 11:49, =CE=BF/=CE=B7 saxo3...@gmail.co= m =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > > > It seems that someone is really upset about Tcl/Tk. > > >http://forum.sqlitestudio.pl/viewtopic.php?f=3D16&t=3D333 > > I think that he has a point regarding threads. Sure. Though I'm curious to know what specific problem of his is so much better served by explicit locks and shared vars than by message passing, given the context. It's not as if he was worried by lost nanoseconds in mutex contention. -Alex Στις 29/4/2013 20:07, ο/η Alexandre Ferrieux έγραψε: > On Apr 29, 11:02 am, Georgios Petasis <peta...@iit.demokritos.gr> > wrote: >> Στις 29/4/2013 11:49, ο/η saxo3...@gmail.com έγραψε: >> >>> It seems that someone is really upset about Tcl/Tk. >> >>> http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 >> >> I think that he has a point regarding threads. > > Sure. Though I'...

Web resources about - How to open a pty from Tcl (or "please translate C example to Tcl") - comp.lang.tcl

Resources last updated: 3/13/2016 6:07:29 PM