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: 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; '>>': 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; '>': 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: References: Date: Wed, 18 Mar 2015 07:41:55 -0700 Subject: Re: Python script output in file From: Robert Clove To: Rustom Mody Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --001a11c2eeeaba23330511911583 Content-Type: text/plain; charset=UTF-8 ./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 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 > --001a11c2eeeaba23330511911583 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
./my_eth_script.p= l eth0 M >> a.txt

How can i run this command with su= bprocess.popen

On Wed, Mar 18, 2015 at 3:49 AM, Rustom Mody <<= a href=3D"mailto:rustompmody@gmail.com" target=3D"_blank">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 r= x speed of the Ethernet interface in Mb.
>
> I want to run this script from another script and want the output in o= ther file.
> So i wrote the following script but not getting the output. =C2=A0
>
>
> #!/usr/bin/python
>
> import sys
> import subprocess
> import datetime
> import os
> import time
>
> comand8 =3D "/root/Desktop/my_eth-traffic.pl eth0 M"

From Popen docs
https://docs.python.org/2/library/subprocess.html#sub= process.Popen


Note in particular that options=C2=A0 and arguments=C2=A0 that are separate= d 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...<= br>
So (I guess) you should try
comand8 =3D ["/root/Desktop/my_eth-traffic.pl", "eth0", "M"]<= br> Or better
comand8 =3D ["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

--001a11c2eeeaba23330511911583--