From: jemptymethod on
I'm trying to execute a shell command with exec and redirect stderr
and stdout to a file as follows:

exec $cmd >& [file join $root_home log exec.log]

I know the command is failing because my program executes nothing
further after this line. That's why I'm trying to log stderr and
stdout, for debugging purposes.

Problem is, the file "exec.log" gets created but it contains nothing,
it is zero bytes.

Thanks in advance for all guidance and suggestions.
From: eugene on
On Aug 7, 3:31 pm, jemptymethod <jemptymet...(a)gmail.com> wrote:
> I'm trying to execute a shell command with exec and redirect stderr
> and stdout to a file as follows:
>
> exec $cmd >& [file join $root_home log exec.log]
>
> I know the command is failing because my program executes nothing
> further after this line.  That's why I'm trying to log stderr and
> stdout, for debugging purposes.
>
> Problem is, the file "exec.log" gets created but it contains nothing,
> it is zero bytes.
>
> Thanks in advance for all guidance and suggestions.

When you launch the binary specified in your $cmd variable from
command line, does it produce any output at all?
Everything in your code seems correct, I set cmd to netstat and got
correct log file with netstat output.
From: jemptymethod on
On Aug 7, 8:25 am, eugene <eugene.mind...(a)gmail.com> wrote:
> On Aug 7, 3:31 pm, jemptymethod <jemptymet...(a)gmail.com> wrote:
>
> > I'm trying to execute a shell command with exec and redirect stderr
> > and stdout to a file as follows:
>
> > exec $cmd >& [file join $root_home log exec.log]
>
> > I know the command is failing because my program executes nothing
> > further after this line.  That's why I'm trying to log stderr and
> > stdout, for debugging purposes.
>
> > Problem is, the file "exec.log" gets created but it contains nothing,
> > it is zero bytes.
>
> > Thanks in advance for all guidance and suggestions.
>
> When you launch the binary specified in your $cmd variable from
> command line, does it produce any output at all?
> Everything in your code seems correct, I set cmd to netstat and got
> correct log file with netstat output.

I have been logging the command before executing it so that I can try
it directly from a shell prompt, and it performs as expected:
generating a starkit.exe. Not only that, but I can then paste this
command into an "ordinary" tcl script and execute it and it likewise
performs as expected.

I say "ordinary" because the actual application within which I am
trying to execute my $cmd is a starkit itself. So that would seem to
be the primary difference. But, within the starkit, I can
successfully exec a simple command such as ls, so I'm not sure why its
barfing on the actual command I need to run :(

At the bottom is the command I'm trying to run from within my
starkit. Guess I will also ask over on the starkit group, I did start
a thread there a few days ago about generating a starkit from a
starkit. I didn't think my current issue was that specific at first,
but rather an issue with not being able to trap stderr/stdout, but the
deeper I dig the more it seems this is indeed starkit/tclkit
specific.

That thread for those who might be interested is:

http://groups.google.com/group/starkit/browse_thread/thread/fc339c3c517e3d35

Thanks for any further guidance/suggestions from this group. It was
not my intention to cross post, I thought at first it might be a more
general Tcl issue. Below is the command I'm trying to run within my
starkit:

C:/opt/deskwideweb/platform/DeskMLKit/dexygen.vfs/dxapp/bin/tclkit-cli
C:/opt/deskwideweb/platform/DeskMLKit/dexygen.vfs/dxapp/bin/sdx.kit
wrap appname.exe -runtime C:/opt/deskwideweb/platform/DeskMLKit/
dexygen.vfs/dxapp/bin/tclkit-gui
From: Robert Heller on
At Sat, 7 Aug 2010 04:31:49 -0700 (PDT) jemptymethod <jemptymethod(a)gmail.com> wrote:

>
> I'm trying to execute a shell command with exec and redirect stderr
> and stdout to a file as follows:
>
> exec $cmd >& [file join $root_home log exec.log]

What is cmd set to? If it is a full command line, the above won't work
at all. Eg this will fail to work:

set cmd "gcc -c foo.c"
exec $cmd >& [file join $root_home log exec.log]

But this will work:

set cmd [list gcc -c foo.c]
eval exec $cmd >& [file join $root_home log exec.log]

>
> I know the command is failing because my program executes nothing
> further after this line. That's why I'm trying to log stderr and
> stdout, for debugging purposes.
>
> Problem is, the file "exec.log" gets created but it contains nothing,
> it is zero bytes.
>
> Thanks in advance for all guidance and suggestions.
>

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/

From: Gerald W. Lester on
jemptymethod wrote:
> On Aug 7, 8:25 am, eugene <eugene.mind...(a)gmail.com> wrote:
>> On Aug 7, 3:31 pm, jemptymethod <jemptymet...(a)gmail.com> wrote:
>>
>>> I'm trying to execute a shell command with exec and redirect stderr
>>> and stdout to a file as follows:
>>> exec $cmd >& [file join $root_home log exec.log]
>>> I know the command is failing because my program executes nothing
>>> further after this line. That's why I'm trying to log stderr and
>>> stdout, for debugging purposes.
>>> Problem is, the file "exec.log" gets created but it contains nothing,
>>> it is zero bytes.
>>> Thanks in advance for all guidance and suggestions.
>> When you launch the binary specified in your $cmd variable from
>> command line, does it produce any output at all?
>> Everything in your code seems correct, I set cmd to netstat and got
>> correct log file with netstat output.
>
> I have been logging the command before executing it so that I can try
> it directly from a shell prompt, and it performs as expected:
> generating a starkit.exe. Not only that, but I can then paste this
> command into an "ordinary" tcl script and execute it and it likewise
> performs as expected.
>
> I say "ordinary" because the actual application within which I am
> trying to execute my $cmd is a starkit itself. So that would seem to
> be the primary difference. But, within the starkit, I can
> successfully exec a simple command such as ls, so I'm not sure why its
> barfing on the actual command I need to run :(
>
> At the bottom is the command I'm trying to run from within my
> starkit. Guess I will also ask over on the starkit group, I did start
> a thread there a few days ago about generating a starkit from a
> starkit. I didn't think my current issue was that specific at first,
> but rather an issue with not being able to trap stderr/stdout, but the
> deeper I dig the more it seems this is indeed starkit/tclkit
> specific.
>
> That thread for those who might be interested is:
>
> http://groups.google.com/group/starkit/browse_thread/thread/fc339c3c517e3d35
>
> Thanks for any further guidance/suggestions from this group. It was
> not my intention to cross post, I thought at first it might be a more
> general Tcl issue. Below is the command I'm trying to run within my
> starkit:
>
> C:/opt/deskwideweb/platform/DeskMLKit/dexygen.vfs/dxapp/bin/tclkit-cli
> C:/opt/deskwideweb/platform/DeskMLKit/dexygen.vfs/dxapp/bin/sdx.kit
> wrap appname.exe -runtime C:/opt/deskwideweb/platform/DeskMLKit/
> dexygen.vfs/dxapp/bin/tclkit-gui

Is C:/opt/deskwideweb/platform/DeskMLKit/dexygen.vfs/dxapp/bin/tclkit-cli an
actual file on the disk or is it inside of your startkit (or another VFS)?



--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester(a)kng-consulting.net |
+------------------------------------------------------------------------+
 |  Next  |  Last
Pages: 1 2
Prev: Ffidl and ShellExecuteEx
Next: Frequent Wiki problems