[CentOS] Unable to execute a script , Permission denied

Wed May 26 14:38:53 UTC 2010
m.roth at 5-cent.us <m.roth at 5-cent.us>

> On Tue, May 25, 2010 at 8:27 AM, Jatin Davey <jashokda at cisco.com> wrote:
>
>> On 5/25/2010 6:44 PM, 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
<snip>
> If more than one other user executes this script at the same time,
> tempfile may be overwritten by the second before the first can run
> the awk line.  Change this to use a pipe.

Good thought. Yes, do. An alternative, if you need the file for some
reason, try
#!/bin/sh
  TEMPFILE=/home/proc_threads/tempfile.`date +%Y%m%d%H%M`
  ps -C java -o thcount>  $TEMPFILE
  awk ' { total += $1 } END { print total } ' $TEMPFILE

Note those are backticks around date and its format.

         mark