shell - 如何在配置单元中调用shell脚本

标签 shell hadoop hive

有人可以解释一下如何从配置单元调用 shell 脚本吗?我对此进行了探索,发现我们必须使用 source FILE 命令从配置单元调用 shell 脚本。但是我不确定如何使用 source File 命令从配置单元中调用我的 shell 脚本。那么有人可以帮我吗?提前致谢。

最佳答案

使用 ! <command> - Executes a shell command from the Hive shell.

test_1.sh:

#!/bin/sh
echo "This massage is from $0 file"

hive 测试.hql:

! echo showing databases... ; 
show databases;

! echo showing tables...;
show tables;

! echo runing shell script...;
! /home/cloudera/test_1.sh

输出:

$ hive -v -f hive-test.hql
showing databases...

    show databases
OK
default
retail_edw
sqoop_import
Time taken: 0.997 seconds, Fetched: 3 row(s)
showing tables...

    show tables
OK
scala_departments
scaladepartments
stack
stackover_hive
Time taken: 0.062 seconds, Fetched: 4 row(s)
runing shell script...
This massage is from /home/cloudera/test_1.sh file

关于shell - 如何在配置单元中调用shell脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38874998/

相关文章:

hadoop - Hive中如何使用DistCp直接将数据转表?

hadoop - 使用 chmod 安装 hadoop

hadoop - 当我运行配置单元选择查询时连接被拒绝

c - 编写shell程序中的段错误C

python - hadoop-streaming:作业完成后自动进行后处理吗?

linux - 如何为文件的每一行创建文件夹?

java - Hiveserver2无法启动: “ascii codec cant encode character”

hadoop - 基于时间的目录结构Apache Drill

linux - 在脚本中创建临时文件 : Advantages of mktemp over touch-ing a file?

linux - '&' 是否在 linux shell 脚本中执行并行或线性作业?