<br><br><div class="gmail_quote">On Tue, May 25, 2010 at 8:27 AM, Jatin Davey <span dir="ltr"><<a href="mailto:jashokda@cisco.com">jashokda@cisco.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 5/25/2010 6:44 PM, Bowie Bailey wrote:<br>
> Jatin Davey wrote:<br>
><br>
>> Here is the script that i am trying to execute as a non-root user:<br>
>><br>
>> #!/bin/sh<br>
>> ps -C java -o thcount> /home/proc_threads/tempfile<br>
>> awk ' { total += $1 } END { print total } ' /home/proc_threads/tempfile<br>
>><br>
>> here is the output when i try to execute as a non-root user:<br>
>><br>
>> ./javathreads: line 2: /home/proc_threads/tempfile: Permission denied<br>
>> awk: cmd. line:1: fatal: cannot open file<br>
>> `/home/proc_threads/tempfile' for reading (Permission denied)<br>
>><br>
> The script is running, but the 'awk' line is failing to read<br>
> /home/proc_threads/tempfile. What are the permissions on that file and<br>
> directory?<br>
><br>
><br>
> $ ls -ld /home/proc_threads<br>
><br>
> $ ls -l /home/proc_threads/tempfile<br>
><br>
><br>
<br>
</div>Thanks all<br>
<br>
I finally figured out that the tempfile that i was creating did not have<br>
proper permissions for the script to write into. Now i have fixed it<br>
using the chmod command and it is working fine.<br></blockquote><div><br>If more than one other user executes this script at the same time,<br>tempfile may be overwritten by the second before the first can run<br>the awk line. Change this to use a pipe. <br>
</div></div>-- <br>Dale Dellutri<br>