Support Questions

Find answers, ask questions, and share your expertise

command to execute pig script from the command line

avatar
Expert Contributor

hello,

i am new to hadoop.

i want to execute my pig script file from grunt shell.

3 REPLIES 3

avatar

Hi @heta desai,

You can execute it via the exec command, for example:

grunt> cat myscript.pig
a = LOAD 'student' AS (name, age, gpa);
b = LIMIT a 3;
DUMP b;

grunt> exec myscript.pig
(alice,20,2.47)
(luke,18,4.00)
(holly,24,3.27)

See also: https://pig.apache.org/docs/r0.9.1/cmds.html#exec

avatar
Expert Contributor

cat test/script/test1-2017-05-02_11-14-06_999.pig

This works good.

but exec comman didn't worked.

exec /test/script/test1-2017-05-02_11-14-06_999.pig

it shows following error:

2017-05-02 05:59:55,487 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. File not found: /test/script/test1-2017-05-02_11-14-06_999.pig Details at logfile: /home/sshuser/pig_1493704766712.log

avatar
Master Mentor

Your script location is wrong, start grunt in the directory with the script or provide full path to the script in the exec command