linux - permission denied in running script
2014-04
I am running a script but there is an unusual warning: This is what happened in my console
#whoami
root
#ls -l test.sh
-rwxr-xr-x. 1 root root 1894 Feb 2 01:58 test.sh
#./test.sh
-bash: ./test.sh: Permission denied
Edit: my script:
#!/bin/bash
while read pass port user ip file; do
echo "startt------------------------------------" $ip
ping $ip -c 4
if [ $? -eq 0 ]; then
echo $ip ok...
else
echo $ip failed...
fi
echo "finish------------------------------------" $ip
done <<____HERE
pass 22 root 1.1.1.1 test.txt
____HERE
any idea? thank you
I notice that there's a .
after the permissions, which indicates that an SELinux security context applies to that file. That's probably what's preventing you from running the script. Are you in a directory where it might be a bad idea for executables to reside?
/usr/bin/editor: line 40: /tmp/crontab.BTXqyZ/crontab: Permission denied
/usr/bin/editor: line 40: exec: /tmp/crontab.BTXqyZ/crontab: cannot execute: Success
crontab: "/usr/bin/editor" exited with status 126
crontab -e was working fine a few months ago. a cron job i set up few month ago is still running successfully.
i wanted to create a new cronjob for another program and i got the above error....
/usr/bin/editor
is apparently a script, that on line 40 fails to start the actual editor, apparently trying to execute the crontab file to edit, perhaps because the path to the editor is supposed to be supplied (in an environment variable?) and isn't.
Just guessing. Have a look at that script and Google on /usr/bin/editor
.
probably that's just a permission issue of /tmp: have you already checked it with ls -la
?
May be /tmp
access mode is wrong. Check it with ls -dla /tmp
Right mode for tmp is 1777 (drwxrwxrwt)
$ ls -dla /tmp drwxrwxrwt 7 root root 4096 Jan 12 00:00 /tmp
Correct it with sudo chmod 1777 /tmp
. 1 is sticky bit http://en.wikipedia.org/wiki/Sticky_bit and 7 is read-write-execute for user, group, world