Shell command execution error in swing script

I have a pig script where at first I would like to generate a date string for the last 7 days from a specific date (later used to extract log files in those days). I am trying to do this with this line:% declare CMD7 input= ; for i in {1..6}; do d=$(date -d "$DATE -i days" "+%Y-%m-%d"); input="\$input\$d,"; done; echo \$input input= ; for i in {1..6}; do d=$(date -d "$DATE -i days" "+%Y-%m-%d"); input="\$input\$d,"; done; echo \$input

I get the error message: "ERROR 2999: Unexpected internal error. Shell command execution error: input =; for I'm in {1..6}; do d = $ (date -d" 2012-07-10 -i days "+ % Y-% m-% d "), input =" $ input $ d ", done ;. Team exit with exit code 127 "
however, the shell team works great outside the pig. I'm really not sure what is going wrong here.

Thanks!

+4
source share
1 answer

I have a working solution, but not as optimized as you like, in fact, I can’t get Pig to execute a complex shell statement in the declaration.

First I wrote a shell script (call it 6-days-back-from.sh):

 #!/bin/bash DATE=$1 for i in {1..6}; do d=$( date -d "$DATE -$i days" +%F ) ; echo -n "$d "; done 

Then the pig script as follows (call it days.pig):

 %declare my_date `./6-days-back-from.sh $DATE` A = LOAD 'dual' USING PigStorage(); B = FOREACH A GENERATE '$my_date'; DUMP B 

note that dual is a directory containing a text file with one line of text, in order to display our variable

I called the script as follows:

 pig -x local -param DATE="2012-08-03" days.pig 

and got the following output:

 ({(2012-08-02),(2012-08-01),(2012-07-31),(2012-07-30),(2012-07-29),(2012-07-28)}) 
+6
source

All Articles