f



Why can execution results in tcl shell differ than if using tcl script??

Hi,

I have been posting a thread here:
http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/983d7ef3e4b1ab54#

I have another question that might be related to it, I'm doing set of
tcl commands (involving external shell commands execution) one time in
tcl shell, and the other from a tcl script..

Although both command sequences are the same, I get quite different
results!!! Why did this happens??

Thanks,
Ahmad
0
7/30/2009 9:51:32 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

5 Replies
734 Views

Similar Articles

[PageSpeed] 27

Ahmad wrote:
> Hi,
> 
> I have been posting a thread here:
> http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/983d7ef3e4b1ab54#
> 
> I have another question that might be related to it, I'm doing set of
> tcl commands (involving external shell commands execution) one time in
> tcl shell, and the other from a tcl script..
> 
> Although both command sequences are the same, I get quite different
> results!!! Why did this happens??
> 
> Thanks,
> Ahmad

The interactive Tcl shell has access to external functionality that a 
running script doesn't.  That's done to make the interactive environment 
easier to work with.  What, specifically, is the command sequence you're 
issuing in both cases?

Jeff
0
jeff_godfrey (836)
7/30/2009 10:25:40 PM
Hi Jeff,

Thank you for your reply.

I've a tcl script that finally creates a certain script, that is when
I run from shell using "calibredrv -gui <certainRunScript>" from
command line it do exactly what I expect.

I have tried two scenarios of trials, and only one of them works:

1. Open tclsh -->  Run the following TCL line from tclsh interpreter
(where the variable runScript is probably defined)
    catch {exec -- calibredrv -gui $runScript >/dev/null 2>/dev/null}
msg

2. From inside my tcl script, the same line (copy and paste):
    catch {exec -- calibredrv -gui $runScript >/dev/null 2>/dev/null}
msg

Results:

Scenario #1 works perfectly, and $msg is alway empty (using puts)

Scenario #2 doesn't work, where CalibreDRV window opens and
immediately get closed, and also $msg is empty!!!

I need the command "calibredrv -gui $runScript" process to be waited
until finished, then in tcl check if a certain file that it should
generate exists or not (i.e. wait for this process) so I didn't
execute it in background..

I think i'm misusing catch/exec and that's what made the problem??

Why does it fail in the tcl script??

In general, how to wait for a shell command while being executed
within tcl?

Any ideas?

Thanks,
Ahmad

On Jul 31, 1:25=A0am, Jeff Godfrey <jeff_godf...@pobox.com> wrote:
> Ahmad wrote:
> > Hi,
>
> > I have been posting a thread here:
> >http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/983...
>
> > I have another question that might be related to it, I'm doing set of
> > tcl commands (involving external shell commands execution) one time in
> > tcl shell, and the other from a tcl script..
>
> > Although both command sequences are the same, I get quite different
> > results!!! Why did this happens??
>
> > Thanks,
> > Ahmad
>
> The interactive Tcl shell has access to external functionality that a
> running script doesn't. =A0That's done to make the interactive environmen=
t
> easier to work with. =A0What, specifically, is the command sequence you'r=
e
> issuing in both cases?
>
> Jeff

0
7/30/2009 10:40:07 PM
Ahmad wrote:
> Hi Jeff,
> 
> Thank you for your reply.
> 
> I've a tcl script that finally creates a certain script, that is when
> I run from shell using "calibredrv -gui <certainRunScript>" from
> command line it do exactly what I expect.
> 
> I have tried two scenarios of trials, and only one of them works:
> 
> 1. Open tclsh -->  Run the following TCL line from tclsh interpreter
> (where the variable runScript is probably defined)
>     catch {exec -- calibredrv -gui $runScript >/dev/null 2>/dev/null}
> msg
> 
> 2. From inside my tcl script, the same line (copy and paste):

Ahmad,

I'm far from an expert in the art of [exec], but here are a few tips...

- First, I'd remove the "catch" command from around your exec call. 
That's likely masking the real problem.  Once it's gone, I'd bet you'll 
get an error that'll lead you in the right direction.

