公司让我做一个看一下在优化的程序和比原来的程序快多少,但是文件还在运行的服务器上,我需要把用到的文件复制到测试服务器上去。但是测试服务器上有的,目录不全,会导致scp出错。就发生了以下的故事。
首选我要查看每个程序用到的文件,然后我整理成了一个TXT
scp -r /DWH3/LV3/TRIALFL_TBL/* [email protected]:/DWH3/LV3/TRIALFL_TBL 1 scp /DWH3/LV3/URE/HANBAI_DAYLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_DAYLIST 1.1 scp /DWH3/TBL/TEN_KYAKURITU.RIREKI [email protected]:/DWH3/TBL/ scp /DWH3/TBL/ZEIRITU [email protected]:/DWH3/TBL/ scp /DWH3/TBL/JAN_TOUROKUDAY [email protected]:/DWH3/TBL/ scp /DWH3/TBL/BUNDLEID_PRODUCTCD_IRISU [email protected]:/DWH3/TBL/ scp /DWH3/LV3/URE/HANBAI_MEISAI/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_MEISAI/ scp /DWH3/LV3/URE/HANBAI_HEADER/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_HEADER/ 2 同1 2.1 同1.1.1 同1.1.2 同1.1.3 同1.1.4 同1.1.5 同1.1.6 3 同1 3.1 同1.1.1 同1.1.2 同1.1.3 同1.1.4 同1.1.5 同1.1.6 4~6 同一 7 scp /DWH3/LV3/URE/HANBAI_WEEKLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_WEEKLIST/ 7.1 scp /DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_TENANT/ 8 同7 8.1 scp /DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_TENANT/ 9 同7 9.1 scp /DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_TENANT/ 10 同7 10.1 scp /DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_TENANT/ 11 同7 11.1 scp /DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_TENANT/ 12 同7 12.1 scp /DWH/LV3/URE/HIBETU_FL_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_FL_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_FL_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_FL_KYAKUSU_TENANT/ 13 scp /DWH3/LV3/URE/HANBAI_MONTHLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_MONTHLIST/ 13.1 同7.1 14 同13 14.1 同8.1 15 同13 15.1 同9.1 16 同13 16.1 同10.1 17 同13 17.1 同11 18 同13 18.1 同12
一共十八个程序,暂时把这个文件保存成c
首先提取scp
cat c | sed -e ‘/^[^s]/d;/^$/d‘
scp -r /DWH3/LV3/TRIALFL_TBL/* [email protected]:/DWH3/LV3/TRIALFL_TBL scp /DWH3/LV3/URE/HANBAI_DAYLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_DAYLIST scp /DWH3/TBL/TEN_KYAKURITU.RIREKI [email protected]:/DWH3/TBL/ scp /DWH3/TBL/ZEIRITU [email protected]:/DWH3/TBL/ scp /DWH3/TBL/JAN_TOUROKUDAY [email protected]:/DWH3/TBL/ scp /DWH3/TBL/BUNDLEID_PRODUCTCD_IRISU [email protected]:/DWH3/TBL/ scp /DWH3/LV3/URE/HANBAI_MEISAI/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_MEISAI/ scp /DWH3/LV3/URE/HANBAI_HEADER/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_HEADER/ scp /DWH3/LV3/URE/HANBAI_WEEKLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_WEEKLIST/ scp /DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_TENANT/ scp /DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_TENANT/ scp /DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_TENANT/ scp /DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_TENANT/ scp /DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_TENANT/ scp /DWH/LV3/URE/HIBETU_FL_KYAKUSU_CHOKUEI/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_FL_KYAKUSU_CHOKUEI/ scp /DWH/LV3/URE/HIBETU_FL_KYAKUSU_TENANT/2016032*.gz [email protected]:/DWH/LV3/URE/HIBETU_FL_KYAKUSU_TENANT/ scp /DWH3/LV3/URE/HANBAI_MONTHLIST/2016032*.gz [email protected]:/DWH3/LV3/URE/HANBAI_MONTHLIST/
然后提取出在目标服务器运行shell
cat c | sed -e ‘/^[^s]/d;/^$/d‘ |sed -n ‘s/.*[email protected]:\S//p‘ |uniq |sed ‘s/^DWH/mkdir -p &/g‘
mkdir -p DWH3/LV3/TRIALFL_TBL mkdir -p DWH3/LV3/URE/HANBAI_DAYLIST mkdir -p DWH3/TBL/ mkdir -p DWH3/LV3/URE/HANBAI_MEISAI/ mkdir -p DWH3/LV3/URE/HANBAI_HEADER/ mkdir -p DWH3/LV3/URE/HANBAI_WEEKLIST/ mkdir -p DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_SUBSEGMENT_KYAKUSU_TENANT/ mkdir -p DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_SEGMENT_KYAKUSU_TENANT/ mkdir -p DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_SUBCATEGORY_KYAKUSU_TENANT/ mkdir -p DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_CATEGORY_KYAKUSU_TENANT/ mkdir -p DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_ZONE_KYAKUSU_TENANT/ mkdir -p DWH/LV3/URE/HIBETU_FL_KYAKUSU_CHOKUEI/ mkdir -p DWH/LV3/URE/HIBETU_FL_KYAKUSU_TENANT/
大功告成
时间: 2024-10-12 17:05:56