Find the answer to your Linux question:
Results 1 to 4 of 4
hi this is my first time to write script. i wrote simple script like the following : $ vi first # # My first shell script # clear echo "Knowledge ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    9

    Cool simple script problem

    hi this is my first time to write script.
    i wrote simple script like the following :
    $ vi first
    #
    # My first shell script
    #
    clear
    echo "Knowledge is Power"

    when i tried to run it , i use the following command:
    [linux@localhost Desktop]$ ./script

    but the result is :
    bash: ./script: Permission denied

    but when i tried " bash script" it work fine.
    can any body give me the reason.

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Posts
    9

    Cool trivial solution

    i'm sorry for this trivial problem ... but i know the reason of problem.
    you should set the permission for the file like this:
    [linux@localhost Desktop]$ chmod 755 script

    and then "./script" work fine.

  3. #3
    Just Joined!
    Join Date
    Oct 2006
    Location
    Denmark, Løgstør
    Posts
    42
    You have to change the permissions of the file. write:

    chmod 755 scriptname

    and that should work.

    This page should answer why it works..
    Writing shell scripts - Lesson 1: Writing your first script and getting it to work

  4. #4
    Just Joined!
    Join Date
    Jul 2007
    Posts
    3
    You can also use your GUI file manager to set permissions also. This may be easier for a new Linux user but if you want to write shell scripts it would be better to use your shell to set the permissions for your scripts. chmod can also change file permissions like this. chmod go+wrx . Using - takes away and + gives permissions, g is group, o is owner and wrx are for write, read and execute . Typing in your shell (man chmod) will give you the manual page on this command which explains how to use the command. Also info command will often give more information on a command .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...