Tags

,

I’m lazy typing in command prompt to execute a particular application like “memcached”, “ruby”, “mysql”, etc.. I need to traverse the directory before reaching its directory. Here in the sample below, I’ve made a batch script to run my memcached server with no more change directories(cd).

NOTE: All of my batch scripts was placed inside the hacking_m0de folder.

Batch script(memcached.bat) to start memcached server

@echo Memcached directory found at C:/memcached
@echo off
set memcached_dir=/memcached
for /D %%a in (/memcached) do (
  cd %%a
  IF %%a == /memcached (
    @echo memcached server started....
    memcached -l 127.0.0.1 -p 11211 -vv    
  ) 
)

To execute the batch script: c:\hacking_m0de>memcached.bat

Batch script(railsblog.bat) to start rails application with pik,a ruby version manager for Windows

Note: Ive installed 2 Ruby versions: 192 and 193. Using pik we can select what Ruby version the app will be using. The webserver is using thin server.

@echo off
@echo "pik started..."
set rootdir=/railsproject
set projectdir=railsblog
for /D %%a in ( /pik, %rootdir% ) do (
    cd %%a
    IF %%a == /pik (
      pik 193
    ) ELSE (
      IF %%a == %rootdir% cd %projectdir%
      REM rails server thin -p3005
      bundle exec thin start -a localhost -p3005
    )
)

To execute the batch script: c:\hacking_m0de>railsblog.bat

Batch script(mysql.bat) to start mysql on xampp application

@echo off
@echo "Mysql on xampp started..."
set parentDir=/xamppv2
set appDir=xampp

for /D %%a in ( %parentDir%, %appDir% ) do (
  cd %%a
)
mysql_start.bat

To execute the batch script: c:\hacking_m0de>mysql.bat

Batch script(railsblog_test.bat) to start your RoR app in TEST ENVIRONMENT

@echo off
@echo "pik started..."
set rootdir=/railsproject
set projectdir=railsblog

for /D %%a in ( /pik, %rootdir% ) do (
    cd %%a
    IF %%a == /pik (
      pik 193
    ) ELSE (
      IF %%a == %rootdir% cd %projectdir%
      bundle exec thin start -a railsblog.local -p3000 -etest -D
    )
)

 

Batch script(selenium.bat) to start your selenium server for acceptance testing.

@echo off
@echo "Selenium server 2.39 started..."
set parentDir=/selenium
set appDir=selenium-server-2.39.0

for /D %%a in ( %parentDir%, %appDir% ) do (
  cd %%a  
)
java -jar selenium-server-standalone-2.39.0.jar 

To execute the batch script: c:\hacking_m0de>selenium.bat

In your test_railsblog.bat, we combined the batch files in one file.

start cmd.exe /k "memcached.bat"
start cmd.exe /k "mysql.bat"
start cmd.exe /k "selenium.bat"
start cmd.exe /k "railsblog.bat"
start cmd.exe /k "railsblog_test.bat"

To execute the batch script: c:\hacking_m0de>test_railsblog.bat

Batch script to start mongodb (mongod.bat)

@echo off
@echo mongoDB started...
@echo dbpath=C:\mongodb\data\db
cd C:\mongodb\bin
mongod --dbpath=C:\mongodb\data\db

To execute the batch script: c:\hacking_m0de>mongod.bat

Batch script to start mongodb (mongod.bat) VERSION 2

More info at install-mongodb-on-windows/

@echo off
@echo Mongodb directory found at C:/mongodb/bin
set mongo_dir=/mongodb
set bin_dir=bin
for /D %%a in ( %mongo_dir%, %bin_dir% ) do (
  cd %%a
)
@echo Initializing mongodb server....
mongod --config C:\mongodb\mongodb.conf 

To execute the batch script: c:\hacking_m0de>mongod.bat

 

Advertisements