# coding=UTF-8

import os
def distcp():
nncheck = os.system('lsof -i:8020')
dncheck = os.system('lsof -i:50010')
if nncheck == 256 and (dncheck == 256):
os.system("su - hdfs hadoop-daemon.sh start namenode")
os.system("su - hdfs hadoop-daemon.sh start datanode")
else:
os.system("hadoop distcp -f hdfs://192.168.66.128:8020/user/hive/warehouse/test.db hdfs://192.168.66.129:8020/user/hive/warehouse/test.db") if __name__ == "__main__":
distcp()

  

Python记录-python执行shell命令的更多相关文章

  1. Python ssh 远程执行shell命令

    工具 python paramiko 远程执行命令 import paramiko ssh = paramiko.SSHClient() key = paramiko.AutoAddPolicy() ...

  2. python中command执行shell命令脚本方法

    在Python中有一个模块commands也很容易做到以上的效果.看一下三个函数:1). commands.getstatusoutput(cmd)用os.popen()执行命令cmd, 然后返回两个 ...

  3. python之commands和subprocess入门介绍(可执行shell命令的模块)

    一.commands模块 1.介绍 当我们使用Python进行编码的时候,但是又想运行一些shell命令,去创建文件夹.移动文件等等操作时,我们可以使用一些Python库去执行shell命令. com ...

  4. C++/Php/Python 语言执行shell命令

    编程中经常需要在程序中使用shell命令来简化程序,这里记录一下. 1. C++ 执行shell命令 #include <iostream> #include <string> ...

  5. 「Python」6种python中执行shell命令方法

    用Python调用Shell命令有如下几种方式: 第一种: os.system("The command you want"). 这个调用相当直接,且是同步进行的,程序需要阻塞并等 ...

  6. python中执行shell命令的几个方法小结

    原文 http://www.jb51.net/article/55327.htm 最近有个需求就是页面上执行shell命令,第一想到的就是os.system, os.system('cat /proc ...

  7. python的subprocess模块执行shell命令

    subprocess模块可以允许我们执行shell命令 一般来说,使用run()方法就可以满足大部分情况 使用run执行shell命令 In [5]: subprocess.run('echo &qu ...

  8. python中执行shell命令行read结果

    +++++++++++++++++++++++++++++ python执行shell命令1 os.system 可以返回运行shell命令状态,同时会在终端输出运行结果 例如 ipython中运行如 ...

  9. python中执行shell命令的几个方法小结(转载)

    转载:http://www.jb51.net/article/55327.htm python中执行shell命令的几个方法小结 投稿:junjie 字体:[增加 减小] 类型:转载 时间:2014- ...

  10. python(6)-执行shell命令

    可以执行shell命令的相关模块和函数有: os.system os.spawn* os.popen*          --废弃 popen2.*           --废弃 commands.* ...

随机推荐

  1. Oracle DG 三种模式

    DG有下面三种模式– Maximum protection– Maximum availability– Maximum performance 在Maximum protection下, 可以保证从 ...

  2. 使用jquery修改display属性

    var show = $('#test').css('display'); $('#test').css('display',show =='block'?'none':show); 这段代码通过判断 ...

  3. C# Ninject使用

    Ninject是一个IOC容器,用来解决程序中组件的耦合问题,它的目的在于做到最少配置.简单来讲就是 为我们选择一个想要的类来处理事务. 百度百科的解释:一个快如闪电.超轻量级的基于.Net平台的依赖 ...

  4. leetcode解题报告(33): Find All Numbers Disappeared in an Array

    描述 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ...

  5. 自主设计BootLoader框架笔记一栏

  6. AtCoder Grand Contest 004题解

    传送门 \(A\) 咕咕 int a,b,c; int main(){ scanf("%d%d%d",&a,&b,&c); if((a&1^1)|( ...

  7. Linux下多线程模拟停车场停车

    #include<stdio.h> #include<string.h> #include<unistd.h> #include<stdlib.h> # ...

  8. CF1208题解

    C \(\begin{aligned}\ 0 0 1 1\\ 0 0 1 1\\ 2 2 3 3\\ 2 2 3 3\\ \end{aligned}\)将每个四方格分别加上\(0,4,8,12\) D ...

  9. DEFINE_CG_MOTION宏【注释版】

    线速度是通过物体上的x方向的力平衡达到的.表达形式为: 此处v为速度,F为外力,m为质量.使用显示欧拉格式表达t时刻速度为: 源代码: #include "udf.h" stati ...

  10. 4、vueJs基础知识04

    简单的目录结构: |-index.html |-main.js 入口文件 |-App.vue vue文件(组件),官方推荐命名法(首字母大写) |-components      组件存放的文件夹 | ...