Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

command to execute pig script from the command line

command to execute pig script from the command line

Expert Contributor

hello,

i am new to hadoop.

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

3 REPLIES 3

Re: command to execute pig script from the command line

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

Re: command to execute pig script from the command line

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

Highlighted

Re: command to execute pig script from the command line

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

Don't have an account?
Coming from Hortonworks? Activate your account here