Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011

    Unanswered: Help with permission commands and checking

    Ok so here is my problem and what I have so far.

    Rewrite the journal script of Chapter 8 (question 5, page 335) by adding commands to verify that the user has write permission for a file named journal-file in the user's home directory, if such a file exists. The script should take appropriate actions if journal-file exists and the user does not have write permission to the file. Verify that the modified script works.

    Here is the script on page 335
    $ cat journal

    # journal: add journal entries to the file

    # $HOME/journal-file


    date >> $file

    echo -n "Enter name of person or group: "

    read name

    echo "$name" >> $file

    echo >> $file

    cat >> $file

    echo "----------------------------------------------------" >> $file

    echo >> $file

    # journal: add journal enteries to the file
    # ~/journal-file
    date >> $file
    echo -n "Enter name of person or group: "
    read name
    echo "$name" >> $file
    echo >> $file
    cat >> $file
    echo "-----------------------------------------" >> $file
    echo >> $file

    The other problem is
    Write a short script that tells you whether the permissions for two files, whose names are given as arguments to the script, are identical. If the permissions for the two files are identical, output the common permission field. Otherwise, output each filename followed by its permission field. (Hint: Try using the cut utility.)

    # sh comparefiles 1 2
    file1_p=$(ls -l $1 | cut -c2-10)
    file2_p=$(ls -l $2 | cut -c2-10)

    if [ "$file1_p" = "$file2_p" ]; then
    echo "match."
    echo $file1_p
    echo "don't match."
    echo $1 $file1_p
    echo $2 $file2_p

    These problems I can't get it to run right... Any help. I think theres something wrong with the else if in the second problem

  2. #2
    Join Date
    May 2005
    South Africa
    Provided Answers: 1
    What does "I can't get it to run right" mean?
    What error message do you get?
    The 2nd script seems OK

Tags for this Thread

Posting Permissions

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