命令在linux命令行可以执行,但是在脚本中执行报错
想写一个比较规范的脚本,通过传递参数来用sqoop同步数据,通过参数的传递发现最后拼接的sqoop语句没有问题,日志打印出来可以直接复制粘贴到命令行上面执行,但是在脚本里面就是报错,说sqoop 参数问题,有人遇到类似的问题么
比如执行: ./main.sh MYSQL01_MYTEST_HIVE_TEXTFILE 1
日志最后打印出来---> sqoop语句:sqoop import --connect jdbc:mysql://192.168.80.123:3306/sqoop --username root --table MYTEST_HIVE --columns 'id,name,money,time_test_01,time_test_02,flag' --where 'time_test_02 >= 20170529 and time_test_02 < 20170530' --delete-target-dir --hive-overwrite --hive-import --hive-table lijie.MYSQL01_MYTEST_HIVE_TEXTFILE --fields-terminated-by '\001' -m 1
直接复制粘贴上面的到命令行执行没问题,但是在脚本中执行就报错,报错内容如下:
17/05/30 10:12:36 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Error parsing arguments for import:
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: >=
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 20170529
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: and
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: time_test_02
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: <
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 20170530'
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --delete-target-dir
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-overwrite
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-import
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-table
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: lijie.MYSQL01_MYTEST_HIVE_TEXTFILE
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --fields-terminated-by
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: '\001'
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: -m
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 1
部分脚本:
#########################拼接sqoop语句##################--password ${8}
condition="'"${@:8}"'"
column="'"${2}"'"
sqoop_exec_str=" --connect ${1} --username ${6} --table ${3} --columns ${column} --where ${condition} --delete-target-dir --hive-overwrite --hive-import --hive-table ${4} --fields-terminated-by '\001' -m 1"
print_log "sqoop语句:sqoop import ${sqoop_exec_str}"
sqoop import ${sqoop_exec_str}
exit_exec $?
注:................. 上面的脚本都是通过vi编辑器编辑的
求各位大神解惑下,谢谢
比如执行: ./main.sh MYSQL01_MYTEST_HIVE_TEXTFILE 1
日志最后打印出来---> sqoop语句:sqoop import --connect jdbc:mysql://192.168.80.123:3306/sqoop --username root --table MYTEST_HIVE --columns 'id,name,money,time_test_01,time_test_02,flag' --where 'time_test_02 >= 20170529 and time_test_02 < 20170530' --delete-target-dir --hive-overwrite --hive-import --hive-table lijie.MYSQL01_MYTEST_HIVE_TEXTFILE --fields-terminated-by '\001' -m 1
直接复制粘贴上面的到命令行执行没问题,但是在脚本中执行就报错,报错内容如下:
17/05/30 10:12:36 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Error parsing arguments for import:
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: >=
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 20170529
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: and
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: time_test_02
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: <
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 20170530'
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --delete-target-dir
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-overwrite
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-import
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --hive-table
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: lijie.MYSQL01_MYTEST_HIVE_TEXTFILE
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: --fields-terminated-by
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: '\001'
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: -m
17/05/30 10:12:36 ERROR tool.BaseSqoopTool: Unrecognized argument: 1
部分脚本:
#########################拼接sqoop语句##################--password ${8}
condition="'"${@:8}"'"
column="'"${2}"'"
sqoop_exec_str=" --connect ${1} --username ${6} --table ${3} --columns ${column} --where ${condition} --delete-target-dir --hive-overwrite --hive-import --hive-table ${4} --fields-terminated-by '\001' -m 1"
print_log "sqoop语句:sqoop import ${sqoop_exec_str}"
sqoop import ${sqoop_exec_str}
exit_exec $?
注:................. 上面的脚本都是通过vi编辑器编辑的
求各位大神解惑下,谢谢
...全文
相关推荐
解决Linux命令未找到报错[可运行源码]
在Linux系统中,用户在命令行环境下经常会使用各类命令来执行操作。然而,在执行命令时,有时会遇到“Bash: command not found”这样的报错信息。
mysql命令行备份及恢复数据库
例如:```sqlUSE news;SOURCE news.sql;```执行完`source`命令后,如果没有报错,则表示数据已经成功导入。
linux运维学习笔记:Shell脚本调试.pdf
其中,set -n选项会读取命令但不执行;set -v选项会显示所有读取的命令行;set -x选项则会显示所有命令及其参数。特别地,set +x可以关闭调试功能。
Linux下命令行安装weblogic
在Linux环境下,通过命令行安装Oracle WebLogic Server是一项常见的任务,尤其对于远程管理服务器或自动化部署来说。
Jmeter命令行执行脚本如何设置动态参数
接下来,我们将详细解读如何通过JMeter命令行执行脚本并设置动态参数。首先,JMeter在执行测试计划之前,会加载jmeter.properties和system.properties等属性文件。


