Contact Info

Crumbtrail

ActiveXperts.com » Network Monitor » Scripts » Custom Script

file-exists.sh - ssh script by ActiveXperts Software

file-exists.sh checks the existence of a file.

Use file-exists.sh directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select file-exists.sh. Configure the required parameter, or press 'Load a working sample'.

In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.


file-exists.sh script code

#################################################################################
# ActiveXperts Network Monitor - Shell script checks
# © 1999-2015, ActiveXperts Software B.V.
#
# For more information about ActiveXperts Network Monitor and SSH, please
# visit the online ActiveXperts Network Monitor Shell Script Guidelines at:
#   http://www.activexperts.com/support/network-monitor/online/linux/
#################################################################################
# Script
#     file_exists.sh
# Description
#     Checks the used space on a disk
# Declare Parameters
#     1) filename (string) - Path to file
# Usage
#     file_exists.sh <filename>
# Sample
#     file_exists.sh test.sh
#################################################################################

#!/bin/sh

# Validate number of arguments
if [ $# -ne 1 ] ; then
  echo "UNCERTAIN: Invalid number arguments - Usage: file_exists <filename>"
  exit 1
fi

# Check if the specified file exists
if [ -f "$1" ] ; then
  echo "SUCCESS: File [$1] exists DATA:1"
else
  echo "ERROR: File [$1] does not exist DATA:0"
fi