Exit bash when find gets to a folder with permission denied Announcing the arrival of Valued...

Why did the rest of the Eastern Bloc not invade Yugoslavia?

How does debian/ubuntu knows a package has a updated version

Why do we bend a book to keep it straight?

What exactly is a "Meth" in Altered Carbon?

Why do people hide their license plates in the EU?

Is it true that "carbohydrates are of no use for the basal metabolic need"?

How widely used is the term Treppenwitz? Is it something that most Germans know?

How to align text above triangle figure

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

Should I discuss the type of campaign with my players?

What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?

How to answer "Have you ever been terminated?"

Seeking colloquialism for “just because”

Why did the Falcon Heavy center core fall off the ASDS OCISLY barge?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Why did the IBM 650 use bi-quinary?

How can I make names more distinctive without making them longer?

porting install scripts : can rpm replace apt?

Can a USB port passively 'listen only'?

What's the meaning of 間時肆拾貳 at a car parking sign

What to do with chalk when deepwater soloing?

What is Arya's weapon design?



Exit bash when find gets to a folder with permission denied



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionExpected behavior of `find -depth` if execute permission denied for subdirectory?Mounting Windows shares using cifs results in “Error:13(Permission denied)”Write a file in /var/lib/sysnews/Why do I get “Permission Denied” errors even though I have group permission?shell for loop with find with filenames containing spacesAccess denied on folders for users though they have the rwx permission on SUSE LinuxSudo mkdir fails due to permission denied errorHow to avoid error-message during the execution of a bash script?Samba shared folder with setgid problemEcho Permission Denied (Trying to use echo instead of ls command in shell script)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















I'm trying to write a Bash script. Where I go through folders recursively and make a list of and count files and folders.



