Viewing 1 to 15 of 15 items
Tag Archives: Fi

Simple Bash Script For Pinging Hosts

This is a simple useful script which I learned from “Coding For Penetration Testers” book. It is used to check if a host is alive or not and echoes on user screen a message with the results of the ping command, if the host is up it informs the user “HOST IS UP” with the  Full Article…

0

This script checks the log file for timeouts

Code: #!/bin/ksh ################################################################################################## # # This script checks the log file for timeouts # ################################################################################################## TIMEOUT=`tail -5000 /dir1/logs/logfile.log | grep “has timed out and is not currently tradeable” | tail -1`; echo ${TIMEOUT}; if [ ! -z ${TIMEOUT} ]; then echo “Timeout Alert”; else echo “No Timeouts”; ———— TIMEOUT=`tail -5000 /dir1/logs/logfile.log | grep “has timed  Full Article…

0

Unix Shell Script Syntax for if and grep and -gt

There are two errors in your script: Nested backticks are not allowed. $2/$file_z instead of $(<$2/$file_z) Fixed: for j in `<$2/$file_z` do if grep -q “$1” “$j” > /dev/null # if grep “$1” “$j” > /dev/null # if your grep does not support -q then echo $j cp $j $3 fi done More optimal: for j in `<$2/$file_z` do  Full Article…

0

ZSH shell search alias

This wraps it all together. We define a ZSH function search which will give us a shortcut for searching multiple files in a folder tree: # Search ASCII-string from multiple files in the currect working directory # E.g. # search “foobar” “*.html” # search “foobar” “*.html” myfolder # By default we excluse dotted files and  Full Article…

0

How to check if process is running?

To me this script looks fine. Can somebody please assist me in finding what the problem is. Thank you Code: #!/bin/bash #———————————————————————————————————————- #This script allows the user to import a dsx file # # Usage: #./import.sh -s -d -r -f # #———————————————————————————————————————– dbname=”$dbname” dsn=”$dsn” dsxfile=”$dsxfile” rangechk=”$rangechk” verbose=”” reverb=”” module=`basename $0` DSXLOG_MODULE=$module export DSXLOG_MODULE dsxdir=”/var/local/dsx/import” dsximp=”/usr/local/bin/dsximp.exe”  Full Article…

0

Menu Driven Shell Script – Using Dialog Utility

#!/bin/bash # SCRIPT : menu_dialog.sh # PURPOSE : A menu driven Shell script using dialog utility # which has following options: # Display Today’s Date and Time. # Display calendar. # Delete selected file from supplied directory. # List of users currently logged in # Disk Statistics # Exit # ############################################################################## # Checking availability of  Full Article…

0

Check if program is running with bash shell script?

This is an example of a bash script which checks for some running process (daemon or service) and does specific actions (reload, sends mail) if there is no such process running. check_process(){ # check the args if [ “$1” = “” ]; then return 0 fi #PROCESS_NUM => get the process number regarding the given  Full Article…

0

ps -ef | grep to check if process is running

The script. #! /bin/sh #check the processes and email me if nsexpress is not running if ps -ef | grep “ns-httpd -d /usr/netscape/suitespot/https-lls/config” then echo “nsexpress is running” |mail george.rajapaksa at lls.edu else #echo “nsexpress is not running ” |mail george.rajapaksa at lls.edu cd /usr/netscape/suitespot/https-lls;./start fi The Problem: if pgrep -f “ns-httpd -d /usr/netscape/suitespot/https-lls/config” pgrep  Full Article…

0