# 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. python get/post接口使用

    背景: 使用python调用get post接口,入参.出参都需要转换,在使用时经常会忘记其中的一步,本文用来记录,后面再使用时直接参考使用 代码如下 post: headers = {'Conten ...

  2. VS - Microsoft.Practices.Unity

    PM>  Install-Package Unity Web.config <configSections> <section name="unity" t ...

  3. 数据库(以MySQL为例)

    一.数据库简介 数据库就是数据的仓库,用来按照特定的结构去组织和管理数据,有了数据库可以更加方便.便捷的操作需要保存的数据 不管是什么数据库,最终都是将数据保存到硬盘中,只是存储的格式不同于文本文件 ...

  4. mysql创建账号、授权、数据导出、导入

    1.账号创建及授权 grant all privileges on *.* to 'yangxin'@'%' identified by 'yangxin123456' with grant opti ...

  5. Java SpringBoot 实体类数据自动验证

    package demo.dto; import org.hibernate.validator.constraints.Length; import javax.validation.constra ...

  6. [Shell]MySql慢查询日志GetShell

    通过开启慢查询日志,配置可解析日志文件GETSHELL. MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应时间超过阀值的语句. long_query_time的默认值 ...

  7. sql 数字转换为字符串补0

    select right('00000000000'+convert(varchar(5),123),5) select right('00000000000'+cast(123   as   var ...

  8. 讲座 - Transposable elements, non-coding RNAs and epigenetic control in embryonic stem cells

    Dr. Andrew Paul HutchinsDepartment of BiologySouthern University of Science and Technology, Shenzhen ...

  9. (基因功能 & 基因表达调控)研究方案

    做了好久的RNA-seq分析,基因表达也在口头溜了几年了,但似乎老是浮在表面. 对一件事的了解程度决定了你的思维深度,只想做技工就不用想太多,想做大师就一定要刨根问底. 老是说基因表达,那么什么是基因 ...

  10. 常见的医学基因筛查检测 | genetic testing | 相癌症早筛 | 液体活检

    NIPT, Non-invasive Prenatal Testing - 无创产前基因检测 (学术名词) NIFTY,胎儿染色体异常无创产前基因检测 (注册商标)华大的明显产品 新生儿耳聋基因检测 ...