Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Permissions - passing a file as the argument

  • 10-09-2007 12:07pm
    #1
    Closed Accounts Posts: 91 ✭✭


    this is the only way i can think of to do this but there must be a better way or else im gonna end up writing 200 lines of copy and pasting code.


    echo ' READ WRITE EXECUTE'


    own=$(ls -al $1 |cut -c2)

    if ($own==r) then
    first=yes
    else
    first=no
    endif
    echo $first



    Im writing a script that takes a file as an argument and it basically checks the permissions the owner and group and everbody has for the file passed in.
    I need the output to look something like this

    READ WRITE EXECUTE
    OWNER LEE.BALLANCORE YES YES NO
    GROUP USERS YES NO NO
    EVERYBODY NO NO NO


Comments

  • Closed Accounts Posts: 91 ✭✭magnia


    i got this to work but not exactly the way i wanted it to. can anyone think of how to improve it?


    #!/bin/bash

    echo ' r w x'

    own=$(ls -al $1 |cut -c2)
    if [ $own = "r" ] ; then first=y; else first=n; fi
    # echo $own

    own1=$(ls -al $1 |cut -c3)
    if [ $own1 = "w" ] ; then second=y ; else second=n; fi
    # echo $own1

    own2=$(ls -al $1 |cut -c4)
    if [ $own2 = "x" ] ; then third=y; else third=n; fi
    # echo $own2
    echo OWNER $first $second $third

    own3=$(ls -al $1 |cut -c5)
    if [ $own3 = "r" ] ; then fourth=y; else fourth=n; fi
    #echo $own3

    own4=$(ls -al $1 |cut -c6)
    if [ $own4 = "w" ] ; then fifth=y; else fifth=n; fi
    #echo $own4

    own5=$(ls -al $1 |cut -c7)
    if [ $own5 = "x" ] ; then sixth=y; else sixth=n; fi
    # echo $own5
    echo GROUP $fourth $fifth $sixth

    own6=$(ls -al $1 |cut -c8)
    if [ $own6 = "r" ] ; then seventh=y; else seventh=n; fi
    #echo $own6

    own7=$(ls -al $1 |cut -c9)
    if [ $own7 = "w" ] ; then eighth=y; else eighth=n; fi
    #echo $own7

    own8=$(ls -al $1 |cut -c10)
    if [ $own8 = "x" ] ; then ninth=y; else ninth=n; fi
    #echo $own8
    echo OTHER $seventh $eight $ninth


  • Registered Users, Registered Users 2 Posts: 1,421 ✭✭✭Steveire


    Can you use python? The stat module might be useful.

    http://www.ibm.com/developerworks/aix/library/au-python/


Advertisement