Find the answer to your Linux question:
Results 1 to 6 of 6
If you execute a shell script ie: ./script.sh and you either: a) Do not have permission to execute the script or b) Do not have permission to execute commands inside ...
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    19

    ./script.sh Permission?

    If you execute a shell script ie: ./script.sh and you
    either:
    a) Do not have permission to execute the script or

    b) Do not have permission to execute commands inside the script

    - Will it return an error message on the lines of "Can't execute....<blah>" or will it not return anything?

    This script is running on a Solaris 9 system but I am happy to hear about what happens on all distro's.

    Regards,
    Narkie.

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Well, let's test it, shall we? I shall execute the following script as a regular user:
    Code:
    #!/bin/bash
    
    ./other_command
    I do not have permission to execute "./other_command". Now let's see what happens:
    Code:
    alex@danu ~/test/bash $ ls -l no_perm 
    -rw-r--r-- 1 alex users 29 Oct 19 00:18 no_perm
    alex@danu ~/test/bash $ ./no_perm
    bash: ./no_perm: Permission denied
    alex@danu ~/test/bash $ chmod +x no_perm
    alex@danu ~/test/bash $ ls -l no_perm 
    -rwxr-xr-x 1 alex users 29 Oct 19 00:18 no_perm
    alex@danu ~/test/bash $ ./no_perm 
    ./no_perm: line 3: ./other_command: Permission denied
    Does this match what you expected?
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Apr 2007
    Posts
    19

    Post

    Hmmm, not quite. I am getting ZERO output. I was thinking it was a permission's thing and I can't *get* the permissions at this stage either.

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    What do you mean you can't get the permissions? "ls -l" will show you the permissions.

    Also, perhaps you can show us exactly what you're trying to do?
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    37
    Zero output where? You need to redirect errors somewhere. You could also include this in your script.

    example:

    echo "hello" >> file_I_do_not_have_permission_to_write_to 2>/root/error.log

  6. #6
    Just Joined!
    Join Date
    Apr 2007
    Posts
    19
    I just could not get access to an account with MORE permissions. ie: root level access. Anyway, the issue has been solved - although I can not give details as the script was just replaced with a known working version
    - so there was just an issue with the script.

    (>'ing it to an output did nothing at all, there was something seriously wrong with this script.)

Posting Permissions

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