Searching for files containing a specific word across all projects.
search cancel

Searching for files containing a specific word across all projects.

book

Article ID: 194444

calendar_today

Updated On:

Products

CA Harvest Software Change Manager CA Harvest Software Change Manager - OpenMake Meister

Issue/Introduction

We have currently 780 active repositories in the Harvest SCM database and have to search in all item versions stored for specific strings.

A search project by project with "Find version" is too much effort and time consuming. 

Do you have a procedure or query to perform a string based search in the database itself.

Environment

Harvest Software Change Manager all versions

Resolution

The "HSV" command line utility does include a "string search" option.  While it can only search one project at a time, a way to do this would be to set up a batch script to cycle through a list of project names and use the hsv command to search through all the projects one-by-one.  Here’s an example Windows batch script that would do it:

***************************************************************************************************************

ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

set sqlcmd="echo select environmentname from harenvironment where envisactive = 'Y' | hsql -b <brokername> -usr <userid> -pw <password> -s -nh"

echo. > hsv.log

for /f "usebackq tokens=*" %%a in (`%sqlcmd%`) do (
  echo Project = %%a >> hsv.log
  hsv -b <brokername> -usr <userid> -pw <password> -en "%%a" -vp "\\" -s "*.*" -wp "%~1" -ic -it nt -oa hsv.log -wts
  echo. >>hsv.log
)

***************************************************************************************************************


And here's an example of what this would look like for Linux:

***************************************************************************************************************

#!/bin/bash

echo '' > hsv.log

while read -r line
do

  if [ -n "$line" ]
  then
    echo Project = "$line" >> hsv.log
    hsv -b <brokername> -usr <userid> -pw <password> -en "$line" -vp "\\" -s "*.*" -wp "$1" -ic -it nt -oa hsv.log -wts
    echo '' >> hsv.log
  fi

done < <(echo "select environmentname from harenvironment where envobjid > 0 and envisactive = 'Y'" | hsql -b <brokername> -usr <userid> -pw <password> -s -nh)

***************************************************************************************************************

Additional Information

More information about the "hsv" command line utility can be found here: Command Reference - hsv Command-Select Version