NaN
Printable View
NaN
Firstly, make sure that you are using the same account to run the file as the one that you used to create it. If you used su to chmod, and a non-root account to create it, that is a problem (since you didn't give any permissions to anyone other than the current user) Secondly, make sure that when you gave the chmod command you gave it in the same directory as the file. If not, then you will need to provide the full path to the file in the command.
Third, to run a script or program that is not in your PATH (make sure you know what I mean by that) then you must provide the full PATH to the file or use ./, such as ./filename.
Last, here is a pretty good tutorial on some basic shell scripting for bash.
*Moved from AntiOnline: How do I?*
Try posting your script here for better help.
Did you start your script off with something like:
#!/bin/sh
It has to be the first characters on the first line. This is what tells the OS which shell interpreter to use. If you have that line there, make sure that the file exists. If not, change the line to match wherever the shell interpreter is installed (to find that, type 'which <cmd>', where cmd is something like 'sh' or 'bash' or 'perl', etc.
You also said it is producing errors, but you didn't say which ones. Post those as well, but you probably have a syntax error somewhere in there.
/nebulus
Your problem is not with chmod, chmod is working fine. The problem is that there is a syntax error in your script.
As you can see, before I did the chmod, I got a permission denied error. After the chmod, I could run the script. (Since it was empty, it didn't do anything.) When I pt some incorrect code into the script, it gave a syntax error. After I fixed the syntax, it ran properly.Code:% touch foo
% ls -l
total 0
-rw-r--r-- 1 j3r unknown 0 Aug 24 14:54 foo
% ./foo
./foo: Permission denied.
% chmod 700 foo
% ls -l
total 0
-rwx------ 1 j3r unknown 0 Aug 24 14:54 foo
% ./foo
% echo 'echo "Hello, world' > foo
% ./foo
./foo: line 1: unexpected EOF while looking for matching `"'
./foo: line 2: syntax error: unexpected end of file
% echo 'echo "Hello, world"' > foo
% ./foo
Hello, world
%
did you add the bang line in the first line of the script? if it's an sh script the first line has to read
#!/bin/sh
if it's perl or anything like that, you need to find where it is installed on the system, usually in /usr/bin so the bang line would look like
#!/usr/local/bin/perl
then to run it you'd just type ./scriptname
This is incorrect unless you are trying to overwrite an exisiting file owned by root. A script to execute must only have the 'x' bit set for whichever set of permissions your user would fall under. If you created the file, then 700 is fully adequate (it sets 'rwx' for the owner of the file, or read, write, and execute). The only thing 770 would do is allow people in whatever group the file was created to be able to read, write, or execute it.Quote:
Originally posted here by Zetaphor
I looked up the chmod command in one of my manuals, and I think the error,(syntax error), was becuase of the permissions, as keysersoze mentioned, it may be because I am using a non root account. I am going to try chmod'ing it to 770. I am at school now, so I haven't had a chance to try all these suggestions. Thank you all for your help. I will post again when I have tryed this out.
Once again, check the first line of your script. Check which shell it references, check to make sure that shell exists. If all of this is in order and you are still getting syntax errors, then post the script here and I will help you with it.
Syntax errors shouldn't have much of anything to do with file permissions.
/nebulus