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


Groups > comp.lang.python > #87681

Re: Python script output in file

References <mailman.520.1426674938.21433.python-list@python.org> <cb602e99-4158-4eac-8036-095f47041c1b@googlegroups.com>
Date 2015-03-18 07:41 -0700
Subject Re: Python script output in file
From Robert Clove <cloverobert@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1.1426689718.10327.python-list@python.org> (permalink)

Show all headers | View raw


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

./my_eth_script.pl eth0 M >> a.txt

How can i run this command with subprocess.popen

On Wed, Mar 18, 2015 at 3:49 AM, Rustom Mody <rustompmody@gmail.com> wrote:

> On Wednesday, March 18, 2015 at 4:06:05 PM UTC+5:30, Robert Clove wrote:
> > 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"
>
> From Popen docs
> https://docs.python.org/2/library/subprocess.html#subprocess.Popen
>
>
> Note in particular that options  and arguments  that are separated by
> whitespace in the shell go in separate list elements, while arguments that
> need
> quoting or backslash escaping when used in the shell (such as filenames...
>
> So (I guess) you should try
> comand8 = ["/root/Desktop/my_eth-traffic.pl", "eth0", "M"]
> Or better
> comand8 = ["perl", "/root/Desktop/my_eth-traffic.pl", "eth0", "M"]
> containing spaces or the echo command shown above) are single list
> elements.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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