[CentOS] Unable to execute a script , Permission denied

Tue May 25 14:30:25 UTC 2010
m.roth at 5-cent.us <m.roth at 5-cent.us>

Bowie wrote:
> Bob Beers wrote:
>> On Tue, May 25, 2010 at 9:42 AM, Les Mikesell <lesmikesell at gmail.com>
>> wrote:
>>> Bowie Bailey wrote:
>>>> Jatin Davey wrote:
>>>>
>>>>> Here is the script that i am trying to execute as a non-root user:
>>>>>
>>>>> #!/bin/sh
>>>>> ps -C java -o thcount > /home/proc_threads/tempfile
>>>>> awk ' { total += $1 } END { print total } '
>>>>> /home/proc_threads/tempfile
>>>>>
>>>>> here is the output when i try to execute as a non-root user:
>>>>>
>>>>> ./javathreads: line 2: /home/proc_threads/tempfile: Permission denied
>>>>> awk: cmd. line:1: fatal: cannot open file
>>>>> `/home/proc_threads/tempfile' for reading (Permission denied)
>>>>>
>>>> The script is running, but the 'awk' line is failing to read
>>>> /home/proc_threads/tempfile.  What are the permissions on that file
>>>> and
>>>> directory?
>>>>
>>>>     $ ls -ld /home/proc_threads
>>>>     $ ls -l /home/proc_threads/tempfile
>>>>
>>> Unless you have some other use for the contents of tempfile, you could
>>> use a pipeline instead to avoid any permissions issue.
>>>
>> If you don't mind, I would like to see the pipeline equivalent. :)
>>
> ps -C java -o thcount | awk ' { total += $1 } END { print total } '

Now, as dearly as I love awk,
ps -C java --no-heading | wc -l

          mark