In a way it works but if "find" gets to a directory where it has permission denied it just continues the script. Skipping the directory not counting files in it nor telling me the directory is permission denied.
(other than a useless terminal command which I can't use since the scripts is run through file-manager custom actions)



I would like it to when "find" finds a permission denied folder to stop the searching process and report to me what folder has permission denied. So I know what its skipping and why.



Half my code looks like this



#!/bin/bash

allfolders=("$@")
nfolders="0"

Nfilesinfolders="0"
filesinfolder="0"

results=""
noteadded="0"

for directory in "${allfolders[@]}"; do

echo "This is where I try and insert the code examples below.
echo "and want it to exit with a zenity error"

nfolders=$(( nfolders + 1 ))
echo "$nfolders"

if [[ $nfolders -ge 11 ]]
then
if [[ $noteadded -ge 0 ]]
then
results+="n"
results+="Not adding any more folders to the list. Look at the top for total number of files"
noteadded=1
fi
else
results+="$directoryn"
fi

echo "This below attempt only worked on the top folder not folders in it"

if [[ -r "$directory" ]] && [[ -w "$directory" ]]
then
filesinfolder=$(find "$directory" -depth -type f -printf '.' | wc -c)
Nfilesinfolders=$(( Nfilesinfolders + filesinfolder ))
else
zenity --error --title="Error occured check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
exit $?
fi
done


Here are then some of my failed attempts



find "$directory" -depth -type d -print0 | while IFS= read -r -d $'' currentdir
do
echo "Checking "$currentdir" in directory "$directory""
if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
then
zenity --error --title="Error occurred check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
exit $?
fi
done


The above code seems like its just getting skipped and continues on the script.



The next one looked like this. I could get it to report an error but not tell me what folder that went wrong.



shredout=$(find "$directory" -depth -type d -print0 2>&1 | grep "Permission denied" && echo "found Permission Denied" && checkfolderperm="1" )

if [[ $checkfolderperm -eq 1 ]]
then
zenity --error --title="Error occurred check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
exit $?
fi


But the above also seems like its just getting skipped.



the last one is all-most like my first try.



while IFS= read -r -d $'' currentdir; do
echo "going through file = $currentdir in folder $directory"
if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
then
zenity --error --title="Error occured check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
exit $?
fi
done < <(find "$directory" -depth -type d -print0)


but that also gets skipped.



Is there any way for me to go through folders with find. Then stop and report if a directory is permission denied.



I've come across bash "traps" and bash "functions" but can't figure out if they are my solution or how to use them.





This is the resulting code after help from "meuh".
It stops the script and reports exactly what folder/folder's it doesn't have permission to. Hope it can help others like it did me.



if finderrors=$(! find "$directory" -depth -type d 2>&1 1>/dev/null)
then
zenity --error --title="Error occurred check message" --text="$finderrors"
exit $?
fi









share|improve this question































    3















    I'm trying to write a Bash script. Where I go through folders recursively and make a list of and count files and folders.



    In a way it works but if "find" gets to a directory where it has permission denied it just continues the script. Skipping the directory not counting files in it nor telling me the directory is permission denied.
    (other than a useless terminal command which I can't use since the scripts is run through file-manager custom actions)



    I would like it to when "find" finds a permission denied folder to stop the searching process and report to me what folder has permission denied. So I know what its skipping and why.



    Half my code looks like this



    #!/bin/bash

    allfolders=("$@")
    nfolders="0"

    Nfilesinfolders="0"
    filesinfolder="0"

    results=""
    noteadded="0"

    for directory in "${allfolders[@]}"; do

    echo "This is where I try and insert the code examples below.
    echo "and want it to exit with a zenity error"

    nfolders=$(( nfolders + 1 ))
    echo "$nfolders"

    if [[ $nfolders -ge 11 ]]
    then
    if [[ $noteadded -ge 0 ]]
    then
    results+="n"
    results+="Not adding any more folders to the list. Look at the top for total number of files"
    noteadded=1
    fi
    else
    results+="$directoryn"
    fi

    echo "This below attempt only worked on the top folder not folders in it"

    if [[ -r "$directory" ]] && [[ -w "$directory" ]]
    then
    filesinfolder=$(find "$directory" -depth -type f -printf '.' | wc -c)
    Nfilesinfolders=$(( Nfilesinfolders + filesinfolder ))
    else
    zenity --error --title="Error occured check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
    exit $?
    fi
    done


    Here are then some of my failed attempts



    find "$directory" -depth -type d -print0 | while IFS= read -r -d $'' currentdir
    do
    echo "Checking "$currentdir" in directory "$directory""
    if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
    then
    zenity --error --title="Error occurred check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
    exit $?
    fi
    done


    The above code seems like its just getting skipped and continues on the script.



    The next one looked like this. I could get it to report an error but not tell me what folder that went wrong.



    shredout=$(find "$directory" -depth -type d -print0 2>&1 | grep "Permission denied" && echo "found Permission Denied" && checkfolderperm="1" )

    if [[ $checkfolderperm -eq 1 ]]
    then
    zenity --error --title="Error occurred check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
    exit $?
    fi


    But the above also seems like its just getting skipped.



    the last one is all-most like my first try.



    while IFS= read -r -d $'' currentdir; do
    echo "going through file = $currentdir in folder $directory"
    if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
    then
    zenity --error --title="Error occured check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
    exit $?
    fi
    done < <(find "$directory" -depth -type d -print0)


    but that also gets skipped.



    Is there any way for me to go through folders with find. Then stop and report if a directory is permission denied.



    I've come across bash "traps" and bash "functions" but can't figure out if they are my solution or how to use them.





    This is the resulting code after help from "meuh".
    It stops the script and reports exactly what folder/folder's it doesn't have permission to. Hope it can help others like it did me.



    if finderrors=$(! find "$directory" -depth -type d 2>&1 1>/dev/null)
    then
    zenity --error --title="Error occurred check message" --text="$finderrors"
    exit $?
    fi









    share|improve this question



























      3












      3








      3


      1






      I'm trying to write a Bash script. Where I go through folders recursively and make a list of and count files and folders.



      In a way it works but if "find" gets to a directory where it has permission denied it just continues the script. Skipping the directory not counting files in it nor telling me the directory is permission denied.
      (other than a useless terminal command which I can't use since the scripts is run through file-manager custom actions)



      I would like it to when "find" finds a permission denied folder to stop the searching process and report to me what folder has permission denied. So I know what its skipping and why.



      Half my code looks like this



      #!/bin/bash

      allfolders=("$@")
      nfolders="0"

      Nfilesinfolders="0"
      filesinfolder="0"

      results=""
      noteadded="0"

      for directory in "${allfolders[@]}"; do

      echo "This is where I try and insert the code examples below.
      echo "and want it to exit with a zenity error"

      nfolders=$(( nfolders + 1 ))
      echo "$nfolders"

      if [[ $nfolders -ge 11 ]]
      then
      if [[ $noteadded -ge 0 ]]
      then
      results+="n"
      results+="Not adding any more folders to the list. Look at the top for total number of files"
      noteadded=1
      fi
      else
      results+="$directoryn"
      fi

      echo "This below attempt only worked on the top folder not folders in it"

      if [[ -r "$directory" ]] && [[ -w "$directory" ]]
      then
      filesinfolder=$(find "$directory" -depth -type f -printf '.' | wc -c)
      Nfilesinfolders=$(( Nfilesinfolders + filesinfolder ))
      else
      zenity --error --title="Error occured check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done


      Here are then some of my failed attempts



      find "$directory" -depth -type d -print0 | while IFS= read -r -d $'' currentdir
      do
      echo "Checking "$currentdir" in directory "$directory""
      if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
      then
      zenity --error --title="Error occurred check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done


      The above code seems like its just getting skipped and continues on the script.



      The next one looked like this. I could get it to report an error but not tell me what folder that went wrong.



      shredout=$(find "$directory" -depth -type d -print0 2>&1 | grep "Permission denied" && echo "found Permission Denied" && checkfolderperm="1" )

      if [[ $checkfolderperm -eq 1 ]]
      then
      zenity --error --title="Error occurred check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi


      But the above also seems like its just getting skipped.



      the last one is all-most like my first try.



      while IFS= read -r -d $'' currentdir; do
      echo "going through file = $currentdir in folder $directory"
      if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
      then
      zenity --error --title="Error occured check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done < <(find "$directory" -depth -type d -print0)


      but that also gets skipped.



      Is there any way for me to go through folders with find. Then stop and report if a directory is permission denied.



      I've come across bash "traps" and bash "functions" but can't figure out if they are my solution or how to use them.





      This is the resulting code after help from "meuh".
      It stops the script and reports exactly what folder/folder's it doesn't have permission to. Hope it can help others like it did me.



      if finderrors=$(! find "$directory" -depth -type d 2>&1 1>/dev/null)
      then
      zenity --error --title="Error occurred check message" --text="$finderrors"
      exit $?
      fi









      share|improve this question
















      I'm trying to write a Bash script. Where I go through folders recursively and make a list of and count files and folders.



      In a way it works but if "find" gets to a directory where it has permission denied it just continues the script. Skipping the directory not counting files in it nor telling me the directory is permission denied.
      (other than a useless terminal command which I can't use since the scripts is run through file-manager custom actions)



      I would like it to when "find" finds a permission denied folder to stop the searching process and report to me what folder has permission denied. So I know what its skipping and why.



      Half my code looks like this



      #!/bin/bash

      allfolders=("$@")
      nfolders="0"

      Nfilesinfolders="0"
      filesinfolder="0"

      results=""
      noteadded="0"

      for directory in "${allfolders[@]}"; do

      echo "This is where I try and insert the code examples below.
      echo "and want it to exit with a zenity error"

      nfolders=$(( nfolders + 1 ))
      echo "$nfolders"

      if [[ $nfolders -ge 11 ]]
      then
      if [[ $noteadded -ge 0 ]]
      then
      results+="n"
      results+="Not adding any more folders to the list. Look at the top for total number of files"
      noteadded=1
      fi
      else
      results+="$directoryn"
      fi

      echo "This below attempt only worked on the top folder not folders in it"

      if [[ -r "$directory" ]] && [[ -w "$directory" ]]
      then
      filesinfolder=$(find "$directory" -depth -type f -printf '.' | wc -c)
      Nfilesinfolders=$(( Nfilesinfolders + filesinfolder ))
      else
      zenity --error --title="Error occured check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done


      Here are then some of my failed attempts



      find "$directory" -depth -type d -print0 | while IFS= read -r -d $'' currentdir
      do
      echo "Checking "$currentdir" in directory "$directory""
      if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
      then
      zenity --error --title="Error occurred check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done


      The above code seems like its just getting skipped and continues on the script.



      The next one looked like this. I could get it to report an error but not tell me what folder that went wrong.



      shredout=$(find "$directory" -depth -type d -print0 2>&1 | grep "Permission denied" && echo "found Permission Denied" && checkfolderperm="1" )

      if [[ $checkfolderperm -eq 1 ]]
      then
      zenity --error --title="Error occurred check message" --text="The directoryn $directoryn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi


      But the above also seems like its just getting skipped.



      the last one is all-most like my first try.



      while IFS= read -r -d $'' currentdir; do
      echo "going through file = $currentdir in folder $directory"
      if [[ ! -r "$currentdir" ]] && [[ ! -w "$currentdir" ]]
      then
      zenity --error --title="Error occured check message" --text="The directoryn $currentdirn is not readable or write-able to you $USERn please run as root"
      exit $?
      fi
      done < <(find "$directory" -depth -type d -print0)


      but that also gets skipped.



      Is there any way for me to go through folders with find. Then stop and report if a directory is permission denied.



      I've come across bash "traps" and bash "functions" but can't figure out if they are my solution or how to use them.





      This is the resulting code after help from "meuh".
      It stops the script and reports exactly what folder/folder's it doesn't have permission to. Hope it can help others like it did me.



      if finderrors=$(! find "$directory" -depth -type d 2>&1 1>/dev/null)
      then
      zenity --error --title="Error occurred check message" --text="$finderrors"
      exit $?
      fi






      bash shell-script permissions find directory






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 hours ago









      Rui F Ribeiro

      42.1k1484142




      42.1k1484142










      asked Aug 26 '15 at 9:59









      DarkyereDarkyere

      186




      186






















          1 Answer
          1






          active

          oldest

          votes


















          8














          find will set its return code to non-zero if it saw an error. So you can do:



          if ! find ... 
          then echo had an error >&2
          fi |
          while ...


          (I'm not sure what you want to do with the find output).





          To collect all the error messages from find on stderr (file descriptor 2) you can redirect 2 to a file. Eg:



          if ! find ... 2>/tmp/errors
          then zenity --error --text "$(</tmp/errors)"
          fi |
          while ...





          share|improve this answer


























          • It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

            – Darkyere
            Aug 26 '15 at 10:34













          • I added to my answer how to collect the error messages.

            – meuh
            Aug 26 '15 at 10:54











          • Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

            – Darkyere
            Aug 26 '15 at 11:26











          • Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

            – Darkyere
            Aug 26 '15 at 14:58











          • You could "set -e" ... but be mindful of its side effects...

            – rackandboneman
            Jan 6 '16 at 9:34












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f225572%2fexit-bash-when-find-gets-to-a-folder-with-permission-denied%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8














          find will set its return code to non-zero if it saw an error. So you can do:



          if ! find ... 
          then echo had an error >&2
          fi |
          while ...


          (I'm not sure what you want to do with the find output).





          To collect all the error messages from find on stderr (file descriptor 2) you can redirect 2 to a file. Eg:



          if ! find ... 2>/tmp/errors
          then zenity --error --text "$(</tmp/errors)"
          fi |
          while ...





          share|improve this answer


























          • It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

            – Darkyere
            Aug 26 '15 at 10:34













          • I added to my answer how to collect the error messages.

            – meuh
            Aug 26 '15 at 10:54











          • Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

            – Darkyere
            Aug 26 '15 at 11:26











          • Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

            – Darkyere
            Aug 26 '15 at 14:58











          • You could "set -e" ... but be mindful of its side effects...

            – rackandboneman
            Jan 6 '16 at 9:34
















          8














          find will set its return code to non-zero if it saw an error. So you can do:



          if ! find ... 
          then echo had an error >&2
          fi |
          while ...


          (I'm not sure what you want to do with the find output).





          To collect all the error messages from find on stderr (file descriptor 2) you can redirect 2 to a file. Eg:



          if ! find ... 2>/tmp/errors
          then zenity --error --text "$(</tmp/errors)"
          fi |
          while ...





          share|improve this answer


























          • It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

            – Darkyere
            Aug 26 '15 at 10:34













          • I added to my answer how to collect the error messages.

            – meuh
            Aug 26 '15 at 10:54











          • Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

            – Darkyere
            Aug 26 '15 at 11:26











          • Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

            – Darkyere
            Aug 26 '15 at 14:58











          • You could "set -e" ... but be mindful of its side effects...

            – rackandboneman
            Jan 6 '16 at 9:34














          8












          8








          8







          find will set its return code to non-zero if it saw an error. So you can do:



          if ! find ... 
          then echo had an error >&2
          fi |
          while ...


          (I'm not sure what you want to do with the find output).





          To collect all the error messages from find on stderr (file descriptor 2) you can redirect 2 to a file. Eg:



          if ! find ... 2>/tmp/errors
          then zenity --error --text "$(</tmp/errors)"
          fi |
          while ...





          share|improve this answer















          find will set its return code to non-zero if it saw an error. So you can do:



          if ! find ... 
          then echo had an error >&2
          fi |
          while ...


          (I'm not sure what you want to do with the find output).





          To collect all the error messages from find on stderr (file descriptor 2) you can redirect 2 to a file. Eg:



          if ! find ... 2>/tmp/errors
          then zenity --error --text "$(</tmp/errors)"
          fi |
          while ...






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 26 '15 at 10:53

























          answered Aug 26 '15 at 10:06









          meuhmeuh

          32.5k12255




          32.5k12255













          • It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

            – Darkyere
            Aug 26 '15 at 10:34













          • I added to my answer how to collect the error messages.

            – meuh
            Aug 26 '15 at 10:54











          • Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

            – Darkyere
            Aug 26 '15 at 11:26











          • Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

            – Darkyere
            Aug 26 '15 at 14:58











          • You could "set -e" ... but be mindful of its side effects...

            – rackandboneman
            Jan 6 '16 at 9:34



















          • It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

            – Darkyere
            Aug 26 '15 at 10:34













          • I added to my answer how to collect the error messages.

            – meuh
            Aug 26 '15 at 10:54











          • Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

            – Darkyere
            Aug 26 '15 at 11:26











          • Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

            – Darkyere
            Aug 26 '15 at 14:58











          • You could "set -e" ... but be mindful of its side effects...

            – rackandboneman
            Jan 6 '16 at 9:34

















          It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

          – Darkyere
          Aug 26 '15 at 10:34







          It solved halve my puzzle thank you. Now i can make it show zenity and exit if an error occur. Now the other problem im still having is it only reports the main directory etc. "find /etc/test1 -depth -type d". It only reports an error in "/etc/test1" I would like it to report the actual folder with permission denied. "/etc/test1/permissiondenied" folder. Is that possible to ?

          – Darkyere
          Aug 26 '15 at 10:34















          I added to my answer how to collect the error messages.

          – meuh
          Aug 26 '15 at 10:54





          I added to my answer how to collect the error messages.

          – meuh
          Aug 26 '15 at 10:54













          Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

          – Darkyere
          Aug 26 '15 at 11:26





          Ty for the answer i just noticed. I will try this and see if i can add the error to a string or array instead to work with. If thats even possible. Right now ive just had a friend pop in the doors so ill have to wait to try for now. Thank you by the way for answering me so far it got me further than ive been before.

          – Darkyere
          Aug 26 '15 at 11:26













          Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

          – Darkyere
          Aug 26 '15 at 14:58





          Ty so much for you assistance. By your help i can now make it stop and report exactly which folder has permission denied. I will add the very smal code to the bottom of my post at the top. For other people to find yousefull or comment about :) Ty and best regards

          – Darkyere
          Aug 26 '15 at 14:58













          You could "set -e" ... but be mindful of its side effects...

          – rackandboneman
          Jan 6 '16 at 9:34





          You could "set -e" ... but be mindful of its side effects...

          – rackandboneman
          Jan 6 '16 at 9:34


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f225572%2fexit-bash-when-find-gets-to-a-folder-with-permission-denied%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...