| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi All, I have a problem in executing the 'du' command in a tcl shell script. My code is #! <tcl-interpreter path> exec du <directory_path> >& tempfile I tried to redirect both the output and error to a file. When i treid to execute the above program, i got an error "child process exited abnormally". This is happening since the directory contains the sub directories which does not have read permissions. I am not able to redirect the error. Hence the script is terminating abnormally. After viewing through some older posts here, I have also tried by redirecting the error to a shell as follows set res [exec sh -c {du <directory_path>;exit 0} 2>@ stderr] But this also didnt help me. Can you please suggest me a solution. It would be really useful for me if you can help me in this regard. Thanks! Anusha |
|
#2
| |||
| |||
| On 25 aug, 14:18, anusha.vempa...@gmail.com wrote: > Hi All, > > I have a problem in executing the 'du' command in a tcl shell script. > > My code is > > #! <tcl-interpreter path> > > exec du <directory_path> >& tempfile > > I tried to redirect both the output and error to a file. > When i treid to execute the above program, i got an error "child > process exited abnormally". This is happening since the directory > contains the sub directories which does not have read permissions. I > am not able to redirect the error. Hence the script is terminating > abnormally. > > After viewing through some older posts here, I have also tried by > redirecting the error to a shell *as follows > > set res [exec sh -c *{du <directory_path>;exit 0} *2>@ stderr] > > But this also didnt help me. > > Can you please suggest me a solution. > > It would be really useful for me if you can help me in this regard. > > Thanks! > Anusha The most definitive way to catch such annoying errors (probably due to a non-zero return code from "du") is: set rc [catch { exec du ... } msg] The value rc returned by catch is the error code of the command and msg is the message. You can reduce this to: catch { exec du ... } but then you do not get any information about what went wrong. Regards, Arjen |
|
#3
| |||
| |||
| |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.