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


Groups > comp.lang.python > #87681

Re: Python script output in file

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cloverobert@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'subject:Python': 0.06; 'elements.': 0.07; 'subject:file': 0.07; 'sys': 0.07; 'wednesday,': 0.07; 'arguments': 0.09; 'spaces': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'wrote': 0.14; '&gt;&gt;': 0.16; 'above)': 0.16; 'backslash': 0.16; 'calculates': 0.16; 'elements,': 0.16; 'separated': 0.16; 'skip:[ 30': 0.16; 'skip:[ 40': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'command': 0.22; 'import': 0.22; 'separate': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; '(such': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'options': 0.25; 'script': 0.25; '&gt;': 0.26; 'shown': 0.26; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'robert': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'getting': 0.31; 'perl': 0.31; 'interface': 0.32; 'run': 0.32; 'another': 0.32; 'url:python': 0.33; 'skip:# 10': 0.33; 'skip:& 30': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'skip:& 10': 0.38; 'url:library': 0.38; 'skip:[ 10': 0.38; 'skip:& 20': 0.39; 'skip:. 10': 0.39; 'url:mail': 0.40; 'how': 0.40; 'march': 0.61; 'to:addr:gmail.com': 0.65; 'mar': 0.68; 'containing': 0.69; '2015': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=DTYFpto6pU1dTVmFjCLZopvMYd4Xxj/ZpbYeOMmzqrc=; b=hJFdd5jVt3F7Nr7+64QanPqc1v350LQzCHzNYQ9cdmlkh80651gkklLv1rJMkS12cL sPaM8nlS6lEklIUa+L5mtaTY01CtEW3v4yAN2fqp8PJGblZdK/cmJjeFz5+v1PRIZfPq 3YmTpGtSkdtJQlvX7uW9QbAAIGoXZa+sCATrNBT9iXE5snmaf8EHhtxF8ulBQ7Cqabvt rmDlnGjT2A+y11f9m6Rt2wyj2cHz1wy78QG8QywqLQiAKHB20Dw+uFjB4QXd/e0q3IM8 S4NoUl1epa+Wvdv3i7uSvn0SZV48GfrIhgNbhxVJW0v+mG/6hlkPOYIF7erabZX7FBYH ep7A==
MIME-Version 1.0
X-Received by 10.182.72.169 with SMTP id e9mr58124371obv.23.1426689716001; Wed, 18 Mar 2015 07:41:56 -0700 (PDT)
In-Reply-To <cb602e99-4158-4eac-8036-095f47041c1b@googlegroups.com>
References <mailman.520.1426674938.21433.python-list@python.org> <cb602e99-4158-4eac-8036-095f47041c1b@googlegroups.com>
Date Wed, 18 Mar 2015 07:41:55 -0700
Subject Re: Python script output in file
From Robert Clove <cloverobert@gmail.com>
To Rustom Mody <rustompmody@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=001a11c2eeeaba23330511911583
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1.1426689718.10327.python-list@python.org> (permalink)
Lines 113
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426689718 news.xs4all.nl 2975 [2001:888:2000:d::a6]:53531
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87681

Show key headers only | 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