Du command failing

This is a discussion on Du command failing within the TCL forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > TCL

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-25-2008, 08:18 AM
anusha.vempati9@gmail.com
Guest
 
Default Du command failing

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
Reply With Quote
  #2  
Old 08-25-2008, 08:29 AM
Arjen Markus
Guest
 
Default Re: Du command failing

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
Reply With Quote
  #3  
Old 08-25-2008, 09:12 AM
Alexandre Ferrieux
Guest
 
Default Re: Du command failing

See
http://groups.google.com/group/comp....c3452f8754c275

-Alex
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:22 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.