Searching on the path given.. on on repository,if it is not there..!!


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Searching on the path given.. on on repository,if it is not there..!!
# 1  
Old 06-04-2010
Data Searching on the path given.. on on repository,if it is not there..!!

Code:
#!/bin/ksh
##### Made by : Vasudha Goel
mainpath="/ms/dist/bi/PROJ/infa_shared/incr/common/Domain"
usage() {
  print " Usage"
  print "\t$0 -d domain_name"
  print "\t$0 -r repo_name"
  print "\t$0 -f folder_name    #Mandatory"
  print "\t$0 -h help"
  exit
}
while getopts "d:f:r:h" opt ;
do
case "$opt" in
  d) domain_name=$OPTARG;;
  f) folder_name=$OPTARG;;
  r) repo_name=$OPTARG;;
  h) usage;;
esac
done
if [[ "$folder_name" = '' ]]; then
  print "Please give a valid Folder name";
  usage && exit 1;
fi
if [[ "$domain_name" = '' ]]; then
  domain_name='Domain_*';
fi
if [[ "$repo_name" = '' ]]; then
  repo_name='REPO_SVC_*';
fi
parse_info () {
domain_old="domain_old";
repo_old="repo_old";
  while read line;
  do {
    domain_new=`echo $line | awk -F"/" '{print $10}'`;
    repo_new=`echo $line | awk -F"/" '{print $11}'`;
    dir=`echo $line | awk -F"/" '{print $12}'`;
    link=`echo $line | awk -F"->" '{print $2}'`;
    if [[ "$domain_old" != "$domain_new" ]]; then
      print "\n$domain_new";
      domain_old=$domain_new;
    fi
    if [[ "$repo_old" != "$repo_new" ]]; then
      print " $repo_new";
      repo_old=$repo_new;
    fi
    print "   $dir -> $link";
  }
  done < $1
}
if [[ $domain_name = 'Domain_*' ]]; then
  cd $mainpath;
  set -A domains `ls -d $domain_name`;
  for dom in "${domains[*]}"; do
    if [[ `find $mainpath/$dom/ -name $repo_name` -eq 0 ]]; then
      find $mainpath/$dom -type l -name "${folder_name}" | xargs ls -l | grep "\b${folder_name}\b" >> /tmp/link`whoami`.txt 2>/dev/null
    else
      find $mainpath/$dom/$repo_name -type l -name "${folder_name}" | xargs ls -l | grep "\b${folder_name}\b" >> /tmp/link`whoami`.txt 2>/dev/null
    fi
  done
fi
if [[ $? -eq 0 ]]; then
  parse_info "/tmp/link`whoami`.txt"
else
  echo "No such Domain/Repository exists"  && exit 1;
fi
piias313 /ms/user/s/sawasthy 6$ vi t1
  }
  done < $1
}
if [[ $domain_name = 'Domain_*' ]]; then
  cd $mainpath;
  set -A domains `ls -d $domain_name`;
  for dom in "${domains[*]}"; do
    if [[ `find $mainpath/$dom/ -name $repo_name` -eq 0 ]]; then
      find $mainpath/$dom -type l -name "${folder_name}" | xargs ls -l | grep "\b${folder_name}\b" >> /tmp/link`whoami`.txt 2>/dev/null
    else
      find $mainpath/$dom/$repo_name -type l -name "${folder_name}" | xargs ls -l | grep "\b${folder_name}\b" >> /tmp/link`whoami`.txt 2>/dev/null
    fi
  done
fi
if [[ $? -eq 0 ]]; then
  parse_info "/tmp/link`whoami`.txt"
else
  echo "No such Domain/Repository exists"  && exit 1;
fi

Moderator's Comments:
Mod Comment If you're posting code, please enclose it in [code] tags, ty

Last edited by pludi; 06-04-2010 at 07:11 AM..
# 2  
Old 06-04-2010
I'm sure there's a question somewhere behind this posting. Would you mind being so kind as to tell it to us, as we're quite understaffed in the scrying and divining department (probably because they don't exist).
# 3  
Old 06-07-2010
Quote:
Originally Posted by pludi
I'm sure there's a question somewhere behind this posting. Would you mind being so kind as to tell it to us, as we're quite understaffed in the scrying and divining department (probably because they don't exist).
well, in the output i can see the domains along with the repo name
but
if we search only on the path, then the output should display the domains only, not the repo names.

plz have a look.. and if possible help me into it..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Makefile missing include path Although the path exists and defined

i have make file which i try to make them generic but it keeps to compline it missing include directory this is the makefile : CXX=g++ CPPFAGS= -Wall -O0 -g -std=c++14 INCLUDES = -I/home/vagrant/libuv/include -Isrc LIBS_DIRS = -L/home/vagrant/libuv/build LDFLAGS=... (7 Replies)
Discussion started by: umen
7 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

4. Shell Programming and Scripting

Generate class path dynamically based on source path

Hi experts, I have multiple file names ending with .jsp located in $SOME_DIR, $SOME_DIR/f1/,$SOME_DIR/f2/test,$SOME_DIR/f3/fa and there are equivalent class files in $SOME_DIR/WEB-INF/classes/_pages,$SOME_DIR/WEB-INF/classes/_pages/_f1,... (0 Replies)
Discussion started by: oraclermanpt
0 Replies

5. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

Hi All, Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created. /Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt /Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Discussion started by: karthikgv417
6 Replies

6. Red Hat

Error: Cannot retrieve repository metadata (repomd.xml) for repository: InstallMedia.

Most of my commands are returning this error on RHEL 6 64 bit: Also I tried installing many sofwtares, but it fails to correctly work. For example I treid installing dos2unix: # rpm -ivh dos2unix-5.3.3-5.ram0.98.src.rpm 1:dos2unix warning: user mockbuild does not... (0 Replies)
Discussion started by: India_2014
0 Replies

7. Shell Programming and Scripting

find command not searching path when -newer specified

When this command is issued from a directory other than where the file is located it works fine: find /db2/D01/log_archive/ -name "S0002166.LOG" -type f /db2/D01/log_archive/db2d01/D01/NODE0000/C0000000/S0002166.LOG When I change -name to -newer, it doesn't work. Find only searches the current... (5 Replies)
Discussion started by: fletchdb2
5 Replies

8. Red Hat

build a repository

Hi, i'll explain my problem in few words: i have to create a repository with mrepo on a RH. I see many procedures on internet and even in linux mag, but there isn't any case where the iso and rpm deposit aren't placed on the repository but on a remote system (a NetApp filer in my case). So... (0 Replies)
Discussion started by: nicnictout
0 Replies

9. Shell Programming and Scripting

Executing Commands From Non-Standard Path (Changing user's PATH secretely???)

Hi: I have a requirement as below: I have some standard Unix commands modified and kept them in a directory say /usr/clsh/bin. For example I have a script named "ls" kept here which is modified version of "ls" (say it always gives long listing i.e. ls -l). When any user logs on and types... (2 Replies)
Discussion started by: ramesh_samane
2 Replies

10. UNIX for Dummies Questions & Answers

Repository of HP-UX 10.20 packages

Hello, What the adresses of ftps or websites the packages depots to HP-UX 10.20 I am search and google I did not get success. Thanks :D (1 Reply)
Discussion started by: markos
1 Replies
Login or Register to Ask a Question