AEM Topics

Window batch scripts

Project folder/sub-folder creation script


@ECHO OFF

rem ############ Author: Prahlad Dutta ############
rem ############ Date: 09/11/2017 #################
rem ############ Description: project folder creation scripts ############

rem Set envrionment variables
set PROJECT_DIR=”D:PrahladProject”
set BKUP_DIR_NAME=”Backup”
set BILL_DIR_NAME=”Bills”
set CODEBASE_DIR_NAME=”Codebase”
set CONTENT_DIR_NAME=”Content Package”
set DEPLOY_DIR_NAME=”Deployment”
set DOC_DIR_NAME=”Documents”
set HTML_DIR_NAME=”HTML”
set WORKSPACE_DIR_NAME=”Workspace”
set TESTING_DIR_NAME=”Testing”

SET /P project_name=Please enter your project name: 
IF “%project_name%”==”” (
ECHO You did not enter your project name! Bye bye!!
echo.
exit
) ELSE (
ECHO Start creating folder for project: %project_name%
mkdir %PROJECT_DIR%%project_name%
echo Project root directory: %PROJECT_DIR%%project_name%, created successfully.
echo ***************Start creating child folders******************
mkdir %PROJECT_DIR%%project_name%%BKUP_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%BILL_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%CODEBASE_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%CONTENT_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%DEPLOY_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%DOC_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%HTML_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%WORKSPACE_DIR_NAME%
mkdir %PROJECT_DIR%%project_name%%TESTING_DIR_NAME%
echo **********Project folder and subfolder created successfully ******
cd %PROJECT_DIR%%project_name%
echo on
start .

)

Setting environment variables


rem ####envpath.bat######

rem set LOGDIR=”D:prahlad’s Systemprahlad document sectionBackupMy_BackupLogs”
rem set COPYFILE=”C:Usersprahlad.duttaAppDataLocalMicrosoftOutlook*.pst”
REM set COPYTO=”D:prahlad’s Systemprahlad document sectionBackupMy_BackupMail_Backup”
set FILE=”*.pst”

set COPYFILE=”C:Usersprahlad.duttaAppDataLocalMicrosoftOutlook*.pst”
set COPYTO=”D:Prahlad_SystemPrahlad DocumentsBackupMy_BackupMail_Backup”

rem ****seting path for one notebooks****
set NOTEBOOK=”C:Usersprahlad.duttaDocumentsOneNote Notebooks”
set TODIR=”D:Prahlad_SystemPrahlad DocumentsBackupMy_BackupOneNote_Backup”

set ALLFILE=”*”

Batch script for login tracker


@echo off

call envpath.bat
set user=%username%


rem ############## for win 7 32-bit###########
rem For /f “tokens=2-4 delims=/ ” %%a in (‘date /t’) do (set MyDate=%%b-%%a-%%c) 

rem ############## for win 7 64-bit###########
for /f “tokens=1” %%a in (‘date /t’) do (set Mydate=%%a)
set logindate=%Mydate%

for /f %%b in (‘time /t’) do (set Mytime=%%b)
set logintime=%Mytime%

for /f “tokens=2 delims= ” %%c in (‘time /t’) do (set Myzone=%%c)
set timezone=%Myzone%

set afile=%user%_Logindetail_%logindate%.log

REM cd %LOGDIR%
IF EXIST %LOGDIR%%afile% (
echo %user% %logindate% %logintime% %timezone% >> %LOGDIR%%user%_Logindetail_%logindate%.log
) ELSE (
echo Loginname Logindate Logintime  > %LOGDIR%%user%_Logindetail_%logindate%.log
echo ———- ———- ———– >> %LOGDIR%%user%_Logindetail_%logindate%.log
echo %user% %logindate% %logintime% %timezone% >> %LOGDIR%%user%_Logindetail_%logindate%.log
)

Batch script for backup your mail


@echo off
call envpath.bat
rem taskkill /f /im outlook.exe
copy %COPYFILE% %COPYTO%
rem ############## for win 7 32-bit###########
rem For /f “tokens=2-4 delims=/ ” %%a in (‘date /t’) do (set MyDate=%%b-%%a-%%c) 
rem ############## for win 7 64-bit###########
set MyDate=%date%
echo %MyDate%
cd %COPYTO%
D:
“c:Program FilesWinRARRar.exe” a -df -r prahlad.dutta_%MyDate%.rar %FILE%
rem “C:Program Files (x86)WinRARRar.exe” a prahlad.dutta_%MyDate%.rar %FILE%
rem del %FILE%
echo .
rem shutdown -s -f -t 60

Bookmarks | Useful links

Continue reading “Bookmarks | Useful links”

linux command | linux command cheat sheet

File Management
  • ls – List files and folders
  • cd – Change directory
  • pwd – Present working directory
  • mkdir – Make a new empty directory
  • rmdir – Remove an empty directory
  • cp – Copy files or directory
  • rm – Remove files or directory
  • mv – Move files or directory / Rename files or directory
  • find – Find files or folders bases on name, data, size, owner or other parameters
  • touch – make a new blank files
Permissions
  • chown – Change ownership of files / directories
  • chgrp – Change group ownership of files / directories
  • chmod – Change permission of files / directories
  • groups – Reports the groups you belong to
  • id – Reports your username, user-id, group(s) and groupid(s)
Resource Monitoring
  • w – See who logged in on your system and what they are doing.
  • who – See who logged in on which shell and time.
  • uname – display the system information like(machine name, version, hostname).
  • hostname – display your system hostname.
  • top – See the top resource hungry processes.
  • ps – Process schedule / status.
  • df – See how much disk space is free.
  • du – Report numbers and size of files on disk.
Printing
  • lpr – send text or post script files to the printer.
  • lpq – view the print queue.
  • lprm – Remove your print jobs.
Job Control
  • whereis – Display full path and installation path of commands.
  • which – Display the full path of commands.
  • ctrl+z – Suspend the current job
  • bg – Put a suspended job in the background.
  • fg – Bring a suspended job into the foreground.
  • kill – Kill a process
Filtering/Searching
  • grep – Search for sub strings in a file or pipeline.
  • awk – Pattern searching in a folder or within a file.
  • sed – Sed is a Stream Editor used for modifying the files in unix (or linux). Whenever you want to make changes to the file automatically.
  • sort – Sort lines alphabetically or numerically.
  • wc – Count lines, word and characters.
  • cat – Catalog a file.
  • more – Teminal bases text viewing program.
 

Find matching files and folder and rename it 

find . -name “clientlib_*” | awk ‘{print(“mv “$1 ” ” $1)}’ | sed ‘s/clientlib_//2’ | sh 

Lifecycle of a Java Program

The above figure explains the lifecycle of a Java Program. In words, the figure can be explained as:

  1. A Java program is written using either a Text Editor like Textpad or an IDE like Eclipse and is saved as a .java file. (Program.java)
  2. The .java file is then compiled using Java compiler and a .class file is obtained from it. (Program.class)
  3. The .class file is now portable and can be used to run this Java program in any platform.
  4. Class file (Program.class) is interpreted by the JVM installed on a particular platform. JVM is part of the JRE software