Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

open command

134 views
Skip to first unread message

shags72

unread,
Jun 11, 2010, 11:39:05 PM6/11/10
to
I am wanting to use the open in the same manner as this script that
uses exec. Is there any way to pull this off?

exec notepad.exe $mom_external_filename

Reason being that my embedded tcl has an issue with exec but
supposedly not open. I just can't figure out the pipeline thing that
goes along with this.

Bruce

unread,
Jun 12, 2010, 12:44:04 AM6/12/10
to

syntax -wise it would just be

open "| notepad.exe $mom_external_filename"

but I would be surprised if the system can't use exec but can use
open with a pipeline. (maybe the "open is fine" is based on just opening
files).

Good luck,
Bruce

Christian Rapp

unread,
Jun 12, 2010, 4:22:58 AM6/12/10
to

Maybe you could describe what does not work with your exec so we could
try to solve this.

Regards

shags72

unread,
Jun 12, 2010, 9:29:04 AM6/12/10
to

Ok the syntax problem was I wasn't using the quotes as I thought that
this was the syntax just didn't realize the spaces would cause
problem. Thanks.

As far as the problem with exec goes I am not sure I can explain it as
I don't have access to the base code to the program. What happens is
if using exec to open something it inconsistently hangs the program
and you must kill your session. Although if you set the affinity of
the program process to a single cpu then it won't hang. This is what I
had been doing but now the program is capable of using multi cpus and
we wouldn't be able to take advantage of the time savings. Which
people have tested and reported huge time savings, so I have to fix
this. Hope I explained this well enough and that this makes sense to
you. Thanks.

Alexandre Ferrieux

unread,
Jun 12, 2010, 12:32:04 PM6/12/10
to
On 12 juin, 15:29, shags72 <je...@mtco.com> wrote:
>
> What happens is
> if using exec to open something it inconsistently hangs the program
> and you must kill your session. Although if you set the affinity of
> the program process to a single cpu then it won't hang. This is what I
> had been doing but now the program is capable of using multi cpus and
> we wouldn't be able to take advantage of the time savings. Which
> people have tested and reported huge time savings, so I have to fix
> this. Hope I explained this well enough and that this makes sense to
> you. Thanks.

When you say "set the cpu affinity of the process", are you talking
about the (embedded Tcl) parent, or about the (other program) child ?
If you haven't already, please try both configurations and report
which one hangs.

-Alex

shags72

unread,
Jun 12, 2010, 1:19:51 PM6/12/10
to
On Jun 12, 11:32 am, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:
I set it on the other program. I don't know how to set it on anything
different. If you could let me know how I would appreciate it a lot.
Thanks.

Alexandre Ferrieux

unread,
Jun 12, 2010, 1:32:34 PM6/12/10
to

Ha ! Then, you're observing a deadlock in [exec] on Windows multi-
core, which is solved by single-proc'ing the child ? Very interesting.
It might be a decisive clue to bug 1939509:

https://sourceforge.net/tracker/?func=detail&aid=1939509&group_id=10894&atid=110894

If you have an SF account, please go there and make yourself known.
Otherwise I'll mention this thread and try to stir things a bit :)

-Alex

shags72

unread,
Jun 12, 2010, 2:56:32 PM6/12/10
to
On Jun 12, 12:32 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
> https://sourceforge.net/tracker/?func=detail&aid=1939509&group_id=108...

>
> If you have an SF account, please go there and make yourself known.
> Otherwise I'll mention this thread and try to stir things a bit :)
>
> -Alex- Hide quoted text -
>
> - Show quoted text -


OOOk. Not really sure what you meant by that. LOL. But if it helps
someone great. By the way I don't know what an SF account so I
probably don't have one, and the embedded version would be 8.1 if that
would help. What is wierd is that there is an interface program that
runs on one embedded version (8.1) that is where I write my tcl code,
but the software that sends the (what we call) events uses 8.3 or 4
can't remember. They didn't tell me this so I was always floundering
around using trying to use 8.3 syntax and getting invalid options on
different commands. now I know but then I heard that 8.1 was not a
very good version of tcl. Just hearsay I really don't know as I am
completely new at coding of any language and only been using this for
about a year. Do you agree with what Bruce said? following is a quote
from his post.

" but I would be surprised if the system can't use exec but can use
open with a pipeline. (maybe the "open is fine" is based on just
opening
files). "


I hope not because I would really like to use this instead of exec if
it will fix my issue. Somone was opening TK windows using it and he
said that it fixed this so I thought it might fix my issue with
opening notepad. You guys are great. Thanks.

