2016-12-19 5 views
0

自分のシステムからDNS値をチェックしたいと思います。私のシステムからDNS値を確認したい

コマンドが間違っている場合、エラーは別の変数に格納する必要があります。

これは私がこれまで持っているものです。

proc = subprocess.Popen(['echo', '"to stdout"'], stdout=subprocess.PIPE,) 

stdout_value = proc.communicate() 
print '\tstdout:', repr(stdout_value) 

subprocess.call('echo #user', shell=True) 
#subprocess.check_call('echo #HOME', shell=True) 

答えて

0

あなたはこれを試してみてください:

それはあなたが引数として渡されたコマンドからのエラーコード、stdoutとstderrをキャプチャ: インポートはサブプロセスから をのshlex import Popen、PIPE

def get_exitcode_stdout_stderr(cmd): 

    """ 
    Execute the external command and get its exitcode, stdout and stderr. 
    """ 
    args = shlex.split(cmd) 

    proc = Popen(args, stdout=PIPE, stderr=PIPE) 
    out, err = proc.communicate() 
    exitcode = proc.returncode 
    # 
    return exitcode, out, err 

cmd = "..." # arbitrary external command, e.g. "python mytest.py" 
exitcode, out, err = get_exitcode_stdout_stderr(cmd) 

あなたの必要に応じて、私はあなたの代わりにあなたが望むものを得るためにPythonモジュールを使うことができると思いますbashのcmd行を歌います。たとえば、完全修飾ドメイン名を取得するには、次のものを使用できます。

+0

これらのデータがある場合は、そして、私は40035FC8だけを持っています 40027C5C 40035FC8このファイルからロジックは何ですか?D:40035FC8 wr-long 00000008 \\ core0 \ Global \ u4TimeHiCnt 1.000us * D:40027C5C rd-byte 00 * core0 \ Global \ Ypf_OILL_OilLvlOn 20.342us * D:40010044 rd-word 0FE2 * l \ u2SAD_OILLVS_RecoveryCounter 0.160us * D:40010044 wr-word 0FE1 * l \ u2SAD_OILLVS_RecoveryCounter 0.040us * D:40035FC8 wr-long 00000008 \\ core0 \ Global \ u4TimeHiCnt 1.000us – mak

関連する問題