| Description | Command | Example |
|---|---|---|
How to get date in YYYYMMDDhhmmss format
|
date +%Y%m%d%H%M%S | date +%Y%m%d%H%M%S 20150701164849 |
| How to get hostname | uname -n | |
| How to unzip and untar a file | gunzip -c filename | tar -xvf - | |
| How to check if a file is non zero size | if [ -s file ] | |
| How to check if a variable is empty | if [ -z file] | |
| How to check if a directory is present | if [ -d file] | |
| How to check if a file is present | if [ -f file] | |
| How to extract file name from path | echo filename | sed -e's/.*\///' | # echo "/opt/app/tmp/pom.xml" | sed -e's/.*\///' pom.xml |
| How to zip a file | cat $file | gzip -c > $FILENAME | |
| How to retrieve return status from a shell | $CTI/common/shells/SendToETL.sh TOPO $FILENAME RC=$? echo "Return status = $RC" |
|
| How to run a command on a remote server | ssh -l user hostname '. ./.profile;echo $JAVA_HOME' | ssh -l jm416b abc.com '. ./.profile;echo $JAVA_HOME' |
| How to view contents of a zip file | zcat file.gz | |
| How to retrieve result to an integer variable | integer RESULT=$(wc -l $DIFFFILE | cut -d' ' -f1) | |
| Numeric comparison | if [ $RESULT -gt 0 ] | you can also use -gt,-ge,-le,-lt,-eq,-ne |
| String comparison | if [ "$HLCS" != "" ] | use = = for equality |
| Convert uppercase to lowercase | DNS=$(echo "$DNS" | tr '[A-Z]' '[a-z]' | |
| Convert lowercase to uppercase | DNS=$(echo "$DNS" | tr '[a-z]' '[A-Z]' | |
| A file is newer than another | if [[ FILE1 -nt FILE2 ]]; then
echo FILE1 is newer than FILE2 fi |
|
| A file is older than another | if [[ FILE1 -nt FILE2 ]]; then echo FILE1 is newer than FILE2 fi |
|
Please follow the below mentioned steps to write a very simple SNMP4J application using Java and eclipse IDE. First you need to download a copy of SNMP4J.jar. You can get it from http://www.snmp4j.org/html/download.html Then you need to decide how you are going to test your application. Check whether you have access to any real network devices like Cisco routers or Juniper routers or whether you are aware of any SNMP agent running on any of your servers.There is nothing to worry if you cannot find one , you can start SNMP agent on your desktop machine as well. Here I am giving an example of how you can use your Windows machine to test your application by starting the SNMP service on the machine. I am using a Windows XP machine and below are the steps needed to start SNMP agent on the machine. 1. Go to Start->Control Panel -> Add or Remove Programs -> Add or Remove Windows Components Select or Check "Management and Monitoring Tools". ...
Comments
Post a Comment