有人可以解释一下如何从配置单元调用 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/