-
August 24th, 2003, 12:56 PM
#1
Member
FreeBSD Unix CHMOD Problems
Last edited by Zetaphor; February 19th, 2013 at 05:52 PM.
3 Easy Steps To Fixing Windows (Permanently!)
1) Insert Linux Installation CD (Any Distro)
2) Read Included Documentation on \"Installing\"
3) Install Linux
-
August 24th, 2003, 01:59 PM
#2
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.
-
August 24th, 2003, 06:21 PM
#3
*Moved from AntiOnline: How do I?*
-
August 24th, 2003, 06:25 PM
#4
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
There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.
(Merovingian - Matrix Reloaded)
-
August 24th, 2003, 07:57 PM
#5
Your problem is not with chmod, chmod is working fine. The problem is that there is a syntax error in your script.
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
%
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.
-
August 25th, 2003, 02:55 PM
#6
Senior Member
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
U suk at teh intuhnet1!!1!1one
-
August 25th, 2003, 04:06 PM
#7
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.
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.
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
There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.
(Merovingian - Matrix Reloaded)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|