错误一:

Hive的where后不能用字段的别名,

错误二:

hive的groupby中不能用自己定义函数,否则报错(用嵌套select取代)

错误三:

运行:$ ./hive_game_operationstatis5.sh时,报错信息例如以下:

./hive_game_operationstatis5.sh:line 11: [: missing `]'
./hive_game_operationstatis5.sh:line 17: /tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt:No such file or directory
./hive_game_operationstatis5.sh:line 36:/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt:No such file or directory
ERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt'not found (Errcode: 2)
ERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt'not found (Errcode: 2)

错误分析:

因为11行的创建文件夹代码没起作用,所以导致后边一系列找不到文件路径的错误。

报错时的代码:

if [ ! -d $output]
then
mkdir -p $output
fi<span style="font-family: Arial, Helvetica, sans-serif;"> </span>

改动后的代码:

if [ ! -d $output]
then
mkdir -p $output
fi

看到区别了没??$output与]之间应该有个空格!

错误四:date不能识别

运行./hive_game_operationstatis6.sh脚本时。报错例如以下:

./hive_game_operationstatis6.sh:line 12: [: /tmp/statis_suspendedwindowstatisdate: binary operator expected
./hive_game_operationstatis6.sh:line 21: $output/$file_name1: ambiguous redirect
./hive_game_operationstatis6.sh:line 39: $output/$file_name2: ambiguous redirect
./hive_game_operationstatis6.sh:line 56: $output/$file_name3: ambiguous redirect
./hive_game_operationstatis6.sh:line 73: $output/$file_name4: ambiguous redirect
./hive_game_operationstatis6.sh:line 90: $output/$file_name5: ambiguous redirect

分析:

在shell脚本中我是这样写:

output='/tmp/statis_suspendedwindowstatis'$date
file_name1='statis_suspendedwindowstatis1'$date'.txt'

错误显示是指调用时”模糊的重定向”!

单从错误提示上看不出个所以然来。请直接看出错代码:

改动之前代码:

date=’date +%Y%m%d’

改动此bug之后代码:

date=`date +%Y%m%d`

大家看到哪里出错了没??哈哈,是的,太坑啦!

shell要用键盘上1前边的‘撇’,而不能用双引號那个‘撇’儿。

假设一个变量后是字符串的话直接用回车左边那个’撇‘就能够,

对于我这个初次接触shell的人。简直头疼到了极点!

希望大家不要犯类似的错误。


写hive sql和shell脚本时遇到几个蛋疼的问题!的更多相关文章

  1. 执行shell脚本时提示bad interpreter:No such file or directory的解决办法

    执行shell脚本时提示bad interpreter:No such file or directory的解决办法 故障现象:在终端直接cd /var正常,在shell脚本中执行则报错.原因是脚本是 ...

  2. python调用shell脚本时需要切换目录

    最近遇到了一个问题,就是python代码调用shell脚本时,发现输入输出的文件,总是和自己预想的有偏差,但是单独在linux下执行命令的时候,却没有错误.后来发现是相对路径的问题,因为执行pytho ...

  3. hive streaming 使用shell脚本

    一.HIVE streaming 在Hive中,需要实现Hive中的函数无法实现的功能时,就可以用Streaming来实现.其原理可以理解成:用HQL语句之外的语言,如Python.Shell来实现这 ...

  4. 批量执行 sql 的 shell 脚本

    最近有用到需要批量导入N个表的sql,一个个导入会吐老血的,写了个shell脚本,便捷导入. 通常我们导入单个sql,可以用 $mysql -uroot -p world < xxxx.sql ...

  5. linux执行shell脚本时提示bad interpreter:No such file or directory的解决办法

    故障现象:在终端直接cd /var正常,在shell脚本中执行则报错.原因是脚本是在windows平台下写的,换行符与Linux不同,造成脚本不能正确执行 出现bad interpreter:No s ...

  6. 执行shell脚本时提示/bin/sh^M: bad interpreter: No such file or directory

    执行脚本时提示解释器有问题,错误提示如下: 这种提示一般是脚本在windows系统之通过记事本写的,记事本修改过的文本,会默认在文本前面加上一些看不到的标记,导致shell脚本不能被shell解释器识 ...

  7. 关于shell脚本时遇value too great for base (error token is "08")

    今天在书写一个定时cp脚本时遇到了一个问题,value too great for base (error token is "08") 在网上查看到原来是以0开头的数字 系统会默 ...

  8. centos分配IP脚本--写的第一个shell脚本

    IDC小菜鸟一枚,非科班出身.常常有客户的centos服务器需要分配15个IP甚至30个IP.每次需要手动分配十分麻烦,于是花了一天时间学了shell脚本,写了这个脚本. #!/bin/bash re ...

  9. linux脚本错误: line *: [: missing `]',linux编写shell脚本时的注意点

    转载:https://www.cnblogs.com/bovenson/p/4548079.html 关于shell的一些注意点,粘贴自拉钩教育精选评论:测试开发核心技术 46 讲-->第6讲 ...

随机推荐

  1. 32位Linux文件限制大小

    线上程序不断重新启动,查看log发现是进程由于SIGXFSZ信号退出.对过大的文件进行操作的时候会产生此信号,一般仅仅在32位机器上出现,文件限制大小为2G.用lsof查看进程打开的文件,果然有一个文 ...

  2. Hermes和开源Solr、ElasticSearch 不同

    Hermes和开源Solr.ElasticSearch不同          谈到Hermes的索引技术.相信非常多同学都会想到Solr.ElasticSearch.Solr.ElasticSearc ...

  3. 恩布企业 IM 安卓端 1.3,服务端 1.12 公布

    恩布企业IM的 Android 安卓开源手机client EntboostIM 公布 1.3 版本号.同一时候恩布IM服务端更新至 1.12 版本号; 安卓端主要更新内容: 添加收发手机文件功能: 登 ...

  4. Android中的动画具体解释系列【1】——逐帧动画

    逐帧动画事实上非常easy,以下我们来看一个样例: <?xml version="1.0" encoding="utf-8"?> <anima ...

  5. String的Split方法的用法与要注意事项

    转自:http://shukuiyan.iteye.com/blog/1058672 之前在http://shukuiyan.iteye.com/blog/507915文中已经叙述过这个问题,但是最近 ...

  6. poj3126解题报告

    题意:简单的说就是:有一个人门牌号是一个四位数的整数,并且还是一个素数,现在他想要换成另外一个四位数且是素数的门牌号,而且,每次都只能更换这个四位数的一个位置的数 ,也就是每换一次都只改变一个数字,而 ...

  7. hdu 4836 The Query on the Tree(线段树or树状数组)

    The Query on the Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. gwt CellTable中的控件按Tab键切换

    默认是 cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); 如果要Tab,则设置为DISABLED; 并将其t ...

  9. cocos2d-x 2.2.3 创建项目的方法

    直接复制粘贴到txt文本,然后修改后缀为.bat,然后将bat文件放到tools\project-creator的目录下即可. :project_input @echo 请输入项目名称,按回车,例:H ...

  10. SO_REUSEADDR 套接字选项应用

    在网络上的SO_REUSEADDR套接字选项是用来解决地址问题重用了大量的信息.但仅仅停留在文字的表达.并没有实例,非常easy误导谁刚开始学习,和不解,此处不再赘述. 的使用该选项,以及须要注意的问 ...