{"id":385381,"date":"2024-11-21T08:43:33","date_gmt":"2024-11-21T08:43:33","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=385381"},"modified":"2024-11-21T08:43:33","modified_gmt":"2024-11-21T08:43:33","slug":"existenz-von-dateien-ueberpruefen-2","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/existenz-von-dateien-ueberpruefen-2\/","title":{"rendered":"Wie man das Vorhandensein von Dateien und Ordnern unter macOS automatisiert \u00fcberpr\u00fcft"},"content":{"rendered":"<p>In der IT-Welt kann die Automatisierung von sich wiederholenden Aufgaben Zeit sparen und Fehler reduzieren. Eine solche Aufgabe ist die \u00dcberpr\u00fcfung des Vorhandenseins bestimmter Dateien oder Ordner in mehreren Verzeichnissen. Ob f\u00fcr die Compliance, die System\u00fcberwachung oder die Fehlerbehebung, eine <strong>automatisierte Methode zur \u00dcberpr\u00fcfung der Existenz von Dateien<\/strong> kann f\u00fcr IT-Experten und <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\" target=\"_blank\" rel=\"noopener\">Managed Service Provider (MSPs)<\/a> von unsch\u00e4tzbarem Wert sein. In diesem Blogbeitrag wird ein Bash-Skript vorgestellt, das diesen Prozess rationalisiert und f\u00fcr eine effiziente und zuverl\u00e4ssige Dateiverwaltung sorgt.<\/p>\n<h2>Kontext<\/h2>\n<p>Dieses Skript ist besonders n\u00fctzlich f\u00fcr IT-Experten, die die Existenz wichtiger Dateien oder Ordner regelm\u00e4\u00dfig \u00fcberpr\u00fcfen m\u00fcssen. Es bietet eine <a href=\"https:\/\/www.ninjaone.com\/de\/blog\/alles-was-sie-ueber-it-automatisierung-wissen-muessen\/\" target=\"_blank\" rel=\"noopener\">automatisierte L\u00f6sung<\/a> zum Durchsuchen von Verzeichnissen, um sicherzustellen, dass wichtige Dateien vorhanden sind oder um zu erkennen, wenn sie fehlen. Diese F\u00e4higkeit ist in verschiedenen Szenarien von entscheidender Bedeutung, z. B. bei der \u00dcberpr\u00fcfung der Speicherorte von Backups, der Gew\u00e4hrleistung des Vorhandenseins von Konfigurationsdateien oder der Best\u00e4tigung der Bereitstellung kritischer Anwendungen.<\/p>\n<h2>Das Skript zur \u00dcberpr\u00fcfung der Existenz von Dateien und Ordnern<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n\r\n# Description: Alert if a specified file or folder is found in a directory or subdirectory you specify.\r\n#\r\n# Release Notes: Initial Release\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n# Below are all the (case sensitive) valid parameters for this script.\r\n# Only the path to search and name of file or folder are required!\r\n#\r\n# Parameter: --path \"\/opt\/NinjaRMM\/programdata\"\r\n#   Required\r\n#   Base path to search for files or folders.\r\n#\r\n# Parameter: --name \"ninjarmm-cli\"\r\n#   Required\r\n#   Name of the file or folder to search for.\r\n#   Notes:\r\n#       If the name is not provided, the script will search for the path only.\r\n#       This is case sensitive and accepts wildcards.\r\n#\r\n# Parameter: --type \"Files Or Folders\"\r\n#   Required\r\n#   Search for files or folders.\r\n#\r\n# Parameter: --type \"Files Only\"\r\n#   Required\r\n#   Searches for files only.\r\n#\r\n# Parameter: --type \"Folders Only\"\r\n#   Required\r\n#   Searches for folder only.\r\n#\r\n# Parameter: --timeout 10\r\n#   Optional and defaults to 30 minutes\r\n#   Time in minutes to wait for the search to complete before timing out.\r\n#\r\n# Parameter: --customfield \"myCustomField\"\r\n#   Optional\r\n#   Custom Field to save the search results to.\r\n\r\ndie() {\r\n    local _ret=\"${2:-1}\"\r\n    test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n    echo \"$1\" &gt;&amp;2\r\n    exit \"${_ret}\"\r\n}\r\n\r\nbegins_with_short_option() {\r\n    local first_option all_short_options='h'\r\n    first_option=\"${1:0:1}\"\r\n    test \"$all_short_options\" = \"${all_short_options\/$first_option\/}\" &amp;&amp; return 1 || return 0\r\n}\r\n\r\n# Initize arguments\r\n_arg_path=\r\n_arg_name=\r\n_arg_type=\r\n_arg_timeout=30\r\n_arg_customfield=\r\n\r\nprint_help() {\r\n    printf '%s\\n' \"Check existence of a file or folder\"\r\n    printf 'Usage: %s [--path &lt;arg&gt;] [--name &lt;arg&gt;] [--type &lt;\"Files Only\"|\"Folders Only\"|\"Files Or Folders\"&gt;] [--timeout &lt;30&gt;] [--customfield &lt;arg&gt;] [-h|--help]\\n' \"$0\"\r\n    printf '\\t%s\\n' \"-h, --help: Prints help\"\r\n}\r\n\r\nparse_commandline() {\r\n    while test $# -gt 0; do\r\n        _key=\"$1\"\r\n        case \"$_key\" in\r\n        --path)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_path=\"$2\"\r\n            shift\r\n            ;;\r\n        --path=*)\r\n            _arg_path=\"${_key##--path=}\"\r\n            ;;\r\n        --name)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_name=\"$2\"\r\n            shift\r\n            ;;\r\n        --name=*)\r\n            _arg_name=\"${_key##--name=}\"\r\n            ;;\r\n        --type)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_type=\"$2\"\r\n            shift\r\n            ;;\r\n        --type=*)\r\n            _arg_type=\"${_key##--type=}\"\r\n            ;;\r\n        --timeout)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_timeout=\"$2\"\r\n            shift\r\n            ;;\r\n        --timeout=*)\r\n            _arg_timeout=\"${_key##--timeout=}\"\r\n            ;;\r\n        --customfield)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_customfield=\"$2\"\r\n            shift\r\n            ;;\r\n        --customfield=*)\r\n            _arg_customfield=\"${_key##--customfield=}\"\r\n            ;;\r\n        -h | --help)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        -h*)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        *)\r\n            _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n            ;;\r\n        esac\r\n        shift\r\n    done\r\n}\r\n\r\nparse_commandline \"$@\"\r\n\r\nfunction SetCustomField() {\r\n    customfieldName=$1\r\n    customfieldValue=$2\r\n    if [ -f \"${NINJA_DATA_PATH}\/ninjarmm-cli\" ]; then\r\n        if [ -x \"${NINJA_DATA_PATH}\/ninjarmm-cli\" ]; then\r\n            if \"$NINJA_DATA_PATH\"\/ninjarmm-cli get \"$customfieldName\" &gt;\/dev\/null; then\r\n                # check if the value is greater than 10000 characters\r\n                if [ ${#customfieldValue} -gt 10000 ]; then\r\n                    echo \"[Warn] Custom field value is greater than 10000 characters\"\r\n                fi\r\n                if ! echo \"${customfieldValue::10000}\" | \"$NINJA_DATA_PATH\"\/ninjarmm-cli set --stdin \"$customfieldName\"; then\r\n                    echo \"[Warn] Failed to set custom field\"\r\n                else\r\n                    echo \"[Info] Custom field value set successfully\"\r\n                fi\r\n            else\r\n                echo \"[Warn] Custom Field ($customfieldName) does not exist or agent does not have permission to access it\"\r\n            fi\r\n        else\r\n            echo \"[Warn] ninjarmm-cli is not executable\"\r\n        fi\r\n    else\r\n        echo \"[Warn] ninjarmm-cli does not exist\"\r\n    fi\r\n}\r\n\r\nif [ ! \"$(command -v timeout)\" ]; then\r\n    notimeout=true\r\n    # If the timeout command does not exist, create a function to mimic the timeout command\r\n    function timeout() { perl -e 'alarm shift; exec @ARGV' \"$@\"; }\r\nfi\r\n\r\nparentSearchPath=$_arg_path\r\nleafSearchName=$_arg_name\r\nsearchType=$_arg_type\r\ntimeout=$_arg_timeout\r\ncustomField=$_arg_customfield\r\n\r\n# Get values from Script Variables\r\nif [[ -n \"${pathToSearch}\" ]]; then\r\n    parentSearchPath=\"${pathToSearch}\"\r\nfi\r\nif [[ -n \"${nameOfFileOrFolder}\" ]]; then\r\n    leafSearchName=\"${nameOfFileOrFolder}\"\r\nfi\r\nif [[ -n \"${filesOrFolders}\" &amp;&amp; \"${filesOrFolders}\" != \"null\" ]]; then\r\n    searchType=\"${filesOrFolders}\"\r\nfi\r\nif [[ -n \"${searchTimeout}\" &amp;&amp; \"${searchTimeout}\" != \"null\" ]]; then\r\n    timeout=\"${searchTimeout}\"\r\nfi\r\nif [[ -n \"${customFieldName}\" &amp;&amp; \"${customFieldName}\" != \"null\" ]]; then\r\n    customField=\"${customFieldName}\"\r\nfi\r\n\r\n# Check if parentSearchPath is a link and replace it with the resolved path\r\nif [ -L \"${parentSearchPath}\" ]; then\r\n    echo \"[Info] Path to Search is a link: ${parentSearchPath} -&gt; $(readlink -f \"${parentSearchPath}\")\"\r\n    echo \"[Info] Will use the resolved path to search\"\r\n    parentSearchPath=$(readlink -f \"${parentSearchPath}\")\r\nfi\r\n\r\nif [[ -z \"${parentSearchPath}\" ]]; then\r\n    echo \"[Error] Path to Search is empty\"\r\n    exit 1\r\nfi\r\n\r\n# Check if path exists\r\nif [ -e \"${parentSearchPath}\" ]; then\r\n    echo \"[Info] Path ${parentSearchPath} exists\"\r\nelse\r\n    echo \"[Error] Path to Search ${parentSearchPath} does not exist or is an invalid path\"\r\n    exit 1\r\nfi\r\n\r\n# Check if timeout is a number\r\nif ! [[ \"${timeout}\" =~ ^[0-9]+$ ]]; then\r\n    echo \"[Error] Timeout is not a number\"\r\n    exit 1\r\nfi\r\n# Check if timeout is not in the range of 1 to 120\r\nif [[ \"${timeout}\" -lt 1 || \"${timeout}\" -gt 120 ]]; then\r\n    echo \"[Error] Timeout is not in the range of 1 to 120\"\r\n    exit 1\r\nfi\r\n\r\n# Check if search type is valid\r\n\r\nif $notimeout; then\r\n    # If the timeout command does not exist, convert the timeout to minutes\r\n    timeout=$((timeout * 60))\r\nelse\r\n    # If the timeout command does exist, add m to the end of the string\r\n    timeout=\"${timeout}m\"\r\nfi\r\n\r\nif [[ $OSTYPE == 'darwin'* ]]; then\r\n    if ! plutil -lint \/Library\/Preferences\/com.apple.TimeMachine.plist &gt;\/dev\/null; then\r\n        echo \"This script requires ninjarmm-macagent to have Full Disk Access.\"\r\n        echo \"Add ninjarmm-macagent to the Full Disk Access list in System Preferences &gt; Security &amp; Privacy, quit the app, and re-run this script.\"\r\n        exit 1\r\n    fi\r\nfi\r\n\r\n# Search for files or folders\r\nif [[ -n \"${leafSearchName}\" &amp;&amp; \"${leafSearchName}\" != \"null\" ]]; then\r\n    if [[ \"${searchType}\" == *\"Files\"* &amp;&amp; \"${searchType}\" == *\"Only\"* ]]; then\r\n        echo \"[Info] Searching for files only\"\r\n        # Search for files only\r\n        # Use timeout to prevent the find command from running indefinitely\r\n        foundPath=$(timeout \"${timeout}\" find \"$parentSearchPath\" -type f -name \"$leafSearchName\" 2&gt;\/dev\/null)\r\n        exitcode=$?\r\n        if [[ $exitcode -eq 0 || $exitcode -eq 124 ]]; then\r\n            if [[ -n $foundPath ]]; then\r\n                echo \"[Alert] File Found\"\r\n            fi\r\n        fi\r\n    elif [[ \"${searchType}\" == *\"Folders\"* &amp;&amp; \"${searchType}\" == *\"Only\"* ]]; then\r\n        echo \"[Info] Searching for folders only\"\r\n        # Search for folders only\r\n        # Use timeout to prevent the find command from running indefinitely\r\n        foundPath=$(timeout \"${timeout}\" find \"$parentSearchPath\" -type d -name \"$leafSearchName\" 2&gt;\/dev\/null)\r\n        exitcode=$?\r\n        if [[ $exitcode -eq 0 || $exitcode -eq 124 ]]; then\r\n            if [[ -n $foundPath ]]; then\r\n                echo \"[Alert] File Found\"\r\n            fi\r\n        fi\r\n    elif [[ \"${searchType}\" == *\"Files\"* &amp;&amp; \"${searchType}\" == *\"Folders\"* ]]; then\r\n        echo \"[Info] Searching for files or folders\"\r\n        # Search for files or folders\r\n        # Use timeout to prevent the find command from running indefinitely\r\n        foundPath=$(timeout \"${timeout}\" find \"$parentSearchPath\" -name \"$leafSearchName\" 2&gt;\/dev\/null)\r\n        exitcode=$?\r\n        if [[ $exitcode -eq 0 || $exitcode -eq 124 ]]; then\r\n            if [[ -n $foundPath ]]; then\r\n                echo \"[Alert] File Found\"\r\n            fi\r\n        fi\r\n    else\r\n        echo \"[Error] Invalid search type\"\r\n        echo \"Valid search types: Files Only, Folders Only, Files Or Folders\"\r\n        exit 1\r\n    fi\r\nelif [[ -z \"${leafSearchName}\" ]]; then\r\n    echo \"[Info] Searching in path only\"\r\n    # Search in path only\r\n    # Use timeout to prevent the find command from running indefinitely\r\n    foundPath=$(timeout \"${timeout}\" find \"$parentSearchPath\")\r\n    exitcode=$?\r\n    if [[ $exitcode -eq 0 || $exitcode -eq 124 ]]; then\r\n        if [[ -n $foundPath ]]; then\r\n            echo \"[Alert] File Found\"\r\n        fi\r\n    fi\r\nfi\r\n\r\n# Check exit code\r\nif [[ -n $foundPath ]]; then\r\n    # Split the string into an array\r\n    IFS=$'\\n' read -rd '' -a foundPathArray &lt;&lt;&lt;\"${foundPath}\"\r\n    # Print each element of the array\r\n    for element in \"${foundPathArray[@]}\"; do\r\n        echo \"[Alert] ${element} exists\"\r\n    done\r\nelif [[ -z $foundPath ]]; then\r\n    echo \"[Warn] Could not find a file or folder\"\r\n    exit 1\r\nelse\r\n    # If the find command fails to find the file or folder\r\n\r\n    # Figure out the grammer for the search type\r\n    if [[ \"${searchType}\" == *\"Only\"* ]]; then\r\n        if [[ \"${searchType}\" == *\"Files\"* ]]; then\r\n            searchTypeInfo=\"file\"\r\n        elif [[ \"${searchType}\" == *\"Folders\"* ]]; then\r\n            searchTypeInfo=\"folder\"\r\n        fi\r\n    elif [[ \"${searchType}\" == *\"Files\"* &amp;&amp; \"${searchType}\" == *\"Folders\"* ]]; then\r\n        searchTypeInfo=\"file or folder\"\r\n    fi\r\n    echo \"[Info] Could not find a ${searchTypeInfo} in the path ${parentSearchPath} with the name containing: ${leafSearchName}\"\r\nfi\r\n\r\n# If foundPath contains \"Alarm clock:\" then the command timed out\r\nif [[ \"${foundPath}\" == *\"Alarm clock:\"* ]]; then\r\n    echo \"[Alert] Timed out searching for file or folder\"\r\n    # Remove \"Alarm clock: *\" from the string\r\n    foundPath=${foundPath\/Alarm clock: [0-9]*\/\/}\r\nfi\r\n\r\n# If command times out\r\nif [[ $exitcode -ge 124 &amp;&amp; $exitcode -le 127 || $exitcode -eq 137 ]]; then\r\n    echo \"[Alert] Timed out searching for file or folder\"\r\n    echo \"timeout exit code: $exitcode\"\r\n    echo \"  124  if COMMAND times out, and --preserve-status is not specified\"\r\n    echo \"  125  if the timeout command itself fails\"\r\n    echo \"  126  if COMMAND is found but cannot be invoked\"\r\n    echo \"  127  if COMMAND cannot be found\"\r\n    echo \"  137  if COMMAND (or timeout itself) is sent the KILL (9) signal (128+9)\"\r\n    echo \"find command result: $foundPath\"\r\n    exit 1\r\nfi\r\n\r\n# Save to custom field\r\nif [[ -n \"${customField}\" &amp;&amp; \"${customField}\" != \"null\" ]]; then\r\n    SetCustomField \"${customField}\" \"${foundPath}\"\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Greifen Sie auf \u00fcber 300 Skripte im NinjaOne Dojo zu.<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detailansicht<\/h2>\n<p>Das Skript arbeitet mit mehreren Parametern, mit denen der Suchprozess angepasst werden kann. Hier finden Sie eine detaillierte Aufschl\u00fcsselung der Funktionen:<\/p>\n<p><strong>1. Parameter und Initialisierung<\/strong>:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"2\"><strong>&#8211;path<\/strong>: Gibt das Basisverzeichnis an, in dem gesucht werden soll.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"2\"><strong>&#8211;name<\/strong>: Legt den Namen der Datei oder des Ordners fest, nach dem gesucht werden soll, wobei Wildcard-Zeichen unterst\u00fctzt werden.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"2\"><strong>&#8211;type<\/strong>: Legt fest, ob nach Dateien, Ordnern oder beidem gesucht werden soll.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"2\"><strong>&#8211;timeout<\/strong>: Legt die maximale Zeit f\u00fcr den Suchvorgang fest. Die Standardeinstellung ist 30 Minuten.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"2\"><strong>&#8211;customfield<\/strong>: Erm\u00f6glicht das Speichern des Suchergebnisses in einem benutzerdefinierten Feld.<\/li>\n<\/ul>\n<p><strong>2. Argumente-Parsen<\/strong>: Das Skript parst die Befehlszeilenargumente, um die Suchparameter zu initialisieren. Fehlt ein erforderlicher Parameter, wird eine Fehlermeldung ausgegeben und das Skript beendet sich.<\/p>\n<p><strong>3. Ausf\u00fchrung der Suche<\/strong>:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"2\">Das Skript l\u00f6st alle symbolischen Links im Suchpfad auf.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"2\">Es wird \u00fcberpr\u00fcft, ob der angegebene Pfad existiert und g\u00fcltig ist.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"2\">Das Skript stellt sicher, dass die Zeit\u00fcberschreitung innerhalb des zul\u00e4ssigen Bereichs liegt (1 bis 120 Minuten).<\/li>\n<\/ul>\n<p><strong>4. Datei- oder Ordnersuche<\/strong>: Je nach dem angegebenen Typ (Dateien, Ordner oder beides) verwendet das Skript den Befehl &#8218;find&#8216; mit einer Zeit\u00fcberschreitung, um die gew\u00fcnschten Elemente zu finden. Wenn es gefunden wird, werden die Benutzer:innen benachrichtigt und das Ergebnis optional in einem benutzerdefinierten Feld gespeichert.<\/p>\n<p><strong>5. Fehlerbehandlung und Berichterstattung<\/strong>: Das Skript enth\u00e4lt eine umfassende Fehlerbehandlung, die daf\u00fcr sorgt, dass Probleme wie ung\u00fcltige Pfade, falsche Timeout-Werte oder nicht existierende Dateien bzw. Ordner den Benutzer:innen deutlich mitgeteilt werden.<\/p>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<h3>Fallstudie: \u00dcberpr\u00fcfung der IT-Compliance<\/h3>\n<p>Ein IT-Experte ist daf\u00fcr verantwortlich, dass auf allen Servern wichtige Sicherheitskonfigurationsdateien vorhanden sind. Mit diesem Skript kann er den \u00dcberpr\u00fcfungsprozess automatisieren:<\/p>\n<p><strong>1. Einrichtung<\/strong>:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"2\"><strong>&#8211;path<\/strong>: \/etc\/security<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"10\" data-aria-level=\"2\"><strong>&#8211;name<\/strong>: security.conf<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"11\" data-aria-level=\"2\"><strong>&#8211;type<\/strong>: Files Only<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:1440,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"12\" data-aria-level=\"2\"><strong>&#8211;timeout<\/strong>: 10<\/li>\n<\/ul>\n<p><strong>2. Ausf\u00fchrung<\/strong>: Das Skript sucht innerhalb der eingestellten Zeitspanne im angegebenen Pfad nach der Datei &#8217;security.conf&#8216;. Wenn sie gefunden wird, protokolliert das Skript eine Warnmeldung; wenn nicht, benachrichtigt es den IT-Experten und erm\u00f6glicht so eine schnelle Probleml\u00f6sung.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Im Vergleich zur manuellen \u00dcberpr\u00fcfung oder zur Verwendung einfacher Shell-Befehle bietet dieses Skript mehrere Vorteile:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Automatisierung<\/strong>: Reduziert den Bedarf an manuellen Kontrollen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Timeout-Management<\/strong>: Verhindert l\u00e4ngere Suchvorg\u00e4nge durch die Durchsetzung eines Zeit\u00fcberschreitungswertes.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Benutzerdefinierte Berichterstellung<\/strong>: Erm\u00f6glicht die Speicherung von Ergebnissen in benutzerdefinierten Feldern f\u00fcr die weitere Verarbeitung oder die Erstellung von Compliance-Berichten.<\/li>\n<\/ul>\n<p>Andere Methoden, wie z. B. die Verwendung von &#8218;ls&#8216; oder Testbefehlen in der Bash, verf\u00fcgen nicht \u00fcber diese erweiterten Funktionen, sodass dieses Skript eine robustere und effizientere L\u00f6sung darstellt.<\/p>\n<h2>FAQs<\/h2>\n<ol>\n<li><strong>Was passiert, wenn das Skript eine Zeit\u00fcberschreitung aufweist?<\/strong><br \/>\nDas Skript meldet eine Zeit\u00fcberschreitung und beendet sich mit einem entsprechenden Fehlercode, damit die Benutzer:innen wissen, dass die Suche unvollst\u00e4ndig war.<\/li>\n<li><strong>Kann ich nach mehreren Dateitypen gleichzeitig suchen?<\/strong><br \/>\nNein, das Skript unterst\u00fctzt derzeit die Suche nach Dateien oder Ordnern auf der Grundlage eines einzigen Namensmusters zur gleichen Zeit.<\/li>\n<li><strong>Wie gehe ich mit symbolischen Links im Suchpfad um?<\/strong><br \/>\nDas Skript l\u00f6st automatisch symbolische Links auf und stellt sicher, dass die Suche im richtigen Verzeichnis durchgef\u00fchrt wird.<\/li>\n<\/ol>\n<h2>Folgen<\/h2>\n<p>Mit diesem Skript kann die IT-Sicherheit erheblich verbessert werden, indem man sicherstellt, dass wichtige Dateien und Ordner vorhanden sind. Die automatische \u00dcberpr\u00fcfung tr\u00e4gt zur Einhaltung von Sicherheitsrichtlinien bei und minimiert das Risiko, dass wichtige Dateien fehlen, was zu Systemschwachstellen oder -ausf\u00e4llen f\u00fchren k\u00f6nnte.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Regelm\u00e4\u00dfige Audits<\/strong>: Planen Sie die regelm\u00e4\u00dfige Ausf\u00fchrung des Skripts, um die aktuelle \u00dcberpr\u00fcfung kritischer Dateien aufrechtzuerhalten.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Verwendung benutzerdefinierter Felder<\/strong>: Nutzen Sie die Option f\u00fcr benutzerdefinierte Felder, um Suchergebnisse systematisch zu verfolgen und zu melden.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Timeout-Einstellungen<\/strong>: Passen Sie den Timeout-Parameter auf der Grundlage der erwarteten Gr\u00f6\u00dfe des Verzeichnisses und der Systemleistung an, um unn\u00f6tige Verz\u00f6gerungen zu vermeiden.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Dieses Bash-Skript ist ein leistungsf\u00e4higes Tool f\u00fcr IT-Experten, das eine automatisierte und zuverl\u00e4ssige Methode zur \u00dcberpr\u00fcfung der Existenz von Dateien und Ordnern bietet. Durch die Integration dieses Skripts in Routinekontrollen k\u00f6nnen MSPs eine h\u00f6here <a href=\"https:\/\/www.ninjaone.com\/de\/effizienz\/\" target=\"_blank\" rel=\"noopener\">Effizienz<\/a> und <a href=\"https:\/\/www.ninjaone.com\/de\/top-5-it-sicherheitsgrundlagen\" target=\"_blank\" rel=\"noopener\">Sicherheit<\/a> in ihrem Betrieb gew\u00e4hrleisten. Mit Tools wie <a href=\"https:\/\/www.ninjaone.com\/de\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a> l\u00e4sst sich dieser Prozess weiter verbessern, indem sie umfassende IT-Management-L\u00f6sungen anbieten, die die Bereitstellung, \u00dcberwachung und Verwaltung von Skripten \u00fcber mehrere Systeme hinweg erleichtern.<\/p>\n<p>Die Automatisierung der Dateiverwaltung spart nicht nur Zeit, sondern erh\u00f6ht auch die Genauigkeit und sorgt daf\u00fcr, dass wichtige Dateien immer dort sind, wo sie sein m\u00fcssen.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4210],"use_cases":[4383],"class_list":["post-385381","script_hub","type-script_hub","status-publish","hentry","script_hub_category-macos","use_cases-monitoring-de"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/385381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=385381"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=385381"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=385381"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=385381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}