Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin
On 25.5.2010 14:27, Jatin Davey wrote:
Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi,
have another users access to /home/proc_threads directory? :) Don't you call any functions from script which can be executed only by root..? Send us the exact error which you get after execute your script as an user.. If it is a bash script, you can debug it with "-x" option..
Excuse my english :)
Jakub J.
On 5/25/2010 6:20 PM, Jakub Jedelsky wrote:
On 25.5.2010 14:27, Jatin Davey wrote:
Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi,
have another users access to /home/proc_threads directory? :) Don't you call any functions from script which can be executed only by root..? Send us the exact error which you get after execute your script as an user.. If it is a bash script, you can debug it with "-x" option..
Excuse my english :)
Jakub J.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
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)
Thanks Jatin
On 25.5.2010 14:57, Jatin Davey wrote:
On 5/25/2010 6:20 PM, Jakub Jedelsky wrote:
On 25.5.2010 14:27, Jatin Davey wrote:
Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi,
have another users access to /home/proc_threads directory? :) Don't you call any functions from script which can be executed only by root..? Send us the exact error which you get after execute your script as an user.. If it is a bash script, you can debug it with "-x" option..
Excuse my english :)
Jakub J.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
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)
Thanks Jatin
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
...and what are permissions of /home/proc_threads/tempfile? It seems, that users can't write to it.. Try 'chmod o+w /home/proc_threads/tempfile'
How are you trying to execute the script, "./my script" or "sh ./my_script"?
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
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
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
Thanks all
I finally figured out that the tempfile that i was creating did not have proper permissions for the script to write into. Now i have fixed it using the chmod command and it is working fine.
Thanks Jatin
On Tue, May 25, 2010 at 8:27 AM, Jatin Davey jashokda@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
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
Thanks all
I finally figured out that the tempfile that i was creating did not have proper permissions for the script to write into. Now i have fixed it using the chmod command and it is working fine.
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.
On Tue, May 25, 2010 at 8:27 AM, Jatin Davey jashokda@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
On 25 May 2010 14:14, Bowie Bailey Bowie_Bailey@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@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
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.
On Tue, May 25, 2010 at 9:42 AM, Les Mikesell lesmikesell@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. :)
I used an array in a similar situation, (to avoid creating tmp file) but maybe that does not scale? For this case, maybe something like this? ...
#!/bin/sh OLD=$IFS IFS=$'\n' R_PS=($(ps -C java -o thcount)) IFS=$OLD # R_PS is now an array, each element is one line of the ps output
for (( i = 0; i < ${#R_PS[@]}; i++ )) ; do # Sum the desired arguments done echo $total
-Bob
Bob Beers wrote:
On Tue, May 25, 2010 at 9:42 AM, Les Mikesell lesmikesell@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 } '
Bowie wrote:
Bob Beers wrote:
On Tue, May 25, 2010 at 9:42 AM, Les Mikesell lesmikesell@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
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
So? $ ps -C java -o thcount --no-heading | wc -l
mark "shorter is us"
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
Oh, I take that back - I see what's going on, a and yeah, you're right.
mark
On 5/25/2010 9:55 AM, m.roth@5-cent.us wrote:
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
Oh, I take that back - I see what's going on, a and yeah, you're right.
How about: ps H -C java |wc -l
Les Mikesell wrote:
On 5/25/2010 9:55 AM, m.roth@5-cent.us wrote:
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
Oh, I take that back - I see what's going on, a and yeah, you're right.
How about: ps H -C java |wc -l
Almost, but you're off by one... :)
ps H -C java --no-headers | wc -l
Les wrote:
On 5/25/2010 9:55 AM, m.roth@5-cent.us wrote:
m.roth@5-cent.us wrote:
Bowie wrote:
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
You are counting processes, the original is counting threads.
$ ps -C java -o thcount | awk ' { total += $1 } END { print total } ' 29
$ ps -C java --no-heading | wc -l 1
Oh, I take that back - I see what's going on, a and yeah, you're right.
How about: ps H -C java |wc -l
No joy. On one of our servers, if I do that, I show three processes, but if I use the thread count flag, I get THCNT 63 59 62 and the original poster wanted the total threadcount.
mark
On Tue, 2010-05-25 at 17:57 +0530, Jatin Davey wrote:
Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Maybe wrong SElinux context?
Calin
Key fingerprint = 37B8 0DA5 9B2A 8554 FB2B 4145 5DC1 15DD A3EF E857
================================================= Like winter snow on summer lawn, time past is time gone.
On 25 May 2010 13:27, Jatin Davey jashokda@cisco.com wrote:
Hi
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
When i log out and log in as a non-root user i was not able to execute the script though.
Could some one please help in this regard. I am a newbie to linux.
Thanks Jatin _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
1) Does the non-root user have access to the /home/proc_threads directory? 2) Is your home partition mounted noexec?
James
On Tue, May 25, 2010 at 05:57:46PM +0530, Jatin Davey wrote:
I have a linux box which has CentOS running in it. I logged into the box using root and wrote a script in the /home/proc_threads directory. saved the file and quit. I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
What are the permissions on the directory itself?
Best, Whit
From: Jatin Davey jashokda@cisco.com
I changed the file permissions such that any user could execute it using the "chmod 777 filename" command.
Better use 755...
JD