- What is calibredrv, and probably more importantly, *where* is 
calibredrv?  Interactively, I think it'll be found if its anywhere in 
the PATH, but that's not the case when run as a script.  If it's not in 
the local folder, you need to specify a path with it.

Jeff
0
jeff_godfrey (836)
7/30/2009 11:10:07 PM
Jeff Godfrey wrote:
> Interactively, I think it'll be found if its anywhere in 
> the PATH, but that's not the case when run as a script.
> 
> Jeff

I was informed via private email that the above is incorrect.  And, 
after RTFM, I've verified that to be the case.  [exec] does indeed 
search the directories defined in PATH, whether interactive or not 
(assuming the command name doesn't contain slashes)...

Sorry for the misinformation.

Still, I think removing your [catch] will be enlightening...

Jeff
0
jeff_godfrey (836)
7/31/2009 1:42:46 AM
At Thu, 30 Jul 2009 20:42:46 -0500 Jeff Godfrey <jeff_godfrey@pobox.com> wrote:

> 
> Jeff Godfrey wrote:
> > Interactively, I think it'll be found if its anywhere in 
> > the PATH, but that's not the case when run as a script.
> > 
> > Jeff
> 
> I was informed via private email that the above is incorrect.  And, 
> after RTFM, I've verified that to be the case.  [exec] does indeed 
> search the directories defined in PATH, whether interactive or not 
> (assuming the command name doesn't contain slashes)...
> 
> Sorry for the misinformation.

It is possible that the value of PATH might be different under different
conditions (interactive vs script). There is much that the original
poster has not told us (the NG).

> 
> Still, I think removing your [catch] will be enlightening...

Yes indeed...

> 
> Jeff
>                                  

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Download the Model Railroad System
http://www.deepsoft.com/  -- Binaries for Linux and MS-Windows
heller@deepsoft.com       -- http://www.deepsoft.com/ModelRailroadSystem/
  
0
heller (3031)
7/31/2009 11:45:44 AM
Reply:

Similar Artilces:

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...

running other tcl from a tcl
Is that possible? 1 - sequentially to call two tcl files, like: c:\> tclkit-8.4.7.exe first.tcl second.tcl 2 - from a tcl to call other one # first.tcl content below exec hello.tcl # end regards, mauro ps.: I'm not experience in Tcl. Mauro Silva wrote: > Is that possible? > > 1 - sequentially to call two tcl files, like: > > c:\> tclkit-8.4.7.exe first.tcl second.tcl > > 2 - from a tcl to call other one > > # first.tcl content below > > exec hello.tcl > > # end > > regards, > m...

tcl-gaul: Genetic Algorithms for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-gaul Tcl-gaul is a Tcl extension for genetic/evolutionary algorithm processing.It relies on the GAUL library: http://gaul.sourceforge.net/ * A genetic algorithm (GA) is a search technique used in computing to find exact or approximate solutions to optimization and search problems. Genetic algorithms are categorized as global search heuristics. They are a particular class of evolutionary algorithms that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover. For ...

tcl-pam: PAM authentication for Tcl (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-pam Tcl-pam is a Tcl interface to the PAM* service of Linux. It provides a Tcl package that allows Tcl scripts to use PAM to authenticate users and programs. It relies on linux-pam library: http://www.kernel.org/pub/linux/libs/pam/ * PAM (Pluggable Authentication Modules): A mechanism to integrate multiple low−level authentication schemes into a high−level application programming interface (API). This enables programs that rely on authentication to be written independently of the underlying authentication scheme. Platform:...

can we use shell-like short key in tcl shell
in nominal shell, we can use the command line short key such as CTRL +P (previous command) CTRL+H (backspace) CTRL+ K (delete all the the end) CTRL + A (go to the begning of the command line. In tclsh/tcl, when I debug a few lines of scripts, I find it is very unconvenient withou this kind of short key. so my question is straigthforward, Is this a bug or feature? Can this kind of thing done in tclshl? If NOT, is there any work around tips ? any suggestions? On May 20, 3:58 am, BingYU <yubin...@gmail.com> wrote: > in nominal shell, we can use the command line short key suc...

Tcl command to evaluate a tcl script?
Hi all, I need to evaluate a separate tcl file within a tcl file. Is there any tcl command to evaluate a tcl file ? Regards, Prabu.K prabu wrote: > Hi all, > > I need to evaluate a separate tcl file within a tcl file. Is there any > tcl command to evaluate a tcl file ? > > Regards, > Prabu.K > hi, try: source your_other_tcl_file.tcl cheers, Tobi ...

can you run e commerce site using just tcl 8.6.2 and a pure tcl webserver?
and have decent performance? ...

tcl-syslog: Unix system logging for Tcl (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-syslog Tcl-syslog is a Tcl interface to the *nix syslog service. It provides a Tcl package that allows Tcl scripts to log messages to syslog. Platform: Linux/Unix Home page: http://sourceforge.net/projects/tcl-syslog/ Man page: http://tcl-syslog.sourceforge.net/ Author: Alexandros Stergiakis alsterg ...

tcl-mq: POSIX Message Queues for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-mp Tcl-mp is a Tcl interface to POSIX Message Queues*. It provides a Tcl package that allows scripts to create/open/close/unlink multiple parallel message queues, and to send/receive messages synchronously and asynchronously to/from them. * A POSIX message queue is an Inter-Process Communication mechanism available on Linux and some other POSIX-compliant operating systems. It allows to or more processes (or threads) to communicate under the same OS. The messages are buffered by the kernel, which gives them kernel persis...

tcl-mmap: A POSIX mmap interface for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-mmap Tcl-mmap is a Tcl interface to the POSIX mmap* system call. It provides a Tcl package that allows Tcl scripts to: 1) Memory map files for improved access efficiency; 2) Share memory between related processes; 3) Easily implement cyclic persistent log files. * See the mmap(2) man page. Platform: Linux/Unix Home page: http://sourceforge.net/projects/tcl-mmap/ Man page: http://tcl-mmap.sourceforge.net/ Author: Alexandros Stergiakis On Sep 3, 11:48=A0am, Alexandros Stergiakis <alst...@gmail.com> wrote: > This is an ...

Tkinter: different results from the same tcl script
Hello, in mixed python-tcl programming I found the following different behaviours of the same tcl script. If I type manually in the python interpreter the following lines >>> from Tkinter import * >>> w = Tk() >>> w.tk.evalfile('my_tcl_script.tcl') where my_tcl_script.tcl is #!/bin/sh package require Tk wm withdraw . toplevel .root wm title .root "My title" I obtain one toplevel window with title "My title", as expected. The same result is obtained with the tcl shell command % wish my_tcl_script.tcl Now, I...

How can I source a shell script from Tcl?
I'm using Modules to configure the software environment on a cluster. It's = written in Tcl. I need to source the Intel startup shell scripts to get all= the compiler environment variables in place, but this seems challenging/im= possible in Tcl. Is there any known work around? I can't alter the shell scripts from intel. I know it should be possible since I can append-path in the modulefile. Thanks for your help! Scott VashTheStampede <scamicha@gmail.com> wrote: > I'm using Modules to configure the software environment on a cluster. > It's written in Tcl. I...

Tcl command to evaluate a tcl script? #2
Hi all, I need to evaluate a separate tcl file within a tcl file. Is there any tcl command to evaluate a tcl file ? Regards, Prabu.K prabu wrote: > I need to evaluate a separate tcl file within a tcl file. Is there any > tcl command to evaluate a tcl file ? You're probably looking for the "source" command. Other commands of interest would be "package require" or "eval". The command "load" is for binary shared libraries. -- Darren New / San Diego, CA, USA (PST) Scruffitarianism - Where T-shirt, jeans, and a three-day beard...

Will tcl 9 use epoll or kqueue for tcl?
curious http://luvit.io/ also check this out for web stuff done in lua but perhaps tcl can steal nice ideas On Wednesday, January 2, 2013 3:22:02 PM UTC-8, gavino_himself wrote: > curious > > > > http://luvit.io/ also check this out for web stuff done in lua but perhaps tcl can steal nice ideas cherokee uses them so gota be ast for events and cherokee outperforms nginx ...

Dose there any tcl script to translate an file with embedded tcl
Hi I need to generate some big file, but there are rules for generate these files Ex . ============================== Start input a [0] wire input a [1] wire .. .. .. .. input a [1000] wire End ================================= Dose there any tcl script can help to translate a file with embedded tcl script into a new file For example this is a source file ======================== Start * set i 0 * for { set i 0 } { $i < 1000 } { incr i } { * puts input a [$i] wire * } End ========================== After Translate ======================= Start input a [0] wire input a [1] wire .. .. ...

Tcl+incr Tcl debuggers to use on command line?
Hi, Does anyone know of incr Tcl supported debuggers that work on command line? That is, without needing bundling with IDEs? Thanks On 10/11/14, 9:46 PM, kenneth.bull@gmail.com wrote: > Hi, > > Does anyone know of incr Tcl supported debuggers that work on command line? > That is, without needing bundling with IDEs? Well, the debugger in ActiveState's TDK does not need a bundled IDE and it works with [incr Tcl] -- but it is a GUI application not a command line one. -- +------------------------------------------------------------------------+ | Gerald W. L...

In Tcl and C++ code, how to use Tcl Command, such as exit?
In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control all input and output from Tcl, but i want to use some of Tcl' Commands, such as, exit. I used Tcl_Eval() then, but the Tcl command seem invisible in my code, I typed a string in command prompt, such as "AAAAA", and Enter, got nothing feedback. How can i do to get these Tcl Commands work? Thanx! vian1381@china.com.cn wrote: > In my code, i used Tcl_SetStdChannel(0, STDIN) and a thread to control > all input and output from Tcl, but i want to use some of Tcl' Commands, > such as, exit. > &g...

tcl-snmptools: SNMP v1/v2/v3 operations for Tcl. (Tcl package)
This is an announcement for a relatively new Tcl project: tcl-snmptools Tcl-snmptools is a Tcl interface to the Net-SNMP library which provides operations for the management of remote SNMP agents. It supports all the standard SNMP v1/v2/v3 operations: connect, close, get, set, getnext, walk, bulkget, bulkwalk, trap, translate and others. It is currently in a functional state, but more work and testing needs to be done. Home page: http://sourceforge.net/projects/tcl-snmptols/ Man page: http://tcl-snmptols.sourceforge.net/ Author: Alexandros Stergiakis alsterg ...

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 fou...

Tclsh application error (executable from tcl script using freewrapTCLSH62
Hi, I used freewrapTCLSH62 to create an executable for a tcl script that telnets into a computer and reboots it and logs into it again after it restarts. When I run the application everything runs fine right until the target system restarts, when I get a pop-up window saying - Tclsh Application has encountered a problem and needs to close. The executable stops right there. Below is the file that was included in the error report. <?xml version=3D"1.0" encoding=3D"UTF-16"?> <DATABASE> <EXE NAME=3D"mfg.exe" FILTER=3D"GRABMI_FILTER_PRIVA...

Using Tcl::Tk Module with Tcl/Tk 8.5
Not sure if this is the right place for this question, as it is with relation to the Tcl::Tk module, rather than Perl/Tk specifically. I'd like to use Tcl::Tk with Tcl/Tk 8.5 rather than 8.4. To that end, on a clean Debian Testing system I have installed only Tcl/Tk 8.5 and also finally managed to install the Tcl::Tk module. I was having problems installing the Tcl-0.95 module, which Tcl::Tk depends on, but fixed it with a specific include path call: >sudo perl Makefile.PL --tclsh /usr/bin/tclsh8.5 --tclconfig /usr/lib/tcl8.5/tclConfig.sh --include /usr/include/tcl8.5 Fo...

How to compile tcl or encrypt tcl
I use TclPro1.5 to compile my tcl script with tixwish in the Solaris before. But I cannot use the same method in Linux. Why? Is there any utility for me to compile or encrypt the code by using tixwish? The following is the simple code if I use the tixwish: #!/home/albertl/local/bin/tixwish puts "haha" And after using procomp by the TclPro1.5 Error in startup script: The TclPro ByteCode Loader is not available or does not support the correct version while executing "error "The TclPro ByteCode Loader is not available or does not support the correct version""...

How to execute script using tcl interpreter coming with Python in Windows?
Hello! Almost each Python installation in Windows has it's own tcl interpreter. Can I execute a tcl script without additional tcl installation? I didn't find any executable tcl file, there is no files contain words wish or tclsh. There are several interesting *.dll files: /c/Python27/ArcGIS10.1/DLLs/tcl85.dll /c/Python27/ArcGIS10.1/DLLs/tclpip85.dll /c/Python27/ArcGIS10.1/DLLs/tk85.dll Here is example of content of Python's tcl directory http://pastebin.com/ts8PmAR4 Thank you El martes, 17 de marzo de 2015, 18:11:04 (UTC-3), John Johnson escribi=F3: > ...

How Tcl speaks for itself and how Tcl is not spoken for...
Hello It's Friday and... well... Two things about Tcl going through my mind this week, a nice anecdote and a eyebrow-rising thing on Wikipedia: Anecdote: Until three months ago I worked in a scientific institue where I wrote much software in Tcl, especially a big Build and Report System, some tools for automatic checking of coding style and other things. Tcl had a bad reputation there (not because of me... they dropped Tcl before I started there in favour of Joy, then JavaScript and now Python) and besides me, there was only one co-worker who appearantly writes some small Tcl-Scripts to...

Web resources about - Why can execution results in tcl shell differ than if using tcl script?? - comp.lang.tcl

Execution by firing squad - Wikipedia, the free encyclopedia
... and "shot at dawn" redirect here. For other uses, see Firing squad (disambiguation) . For the UK memorial, see Shot at Dawn Memorial . Execution ...

Cie Games Founder Justin Choi: Execution Key To Success On Facebook’s Gaming Platform
... its flagship game to continued success and some 5.9 million monthly average users . The key, according to Founder Justin Choi: Better execution. ...

SAP Retail Execution on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about SAP Retail Execution. Download SAP Retail Execution and enjoy it ...

Execution Bed - Flickr - Photo Sharing!
... the microphone; it is why I am here. There are few acts graver than when a government takes the life of one of its own citizens. Executions ...

W.H. Refuses to Say If It Supports the Executions of the Al Qaeda Terrorist by Jordan - YouTube
"THIS VIDEO IS FAIR USE UNDER U.S. COPYRIGHT LAW BECAUSE IT IS (1) NON-COMMERCIAL, (2) TRANSFORMATIVE IN NATURE, (3) USES NO MORE OF THE ORIGINAL ...

Roger Rogerson trial: Jury sees CCTV footage which prosecutors say reveals execution of drug dealer Jamie ...
A SECRET pub meeting, a body in a surfboard bag and a six-pack of beer following an alleged ­execution — the making of Jamie Gao’s murder was ...

Gao’s ice dream ‘ended in execution’
WHEN would-be drug dealer and student Jamie Gao met Roger Rogerson and Glen McNamara in a storage unit to hand over three kilos of the drug ...

Get The Strategy Right And The Execution Is Easy
... best of the group was Arnie Chavkin and he taught me something that I come back to often. Arnie told me “get the strategy right and the execution ...

Israel releases Nazi Eichmann's execution plea papers
Papers newly released by Israel show Nazi Adolf Eichmann blamed others for the Holocaust, in a plea for clemency against his death sentence. ...

Eric Trump: ‘The Speed of Execution’ of a Trump Administration ‘Would Be Like Something Never Seen Before’ ...
Eric Trump: 'The Speed of Execution' of a Trump Administration 'Would Be Like Something Never Seen Before'

Resources last updated: 2/19/2016 4:12:15 AM