shags72

unread,
Jun 12, 2010, 2:57:53 PM6/12/10
to
> opening notepad. You guys are great. Thanks.- Hide quoted text -

>
> - Show quoted text -

Oh and one more question. If it is embedded tcl version. I probably
won't be able to use any fix that is brought on to tcl at this time
right?

Alexandre Ferrieux

unread,
Jun 12, 2010, 6:47:20 PM6/12/10
to

OK never mind. If we squash that one thanks to your report, you'll be
on the photo ;-)

> about a year. Do you agree with what Bruce said? following is a quote
> from his post.
>
> "   but I would be surprised if the system can't use exec but can use
> open with a pipeline. (maybe the "open is fine" is based on just
> opening
> files).   "
>
> I hope not because I would really like to use this instead of exec if
> it will fix my issue. Somone was opening TK windows using it and he
> said that it fixed this so I thought it might fix my issue with
> opening notepad. You guys are great. Thanks.

I tend to agree with Bruce. The only difference that comes to mind
between [open |...] and [exec] is the availability of I/O pipes to the
child, and I don't see a direct link with a deadlock in your case.
Just to be sure, when you spawn the child process with [exec], you've
got an "&", right ?

Second question: have you actually tried [open |...] ? Does it solve
the issue without using the processor affinity trick ?

-Alex

shags72

unread,
Jun 12, 2010, 7:17:53 PM6/12/10
to
On Jun 12, 5:47 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>

Where does the "&" go anyway? My code is pretty much as it is in the
first posting.

exec notepad.exe $mom_external_filename

I have an if around it but that is about it. I have not tried the open
command as of yet as I am at home and the software is at work. I was
just trying to get the syntax right so Monday I can try it out and
see. The problem is, is that is is excrutiatingly inconsistent.
Sometimes it locks and then it won't. I even ran it in a loop like 50
times and it never hung once and then all of a sudden it hung.

Alexandre Ferrieux

unread,
Jun 12, 2010, 7:26:17 PM6/12/10
to

The & is the last arg to [exec] when you just want to "fire and
forget". Read the fine manual ;-)

exec child args &

Notepad may or may not be a good example, because it has a GUI, and in
Windows such things have special status. Does your 'other program'
also have a GUI ? Also, do you also want to "fire and forget", or do
you want your Tcl launcher to be blocked until the child returns ?

-Alex

shags72

unread,
Jun 12, 2010, 11:42:01 PM6/12/10
to
On Jun 12, 6:26 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>

Ok I don't use the & . Basically I use notepad to create a file and
then I open it to write out to another file. I will insert the whole
code following this message. So I think fire and forget is out of the
picture as I need this file complete to write whatever is inside to a
new file. So I think the latter is what I need, the wait until my
child returns. Thanks for all the help btw.


uplevel #0 {
# MOM_output_literal "I am in procUL"

proc MOM_load_ext_program { } {

############################# these set control in globally as
cco and cci
global mom_sys_control_out ;# use as needed
global mom_sys_control_in
global cco
global cci
set cco $mom_sys_control_out
set cci $mom_sys_control_in
#############################

global mom_external_filename mom_edit_file mom_add_seqnum
mom_add_msg_leader

set mom_external_filename "[MOM_ask_env_var UGII_CAM_CUSTOM_DIR]\
\text_docs\\$mom_external_filename.txt"
set edit_flag 0
#MOM_output_literal $mom_external_filename

if {$mom_edit_file =="TRUE"} {
exec notepad.exe $mom_external_filename
set edit_flag 1
after 3000
# MOM_output_literal "I am in edit"
}

if {$mom_add_seqnum == "FALSE"} {
MOM_set_seq_off
# MOM_output_literal "I am in seqnum"
} elseif {$mom_add_seqnum == "TRUE"} {
MOM_set_seq_on
}
if {$mom_add_msg_leader == "TRUE"} { ;# turns msg leader off and on
BDB 10-5-09
set mlo "$cco"
set mli "$cci"
} else {
set mlo ""
set mli ""
}
if {[file exists $mom_external_filename]} {
if {![info exists ::count_paths_used]} {
set ::count_paths_used 0
if {$::count_paths_used != 0} {
set file [open $mom_external_filename r]
while { ! [eof $file ] } {
gets $file len
set len "$mlo$len$mli"
MOM_output_literal "$len"
}
close $file
MOM_set_seq_on
} else {
# MOM_output_literal "I am in else cpused"
global delayed_ext_file
global delayed_ext_file_index
global delayed_mom_add_seqnum
set delayed_mom_add_seqnum $mom_add_seqnum
if {![info exists delayed_ext_file_index]} {set
delayed_ext_file_index 0}
set file [open $mom_external_filename r]
while { ! [eof $file ] } {
gets $file len
incr delayed_ext_file_index
set len "$mlo$len$mli"
set delayed_ext_file($delayed_ext_file_index)
"$len"
# MOM_output_literal "$len"
}
close $file
}
incr ::count_paths_used
} else {
if {$::count_paths_used != 0} {
set file [open $mom_external_filename r]
while { ! [eof $file ] } {
gets $file len
set len "$mlo$len$mli"
MOM_output_literal "$len"
}
close $file
MOM_set_seq_on
} else {
# MOM_output_literal "I am in else cpused"
global delayed_ext_file
global delayed_ext_file_index
global delayed_mom_add_seqnum
set delayed_mom_add_seqnum $mom_add_seqnum
if {![info exists delayed_ext_file_index]} {set
delayed_ext_file_index 0}
set file [open $mom_external_filename r]
while { ! [eof $file ] } {
gets $file len
incr delayed_ext_file_index
set len "$mlo$len$mli"
set delayed_ext_file($delayed_ext_file_index) "$len"
# MOM_output_literal "$len"
}
close $file
}
}
MOM_set_seq_on
} else { ;# file exists
if {$edit_flag == 1} {
MOM_output_literal "$cco *** New file not created. Did not save
on exit of Notepad. ****$cci"
} else {
MOM_output_literal "$cco *** New file not created. Must have
EDIT box checked in UDE to create new file. ****$cci"
}
};# file exists
} ;# close proc
} ;# close uplevel

