Search code examples
shellhadoopapache-pig

how to call Pig scripts from shell script sequentially


I have squence of Pig scripts in a file and I want to execute it from Shell script which execute pig scripts sqeuenciatly.

For Ex:

sh script.sh /it/provider/file_name PIGddl.txt

Suppose PIGddl.txt has Pig scripts like

  1. Record Count
  2. Null validation e.t.c

If all the Pig queries are in one file then how to execute the pig scripts from Shell scripts?


Solution

  • below idea works ,but if you want sequential process like if 1 execute then execute 2 else execute 3 kind of flow,you may go with Oozie for running and scheduling the jobs.

    #!/bin/sh
    x=1
    while [ $x -le 3 ]
     do
    
    echo "pig_dcnt$x.pig will be  run"
    
    pig  -f /home/Scripts/PigScripts/pig_dcnt$x.pig --param timestamp=$timestamp1
    
    x=$(( $x + 1 ))
    
    done