新聞中心
調(diào)用Grunt shell后,可以在shell中運(yùn)行Pig腳本。除此之外,還有由Grunt shell提供的一些有用的shell和實(shí)用程序命令。本章講解的是Grunt shell提供的shell和實(shí)用程序命令。

創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),東洲企業(yè)網(wǎng)站建設(shè),東洲品牌網(wǎng)站建設(shè),網(wǎng)站定制,東洲網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,東洲網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
注意:在本章的某些部分中,使用了Load和Store等命令。請(qǐng)參閱相應(yīng)章節(jié)以獲取有關(guān)它們的詳細(xì)信息。
Shell 命令
Apache Pig的Grunt shell主要用于編寫Pig Latin腳本。在此之前,我們可以使用 sh和 fs來調(diào)用任何shell命令。
sh 命令
使用 sh命令,我們可以從Grunt shell調(diào)用任何shell命令,但無法執(zhí)行作為shell環(huán)境( ex - cd)一部分的命令。
語法
下面給出了 sh命令的語法。
grunt> sh shell command parameters
示例
我們可以使用 sh選項(xiàng)從Grunt shell中調(diào)用Linux shell的 ls命令,如下所示。在此示例中,它列出了 /pig/bin/目錄中的文件。
grunt> sh ls pig pig_1444799121955.log pig.cmd pig.py
fs命令
使用 fs命令,我們可以從Grunt shell調(diào)用任何FsShell命令。
語法
下面給出了 fs命令的語法。
grunt> sh File System command parameters
示例
我們可以使用fs命令從Grunt shell調(diào)用HDFS的ls命令。在以下示例中,它列出了HDFS根目錄中的文件。
grunt> fs –ls Found 3 items drwxrwxrwx - Hadoop supergroup 0 2015-09-08 14:13 Hbase drwxr-xr-x - Hadoop supergroup 0 2015-09-09 14:52 seqgen_data drwxr-xr-x - Hadoop supergroup 0 2015-09-08 11:30 twitter_data
以同樣的方式,我們可以使用 fs命令從Grunt shell中調(diào)用所有其他文件系統(tǒng)的shell命令。
實(shí)用程序命令
Grunt shell提供了一組實(shí)用程序命令。這些包括諸如clear,help,history,quit和set等實(shí)用程序命令;以及Grunt shell中諸如 exec,kill和run等命令來控制Pig。下面給出了Grunt shell提供的實(shí)用命令的描述。
clear命令
clear命令用于清除Grunt shell的屏幕。
語法
你可以使用 clear命令清除grunt shell的屏幕,如下所示。
grunt> clear
help命令
help命令提供了Pig命令或Pig屬性的列表。
使用
你可以使用 help命令獲取Pig命令列表,如下所示。
grunt> help Commands:; - See the PigLatin manual for details: http://hadoop.apache.org/pig File system commands:fs - Equivalent to Hadoop dfs command: http://hadoop.apache.org/common/docs/current/hdfs_shell.html Diagnostic Commands:describe [:: ] [-out ] [-brief] [-dot|-xml] [-param = ] [-param_file ] [ ] - Show the execution plan to compute the alias or for entire script. -script - Explain the entire script. -out - Store the output into directory rather than print to stdout. -brief - Don't expand nested plans (presenting a smaller graph for overview). -dot - Generate the output in .dot format. Default is text format. -xml - Generate the output in .xml format. Default is text format. -param - See parameter substitution for details. alias - Alias to explain. dump - Compute the alias and writes the results to stdout. Utility Commands: exec [-param =param_value] [-param_file ]


咨詢
建站咨詢