Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87673

Python script output in file

Date 2015-03-18 06:35 -0400
Subject Python script output in file
From Robert Clove <cloverobert@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.520.1426674938.21433.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

I have a perl script named "my_eth-traffic.pl" which calculates the tx and
rx speed of the Ethernet interface in Mb.

I want to run this script from another script and want the output in other
file.
So i wrote the following script but not getting the output.

#!/usr/bin/python

import sys
import subprocess
import datetime
import os
import time

comand8 = "/root/Desktop/my_eth-traffic.pl eth0 M"

filename = logfilename+packetsize+'-'+formated_string+'.txt'
    logfile = open("/root/Desktop/speed.txt", 'w')


proc=subprocess.Popen(comand8,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    for line in proc.stdout:
                   logfile.write(line)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Python script output in file Robert Clove <cloverobert@gmail.com> - 2015-03-18 06:35 -0400
  Re: Python script output in file Rustom Mody <rustompmody@gmail.com> - 2015-03-18 03:49 -0700
    Re: Python script output in file Robert Clove <cloverobert@gmail.com> - 2015-03-18 07:41 -0700
      Re: Python script output in file Rustom Mody <rustompmody@gmail.com> - 2015-03-18 11:06 -0700
        Re: Python script output in file Rustom Mody <rustompmody@gmail.com> - 2015-03-18 11:10 -0700

csiph-web