shags72

unread,
Jun 12, 2010, 11:44:33 PM6/12/10
to
> } ;# close uplevel- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -

>
> - Show quoted text -

Oh and also my tcl is called by this other program and it does have
gui. I just click an icon in it and it runs my code.

Larry W. Virden

unread,
Jun 14, 2010, 6:59:01 AM6/14/10
to
On Jun 12, 2:56 pm, shags72 <je...@mtco.com> wrote:
>
> By the way I don't know what an SF account so I
> probably don't have one, and the embedded version would be 8.1 if that
> would help.

An sf account is an http://sourceforge.net/ account. That's where
http://tcl.sf.net/ resides, which has all the various tcl sources, as
well as bug reports, feature requests, etc. Having an account there
allows you to submit a bug report and to get email when progress is
made on fixing it.

When you submit your bug report, please be certain to report the
following things:

The EXACT version of Windows you are using
The hardware you are using
The exact name and version of the program that has tcl embedded
Upload a copy of that code you are attempting to use.

shags72

unread,
Jun 14, 2010, 6:27:16 PM6/14/10
to
On Jun 14, 5:59 am, "Larry W. Virden" <lvir...@gmail.com> wrote:
> On Jun 12, 2:56 pm, shags72 <je...@mtco.com> wrote:
>
>
>
> >  By the way I don't know what an SF account so I
> > probably don't have one, and the embedded version would be 8.1 if that
> > would help.
>
> An sf account is anhttp://sourceforge.net/account. That's wherehttp://tcl.sf.net/resides, which has all the various tcl sources, as

> well as bug reports, feature requests, etc.  Having an account there
> allows you to submit a bug report and to get email when progress is
> made on fixing it.
>
> When you submit your bug report, please be certain to report the
> following things:
>
> The EXACT version of Windows you are using
> The hardware you are using
> The exact name and version of the program that has tcl embedded
> Upload a copy of that code you are attempting to use.

I tried to get this to work today but instead of notepad I tried to
get it to open a tk window looking something like this again remember
this is embedded tcl. ugwish is unigraphics and it is a path like
c:/program files/ugs/mach/auxilary/ugwish.exe the other path to the
myvar is similar with only the end folder being different.

set var [open "|$ugwish_dir_var $myvar"] ;# I tried this with and
without the space after the | neither worked

which didn't work, this replaced a string like this

set var [exec $ugwish_dir_var $myvar]

which worked.

shags72

unread,
Jun 19, 2010, 12:15:40 AM6/19/10
to
> which worked.- Hide quoted text -

>
> - Show quoted text -

Well I got this to work in the software and it ended up being the
spaces in the string. I even had regsub the " " with "\ " or "\" and
couldn't get it to work. My end path in the software didn't have
spaces so this wasn't a problem. Just hope it fixes my hanging
problem.
Still wondering why my regsubs didn't work.

0 new messages