[CentOS] Unable to execute a script , Permission denied

Tue May 25 13:29:05 UTC 2010
James Hogarth <james.hogarth at gmail.com>

On 25 May 2010 14:14, Bowie Bailey <Bowie_Bailey at buc.com> 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
>
> --
> Bowie
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>

Looks like it is failing before the awk...

For that script to run the directory will need to be writeable by the
user running the script...

chmod o+w /home/proc_threads will do if you don't care for security of
the file/directory... or arrange the group of the user running the
script to be able to write to the directory instead.

James