zoukankan      html  css  js  c++  java
  • python 执行命令

    def readmqmessage(req):
        print  req.get_full_path()
        print req.GET['queue']
        qname=req.GET['queue']
        output=commands.getstatusoutput("/home/mqm/sbin/read_mq_message QMEMBFE 'SYSTEM.ADMIN.SVRCONN' '10.3.244.1' '1417' %s" % qname)
        aa={'response':output}
        return HttpResponse(json.dumps(aa), content_type="application/json")
    def getmqmessage(req):
        print  req.get_full_path()
        print req.GET['queue']
        qname=req.GET['queue']
        output=commands.getstatusoutput("/home/mqm/sbin/get_mq_message QMEMBFE 'SYSTEM.ADMIN.SVRCONN' '10.3.244.1' '1417' %s" % qname)
        aa={'response':output}
        return HttpResponse(json.dumps(aa), content_type="application/json")
    
    
    node2:/root/python#cat a7.py 
    import commands
    str='测试'
    aa= commands.getstatusoutput("echo %s >>aa.txt" % str)
    print type(aa)
    print aa
    
    node2:/root/python#cat aa.txt
    cat: aa.txt: No such file or directory
    node2:/root/python#python a7.py 
      File "a7.py", line 2
    SyntaxError: Non-ASCII character 'xe6' in file a7.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
    
    
    node2:/root/python#cat a7.py 
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import commands
    str='测试'
    aa= commands.getstatusoutput("echo %s >>aa.txt" % str)
    print type(aa)
    print aa
    
    
    node2:/root/python#python a7.py 
    <type 'tuple'>
    (0, '')
    node2:/root/python#cat aa.txt 
    测试

  • 相关阅读:
    Linux shell脚本学习
    正则表达式 学习-编辑
    新装ubuntu使用vi时方向键不起作用
    vi
    ln
    crontab
    64bit ubuntu 14 04 LTS 安装 google chrome
    64bit ubuntu 14 04 LTS 安装 adobe flash player
    glogin.sql的常用配置
    sql基本语句(一)select
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349339.html
Copyright © 2011-2022 走看看