Prev: How to transfer "trusted" environment into a safe slave interpreter?
Next: Reading binary file from channel on host computer
From: Andreas Leitgeb on 15 Jan 2010 12:49 Mat <kill_spam(a)matware.net> wrote: > great! I was hoping, I just needed to change some sort global variable > (like in perl or php), so it didn't even occur to me check exec's options :) Given that we're talking about a peculiarity of your machine, namely not offering the normal /tmp for everyone, it might be a good idea to recompile tcl yourself on that machine, with the tmpdir path hard-adapted to your machine's one. That would allow you to use foreign scripts unmodified, and have your own scripts work on other machines as well (without having to eliminate the workarounds...) And perhaps it is about time to revamp exec and replace the inadequate ones among the used internal helper functions and then finally fix some of its long- standing bugs. ;)
From: Alexandre Ferrieux on 15 Jan 2010 12:50
On Jan 15, 6:47 pm, Mat <kill_s...(a)matware.net> wrote: > Mat wrote: > > Alexandre Ferrieux wrote: > >> On Jan 15, 3:40 pm, Mat <kill_s...(a)matware.net> wrote: > >>> Hi, > > >>> in a shared hosting environment, I don't have any access to > >>> /tmp which results in all my exec calls to return the error > > >>> couldn't create error file for command: permission denied > > >>> I've been assigned a "private" temp dir but am at a loss as to how to > >>> tell my script to use that directory instead.. > > >>> Any ideas? > >>> Mat > > >> The temporary file in [exec] serves only when no 2> or 2>@ redirection > >> is given, because the child's stderr output in this case is > >> accumulated to later generate the error message. Unfortunately, that > >> code uses the old, rigid TclpCreateTempFile, which is not as > >> customizable as the more modern TclpOpenTemporaryFile. So it uses a > >> libc header macro P_tmpdir and no env variable :-( > > >> So, to work around this limitation, either add "2>@ stderr" so that > >> the child's stderr will simply flow outside, or the -ignorestderr flag > >> to swallow it silently, or explicitly use a file of yours (2>/path/to/ > >> yourfile). > > > great! I was hoping, I just needed to change some sort global variable > > (like in perl or php), so it didn't even occur to me check exec's > > options :) > > > Using my own file worked.. but then again, I need to add extra stuff > > (like reading the error file ;) ) to get the actual error message. > > > thanks > > Mat > > alright, seems I've been blind while perusing the exec docs.. > > I'm now using > > if {[catch {set result [exec {*}$cmd 2>@1]} err]} { > set html "ERROR: $err"} else { > > set html $result} > > puts $html > > to get my error message without the need for extra temporary files.. > (and I even brought in a 8.5.8 tclkit for that expand goodness :)) > > Mat Beware, doing that you'll mix the child's stdout and stderr. Some programs write to stderr for debugging aid or just progress indication, not only for errors. -Alex |