LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   csh: permission denied (https://www.linuxquestions.org/questions/linux-newbie-8/csh-permission-denied-669367/)

jjguo 09-11-2008 09:55 PM

csh: permission denied
 
When i use 'csh' to execute any c shell script, the command line console always prompt "/home/xxx: Permission denied" message.
but the shell script works ok when i use 'sh' to execute it.
So i think it has not relation with the permission of shell script.

lrwxrwxrwx 1 root root 4 Apr 9 22:23 /bin/sh -> bash
lrwxrwxrwx 1 root root 4 Apr 9 22:25 /bin/csh -> tcsh
-rwxr-xr-x 1 root root 616248 Oct 6 2006 /bin/bash
-rwxrwxrwx 1 root root 307488 Mar 15 2007 /bin/tcsh

mjmwired 09-11-2008 10:08 PM

Set the execute permission on the script:
# chmod +x script_name

Then run:
# ./script_name

jjguo 09-11-2008 10:41 PM

Thanks for your reply.

My problem is not relation with the permission of shell script which executed by csh. it is about the permission of csh command.

When i just type "csh" in command line console, the console prompt "permission denied" like below.

[jjguo@stsdd08-4 /]$ csh
/home/jjguo: Permission denied.

And it can work but it always prompt "Permission denied" message, i just don't know why this happens.

jschiwal 09-11-2008 10:56 PM

The group and other permissions for tcsh should not have the write permissions. Reinstall tcsh. Determine how it happened. I'm somewhat worried that the command was replaced with a cracker's version, in which case, tcsh is the least of your worries. Check if tcsh is a wrapper script for some reason.

anomie 09-12-2008 01:10 PM

Quote:

Originally Posted by jjguo
When i use 'csh' to execute any c shell script, the command line console always prompt "/home/xxx: Permission denied" message.
but the shell script works ok when i use 'sh' to execute it.

So... is it really a c shell script or is it a Bourne shell script?

P.S. Read here: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

makyo 09-12-2008 01:55 PM

Hi.

Please post the shortest example of a script that exhibits this behavior along with a copy / paste of the output, and the similar output as executed with sh. Otherwise we're working just where the light is good, not where the problem is.

I'm betting on something in .cshrc or .tcshrc ... cheers, makyo

jjguo 09-15-2008 08:50 PM

you don't need to care about whatever shell script it executes, for example:

[jjguo@stsdd08-4 ~]$ csh
/home/jjguo: Permission denied.
[jjguo@stsdd08-4 ~]$ sh
sh-3.00$

Simultaneity, csh can execute shell script correctly, but just always prompt the message "Permission denied".

thanks

jjguo 09-15-2008 09:00 PM

I have commented all codes in .cshrc file, it still prompt "Permission denied"

thanks.

jjguo 09-15-2008 09:12 PM

i found that when i switch to another user, csh don't prompt that message.
Maybe it is related with my user.

the two user's information in file /etc/passwd
aime:x:94110:42424::/scratch/aime:/bin/tcsh
jjguo:70dQGjUwdngPM:505540:8500::/home/jjguo:/bin/csh

the first user 'aime' is ok
the second user 'jjguo' is wrong

[aime@stsdd08-4 ~]$ csh
[aime@stsdd08-4 ~]$

[jjguo@stsdd08-4 aime]$ csh
/home/jjguo: Permission denied.
[jjguo@stsdd08-4 aime]$

thanks everyone.

Mr. C. 09-16-2008 01:12 AM

What is the output of the following command:

Code:

ls -ld /home/jjguo /home//home/jjguo/.??*

jjguo 09-16-2008 09:10 AM

[jjguo@stsdd08-4 ~]$ ls -ld /home/jjguo /home /home/jjguo/.??*
drwxr-xr-x 11 root root 4096 Sep 4 09:48 /home
drwxr-xr-x 21 jjguo 645 4096 Sep 16 07:08 /home/jjguo
-rw------- 1 jjguo dba 56 Sep 16 03:55 /home/jjguo/.bash_history
-rw-r--r-- 1 jjguo dba 118 Sep 11 07:20 /home/jjguo/.bashrc
drwxr-xr-x 3 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.config
-rw-r--r-- 1 jjguo dba 152 Sep 15 19:00 /home/jjguo/.cshrc
drwxr-x--- 2 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.eggcups
drwx------ 4 jjguo dba 4096 Sep 11 01:48 /home/jjguo/.gconf
drwx------ 2 jjguo dba 4096 Sep 16 00:37 /home/jjguo/.gconfd
drwx------ 4 jjguo dba 4096 Sep 9 09:18 /home/jjguo/.gnome
drwx------ 7 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.gnome2
drwx------ 2 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.gnome2_private
drwxr-xr-x 2 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.gstreamer-0.8
-rw-r--r-- 1 jjguo dba 136 Sep 9 02:17 /home/jjguo/.gtkrc-1.2-gnome2
-rw------- 1 jjguo dba 497 Sep 11 01:47 /home/jjguo/.ICEauthority
drwxrwxr-x 3 jjguo dba 4096 Sep 16 00:38 /home/jjguo/.java
drwx------ 3 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.metacity
drwx------ 3 jjguo dba 4096 Sep 10 01:55 /home/jjguo/.mozilla
drwxr-xr-x 3 jjguo dba 4096 Sep 9 02:17 /home/jjguo/.nautilus
-rw------- 1 jjguo dba 0 Sep 9 02:17 /home/jjguo/.recently-used
-rw------- 1 jjguo dba 574 Sep 14 01:48 /home/jjguo/.rhn-applet.conf
drwx------ 2 jjguo dba 4096 Sep 11 22:34 /home/jjguo/.ssh
-rw------- 1 jjguo dba 10033 Sep 16 07:08 /home/jjguo/.viminfo
-rw-r--r-- 1 jjguo dba 0 Sep 10 03:55 /home/jjguo/.viminfo.tmp
drwxr-xr-x 2 jjguo dba 4096 Sep 16 07:08 /home/jjguo/.vnc
-rw------- 1 jjguo dba 517 Sep 16 00:23 /home/jjguo/.Xauthority

Mr. C. 09-16-2008 03:05 PM

/home/jjguo should be group dba (or whatever group your jjguo belongs do).

Code:

sudo chgrp dba /home/jjguo
Please show the entire contents of your .cshrc as follows:

Code:

cat ~jjguo /.cshrc
FYI: please place code and output into [ code ] [ /code ] blocks (no spaces inside brackets), so that columns line up correctly, and formatting remains.

jjguo 09-16-2008 11:21 PM

Quote:

Originally Posted by Mr. C. (Post 3282346)
/home/jjguo should be group dba (or whatever group your jjguo belongs do).

Code:

sudo chgrp dba /home/jjguo
Please show the entire contents of your .cshrc as follows:

Code:

cat ~jjguo /.cshrc
FYI: please place code and output into [ code ] [ /code ] blocks (no spaces inside brackets), so that columns line up correctly, and formatting remains.

There is nothing in my /home/jjguo/.cshrc file like below:
Code:

[jjguo@stsdd08-4 ~]$ cat .cshrc

~
[jjguo@stsdd08-4 ~]$ csh
/home/jjguo: Permission denied.
[jjguo@stsdd08-4 ~]$


Mr. C. 09-16-2008 11:35 PM

Quote:

Originally Posted by jjguo (Post 3282653)
There is nothing in my /home/jjguo/.cshrc file like below:
Code:

[jjguo@stsdd08-4 ~]$ cat .cshrc

~
[jjguo@stsdd08-4 ~]$ csh
/home/jjguo: Permission denied.
[jjguo@stsdd08-4 ~]$


There's your answer. You are incorrect - there IS something in your .cshrc. It is that lonely, single tilde character you left from a vi session copy/paste. Remove the tilde and all will be fine.

In case you're interested, the ~ character is a shortcut equivalent of your home directory. You are trying to execute your home directory as a command, just as if you did:

Code:

$ /home/jjguo

jjguo 09-17-2008 11:29 PM

Quote:

Originally Posted by Mr. C. (Post 3282662)
There's your answer. You are incorrect - there IS something in your .cshrc. It is that lonely, single tilde character you left from a vi session copy/paste. Remove the tilde and all will be fine.

In case you're interested, the ~ character is a shortcut equivalent of your home directory. You are trying to execute your home directory as a command, just as if you did:

Code:

$ /home/jjguo

Hi Mr. C.,
You are right, the problem is fixed. Thank you very much. This problem results from my mistake.

Thank everyone who cares about this question.


All times are GMT -5. The time now is 12:57 PM.