dpi数据接入shell脚

原文:dpi数据接入shell脚本_weixin_34416754的博客-CSDN博客

##############从ftp服务器拿数据文件

#!/bin/bash

#获取感知优良率DPI数据
#DCN服务器信息
u=Sichuan
p=S988188#
ip=137.192.5.53

#获取日期,根据日期抓取文件
T=`date -d "3 days ago" +%Y%m%d`

#写入日志
echo "(`date`) get data start...." >> /vm/hym/dpidata/getdata.log
echo "===================================================" >> /vm/hym/dpidata/getdata.log
function getdata_from_ftp(){
ftp -n <<EOF
open ${ip}
user ${u} ${p}
binary
cd / #远程服务器文件目录

#打开交互模式
prompt off
#下载特定日期的数据文件
mget *$T*
close
bye
EOF
}

#从DCN服务器get数据到本地目录
getdata_from_ftp >>/vm/hym/dpidata/getdata.log

#批量处理数据文件,将'|' 替换为','
sed -i 's/|/,/g' *$T*

#拷贝当天的数据文件到88服务器
scp *$T* root@133.37.23.88:/home/hdfs/hym/dpidata/

#触发88服务器上面put数据到hdfs的脚本
ssh root@133.37.23.88<<EOF
cd /home/hdfs/hym/dpidata/
sh put_data.sh ${T}
EOF

##############从ftp服务器拿数据文件,放到hive表里 

#!/bin/bash

#获取数据的天分区
T=`date -d "3 days ago" +%Y-%m-%d`

#在hdfs建立文件路径,将数据文件Put到hdfs
su - hdfs -c "hdfs dfs -mkdir -p /zxvmax/telecom/union/mobile_good_rate_DPI_GP_date/p_provincecode=510000/p_date=$T"
su - hdfs -c "hdfs dfs -put /home/hdfs/hym/dpidata/GP_$1.txt /zxvmax/telecom/union/mobile_good_rate_DPI_GP_date/p_provincecode=510000/p_date=$T"

su - hdfs -c "hdfs dfs -mkdir -p /zxvmax/telecom/union/mobile_good_rate_DPI_GR_date/p_provincecode=510000/p_date=$T"
su - hdfs -c "hdfs dfs -put /home/hdfs/hym/dpidata/GR_$1.txt /zxvmax/telecom/union/mobile_good_rate_DPI_GR_date/p_provincecode=510000/p_date=$T"

su - hdfs -c "hdfs dfs -mkdir -p /zxvmax/telecom/union/mobile_good_rate_DPI_EC_date/p_provincecode=510000/p_date=$T"
su - hdfs -c "hdfs dfs -put /home/hdfs/hym/dpidata/EC_$1.txt /zxvmax/telecom/union/mobile_good_rate_DPI_EC_date/p_provincecode=510000/p_date=$T"


#连接spark,修复表分区
/home/mr/spark/bin/beeline -u jdbc:hive2://133.37.23.88:18000/zxvmax -n mr -p ""<<Eof
msck repair table mobile_good_rate_DPI_EC_date;
msck repair table mobile_good_rate_DPI_GR_date;
msck repair table mobile_good_rate_DPI_GP_date;
Eof

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的UVM DPI接口的使用实例,以调用外部C函数为例: 1. 外部C函数的实现: ``` // dpi_function.h #ifndef DPI_FUNCTION_H #define DPI_FUNCTION_H #ifdef __cplusplus extern "C" { #endif int add(int a, int b); #ifdef __cplusplus } #endif #endif // DPI_FUNCTION_H ``` ``` // dpi_function.c #include "dpi_function.h" int add(int a, int b) { return a + b; } ``` 2. 在UVM环境中创建UVM DPI组件: ``` // dpi_component.sv class dpi_component extends uvm_component; `uvm_component_utils(dpi_component) extern function int add(int a, int b); int result; function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual function void build_phase(uvm_phase phase); super.build_phase(phase); endfunction virtual function void run_phase(uvm_phase phase); super.run_phase(phase); result = add(1, 2); $display("Result is %d", result); endfunction endclass ``` 3. 在UVM Testbench中实例化UVM DPI组件: ``` // testbench.sv module testbench; dpi_component dpi_comp; initial begin uvm_config_db#(virtual dpi_component)::set(null, "*", "dpi_comp", dpi_comp); run_test(); end endmodule ``` 4. 编译并运行: ``` # 编译外部C代码 $ gcc -c dpi_function.c $ ld -shared dpi_function.o -o dpi_function.so # 编译UVM环境 $ vlog dpi_component.sv $ vlog testbench.sv $ vsim -c -do "run -all" testbench ``` 在运行时,UVM DPI组件将会调用外部C函数add,并将结果显示在屏幕上。需要注意的是,在编译时需要使用相同的编译器和编译选项,以保证DPI接口能够正确连接和调用外部函数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值