1
1
I have a CentOS 6.5 64-bit dedicated server. The only thing I done on it is yum install java7
, so I have not installed any other stuff.
So in the directory /root
I made this file (test.sh
)
#!/bin/bash
while true
do
echo "Hey"
echo "You have five seconds to do 'Ctrl+C' or the while loop will continue."
sleep 5
done
I know theres nothing wrong with the code, because I have tried some other (From official websites) and I get the same errors.
So If I do:
cd /root
bash test.sh
I get this error
test.sh: line 7: syntax error near unexpected token `done'
test.sh: line 7: `done'
If I do
cd /root
./test.sh
I get this error
-bash: ./test.sh: Permission denied
I have also tried doing this in the directory /home
and I get the same errors.
PS. I'm logged in as root via SSH.
What does
echo $USER
say? What doesstat -c '%a' "./test.sh"
say? Your code above works for me. Did you forget tochmod +x /root/test.sh
? – polym – 2014-06-22T14:12:07.543$USER says "root" stat -c '%a' "./test.sh" says "644" – user3524823 – 2014-06-22T14:15:16.717
You forgot to add the executable flag. Look at @slhck's answer below. Is the code above the same as it is displayed here? I don't get why you get the line 7 error. – polym – 2014-06-22T14:19:11.273
Its exact the same code. Just copied and pasted it to double check. – user3524823 – 2014-06-22T14:20:58.537