Re: [Tutor] subprocess check_output

2017-09-20 Thread Alan Gauld via Tutor
On 20/09/17 22:09, Derek Smith wrote: > Why does python output this b and newline characters Because that's what the command is returning. The b indicates its an array of bytes (as opposed to a unicode string) Note the module dpocumentation for check_output() says: "By default, this function wil

Re: [Tutor] subprocess module seems to be failing...

2016-06-03 Thread dirkjso...@gmail.com
Add sound of me beating my head with a bat! :) Thanks Peter! -I was a bit too precise in my naming conventions for later review! On 06/03/2016 02:30 PM, Peter Otten wrote: dirkjso...@gmail.com wrote: Running Linux Mint 17.3 Python3.4.3 I'm following a Tutor concerning the subprocess modul

Re: [Tutor] subprocess module seems to be failing...

2016-06-03 Thread Peter Otten
dirkjso...@gmail.com wrote: > Running Linux Mint 17.3 > Python3.4.3 > > I'm following a Tutor concerning the subprocess module which said to > open a Terminal SHELL and type: > > $ python3 > >>> import subprocess > >>> subprocess.call('ls', shell=True) > > Last night the subprocess.call porti

Re: [Tutor] subprocess outputing wrong info to command line

2015-02-20 Thread Steven D'Aprano
On Fri, Feb 20, 2015 at 06:58:17PM -0500, brads wrote: > My subprocess is in error but the same command at the command line works > fine. Are you running the Python script as the same user and from the same location as the command line? If you are running the Python script as an unprivileged us

Re: [Tutor] Subprocess how to use?

2014-11-06 Thread Cameron Simpson
On 06Nov2014 22:18, jarod...@libero.it wrote: Dear All thanks so much for the suggestion !!! One thing is not clear to me: How can write more safe string to send on subprocess.Popen() without %s? What is the best way to do this? The safest way is to use shell=False and pass a python list wit

Re: [Tutor] Subprocess how to use?

2014-11-06 Thread jarod...@libero.it
Dear All thanks so much for the suggestion !!! One thing is not clear to me: How can write more safe string to send on subprocess.Popen() without %s? What is the best way to do this? thanks so much! ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] Subprocess how to use?

2014-11-06 Thread Albert-Jan Roskam
- On Thu, Nov 6, 2014 12:57 AM CET Cameron Simpson wrote: >On 05Nov2014 14:05, jarod...@libero.it wrote: >> I need to use external program from my scirpt. >> code = "intersectBed -a %s -b /database/Refseq_Gene2.bed -wa -wb|cut -f >> 4,8|uniq > tmp.tmp1"%("gene5.tmp.

Re: [Tutor] Subprocess how to use?

2014-11-05 Thread Cameron Simpson
On 05Nov2014 14:05, jarod...@libero.it wrote: I need to use external program from my scirpt. code = "intersectBed -a %s -b /database/Refseq_Gene2.bed -wa -wb|cut -f 4,8|uniq > tmp.tmp1"%("gene5.tmp.bed") code2 = "intersectBed -a %s -b /database/Refseq_Gene2.bed -wa -wb|cut -f 4,8|uniq > tm

Re: [Tutor] Subprocess help

2014-09-21 Thread Danny Yoo
> "Semantically, the command above means: > execute "./octosetupBROADCASTER-linux_i386.bin" in an environment > that binds BYPASSROOT to "yes"." > > Does the above mean "BYPASSROOT" is an environmet variable? Is this created > and set by default by the system or is it created and set by > "octo

Re: [Tutor] Subprocess help

2014-09-21 Thread Crush
Thank you Danny for your assistance. Just a couple of follow up questions to help me understand what is going on. You said... "Semantically, the command above means: execute "./octosetupBROADCASTER-linux_i386.bin" in an environment that binds BYPASSROOT to "yes"." Does the above mean "BYPASSR

Re: [Tutor] Subprocess help

2014-09-20 Thread Danny Yoo
> The command I need to run is "BYPASSROOT=yes > ./octosetupBROADCASTER-linux_i386.bin" Semantically, the command above means: execute "./octosetupBROADCASTER-linux_i386.bin" in an environment that binds BYPASSROOT to "yes". The subprocess.Popen command takes in an optional "env" argument,

Re: [Tutor] subprocess not returning

2014-04-22 Thread shawn wilson
On Tue, Apr 22, 2014 at 3:10 PM, Alan Gauld wrote: > We have no clue what you are doing. You say "this works" > but we can't see what 'this' is. Is the code on the > pastebin link the working or the broken version? > Per what is expected output (which I forgot to provide - sorry about that). Sho

Re: [Tutor] subprocess not returning

2014-04-22 Thread Alan Gauld
On 22/04/14 10:14, shawn wilson wrote: This works when I have a class for ldd and nothing else, but when I run it like this: https://gist.github.com/ag4ve/11171201 I don't get any of the libraries and I can't figure out where it's failing. ['fattr', [['/testroot', 0, 0, 777], ['/bin/dash']]] HER

Re: [Tutor] Subprocess communications query

2013-12-11 Thread William Ray Wing
On Dec 10, 2013, at 2:28 PM, Reuben wrote: > Hi, > > There exists two Linux machines A and B. Machine B contains python script > which needs to be run e.g. Test.py > > In order to run that script, machine A needs to telnet into machine B and > then execute "python Test.py" > > How can this b

Re: [Tutor] Subprocess communications query

2013-12-10 Thread Steven D'Aprano
On Wed, Dec 11, 2013 at 12:58:16AM +0530, Reuben wrote: > Hi, > > There exists two Linux machines A and B. Machine B contains python script > which needs to be run e.g. Test.py > > In order to run that script, machine A needs to telnet into machine B and > then execute "python Test.py" Using tel

Re: [Tutor] Subprocess communications query

2013-12-10 Thread Steve Willoughby
Reuben wrote: >I want to implement a python script on machine A to do telnet/ssh into >machine B (this might be easy)and then run the Test.py (this is >challenging) >On 11-Dec-2013 1:05 AM, "Danny Yoo" wrote: > >> On Tue, Dec 10, 2013 at 11:28 AM, Reuben >wrote: >> > Hi, >> > >> > There exists t

Re: [Tutor] Subprocess communications query

2013-12-10 Thread Danny Yoo
Ok; so in your situation, it sounds like machine A is also running a Python script, and you want to automate the remote administration of machine B through that program. If that's the case, you may want to look at the "Fabric" library, or other libraries that help with driving ssh through Python:

Re: [Tutor] Subprocess communications query

2013-12-10 Thread Reuben
I want to implement a python script on machine A to do telnet/ssh into machine B (this might be easy)and then run the Test.py (this is challenging) On 11-Dec-2013 1:05 AM, "Danny Yoo" wrote: > On Tue, Dec 10, 2013 at 11:28 AM, Reuben wrote: > > Hi, > > > > There exists two Linux machines A and B

Re: [Tutor] Subprocess communications query

2013-12-10 Thread Danny Yoo
On Tue, Dec 10, 2013 at 11:28 AM, Reuben wrote: > Hi, > > There exists two Linux machines A and B. Machine B contains python script > which needs to be run e.g. Test.py > > In order to run that script, machine A needs to telnet into machine B and > then execute "python Test.py" Nothing about this

Re: [Tutor] subprocess module: when to _NOT_ use shell=True

2013-03-11 Thread akleider
Thank you "Eryksun" and "EikeWek" for your responses. It is this sort of thing that begins to pull one out of the newbie into the intermediate category. I'm grateful. alex > I've not found anywhere a clear explanation of when not to set shell=True. > If the command line must be interpreted by the

Re: [Tutor] subprocess module: when to _NOT_ use shell=True

2013-03-10 Thread Eike Welk
On Sunday 10.03.2013 09:56:26 aklei...@sonic.net wrote: > I've not found anywhere a clear explanation of when not to set shell=True. > If the command line must be interpreted by the shell then clearly this > must be set. So the question that comes up is why not set it always? Because ``shell=True`

Re: [Tutor] subprocess module: when to _NOT_ use shell=True

2013-03-10 Thread eryksun
On Sun, Mar 10, 2013 at 12:56 PM, wrote: > I've not found anywhere a clear explanation of when not to > set shell=True. If the command line must be interpreted by > the shell then clearly this must be set. So the question > that comes up is why not set it always? Using the shell can be a securit

Re: [Tutor] subprocess Popen PIPE error

2010-10-26 Thread Abhijeet Rastogi
Ya. Do it using python. Why do you want to use bash when you already have python? See, do something like this:- import os alldirs = os.listdir("/path/to/dir") DIRS = [] #Only the dirs you are interested in for i in alldirs: if i.find("deploy") is -1: L.append(i) if i.find("TEMPLATE"

Re: [Tutor] subprocess Popen PIPE error

2010-10-26 Thread Abhijeet Rastogi
Please read the documentation of Popen. You cannot pass arguments like that. >>> from subprocess import Popen,PIPE >>> import shlex >>> cmd="ls -l" >>> cmd=shlex.split(cmd) >>> p = Popen(cmd,stdout=PIPE,stderr=PIPE) or simply that means >>> p = Popen(['ls','-l'],stdout=PIPE,stderr=PIPE) Hope I

Re: [Tutor] subprocess output

2010-07-28 Thread Evert Rol
> #!/usr/bin/env python > import subprocess > import sys > > dom = sys.argv[1] > switch = sys.argv [2] > answer = subprocess.call("whois " + dom, shell=True) > > Execute the above (whatever.py -example.com -a1) prints the entire WHOIS > output, but I just want it saved to the variable 'answer', n

Re: [Tutor] subprocess output

2010-07-28 Thread Sander Sweers
- Original message - > I'm using Python 2.6.5 and I've got a challenge with the subprocess > module. I'd like the output to be stored in a variable, and not sent to > the stdout. The relevant lines as they are now: Go to google, enter "pymotw subprocess" and hit I am feeling lucky ;-) gre

Re: [Tutor] subprocess

2010-03-27 Thread Sander Sweers
On 27 March 2010 09:30, David Abbott wrote: > Here is an example using subprocess.call > http://dwabbott.com/code/index8.html > > and some more here with subprocess.Popen > http://asterisklinks.com/wiki/doku.php?id=wiki:subprocess On top of that we have the excelent PyMOTW from Doug on subprocess

Re: [Tutor] subprocess

2010-03-27 Thread kevin parks
Thanks David. Those are excellent short clear examples. I will look those over. Super! Thanks for that. -kp On Mar 27, 2010, at 5:30 PM, David Abbott wrote: > On Sat, 2010-03-27 at 16:55 +0900, kevin parks wrote: > > Here is an example using subprocess.call > http://dwabbott.com/code/index8.

Re: [Tutor] subprocess

2010-03-27 Thread David Abbott
On Sat, 2010-03-27 at 16:55 +0900, kevin parks wrote: > I tried readings some toots and tried reading alan's thing. I just still > can't grok how to use subprocess. > > I am trying to call sox (fun fact: an early contributer to sox was none other > than Guido van Rossum) > > In the old days you

Re: [Tutor] Subprocess Stdout Redirection

2010-02-07 Thread Gil Johnson
Muhammad, I am no expert, but I think you have to call proc_log.close() in your StartProc() to make sure that the file is written out to disk. If I understand what you are doing, you are trying to generate a new path for each pass through the loop, of the form 0/, 1/,... and write "MyLog.txt" to th

Re: [Tutor] subprocess/files help

2009-06-10 Thread Lie Ryan
Essah Mitges wrote: > game runs fine out of the WODDS.py it when I start it from the menu lies the > problemup-1.png is the first pic file used in the program so I'm guessing > that all of the imported files from data have a problem if i took away up-1 > up-2 would start a problem then side-1 an

Re: [Tutor] subprocess/files help

2009-06-10 Thread Essah Mitges
so on > From: sri...@gmail.com > Date: Wed, 10 Jun 2009 17:16:43 -0500 > Subject: Re: [Tutor] subprocess/files help > To: e_mit...@hotmail.com > CC: tutor@python.org > > On Wed, Jun 10, 2009 at 4:21 PM, Essah Mitges> wrote: > > > > > The p

Re: [Tutor] subprocess/files help

2009-06-10 Thread Wayne
On Wed, Jun 10, 2009 at 4:21 PM, Essah Mitges wrote: > > The problem I am have now is that once my game is initiated from the menu > file the modules that are with cannot import the imagesthe folder looks like > thisWODDSdataAll images and sound for gamegamelib > ObjectsU

Re: [Tutor] subprocess Popen

2009-04-03 Thread Tiago Saboga
On Fri, Apr 03, 2009 at 03:12:08PM -0700, Weidner, Ronald wrote: > I have a long running py script that I'm trying to kick off from > another long running py script as a separate process... If either > script fails or terminates, I don't want the other script to be > effected as a result. In other

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Martin Walsh
David wrote: > Martin Walsh wrote: > >> Welcome! > > thanks welcome (uh oh, infinite loop warning) > This "podcast_file.write('%s: %s' % (entry.updated, entry.link))" > writes it in one very long string Copy and paste gets me every time. Try this, and note the presence of the newline ('\n'):

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Alan Gauld
"David" wrote sys.stdout = open("podcast_links.txt", "a") print '%s' % (entry.link) sys.stdout.close() getFeed() This "podcast_file.write('%s: %s' % (entry.updated, entry.link))" writes it in one very long string Use podcastfile.writeline() to write it line by line

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
Martin Walsh wrote: Welcome! thanks You should probably try to avoid reassigning sys.stdout. This is usually a bad idea, and can cause odd behavior that is difficult to troubleshoot, especially for a beginner. A reasonable approach is to assign the open file object to a name of your own ch

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Martin Walsh
Hi David, David wrote: > Hi everyone. > Just learning :) I have one program to parse a podcast feed and put it > into a file. Welcome! > > def getFeed(): > url = raw_input("Please enter the feed: ") > data = feedparser.parse(url) > for entry in data.entries: > sys.stdout =

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread Kent Johnson
On Sun, Dec 21, 2008 at 7:29 PM, David wrote: > This seems to work; > > download = L.readline() > print download > download = download[0:-1] > > What is that last character that is added; > .mp3%0A It is a newline character (line feed). readline() includes the line endings in the returned lines.

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
This seems to work; download = L.readline() print download download = download[0:-1] What is that last character that is added; .mp3%0A -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] subprocess help, nohup

2007-11-18 Thread Martin Walsh
John wrote: > Hello, Hi John, I didn't see a response to your question, so I'll make an attempt ... > > I've written a script which conducts several subprocess calls and then > ultimately calls a shell script which runs even more programs... my > script is using subprocess to execute a few sed

Re: [Tutor] subprocess and su

2007-08-22 Thread Michael Meier
> how I thought that it was supposed to work was it would allow me to use > sbp.communicate() to > send stuff to the stdin, and get information out. What do get is a prompt > ask for my password. I believe that su does not read its input from stdin but from its controlling tty. So you'd have to o

Re: [Tutor] subprocess and su

2007-08-21 Thread Alan Gauld
"Alan Gauld" <[EMAIL PROTECTED]> wrote > Oddly I just tried some experiments and I can't get subprocess > to work with the stdout=PIPE option, it used to... > > Anyone have any idea what my obvious mistake is? > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\li

Re: [Tutor] subprocess and su

2007-08-21 Thread Alan Gauld
"Tino Dai" <[EMAIL PROTECTED]> wrote > PIPE=subprocess.pipe Not sure why you need this? > sbp=subprocess.Popen > (["su","-",stdin=PIPE,stdout=PIPE,close_fds=True,shell=True) and I'm not sure what that [ is doing in there? I assume you meant to have a closing ] after the "-"? Have you looked a

Re: [Tutor] subprocess and su

2007-08-21 Thread Eric Brunson
Tino Dai wrote: > Hi there, > > I'm have a tough time figuring out how to get su and subprocess > working. I have > > PIPE=subprocess.pipe > > sbp=subprocess.Popen(["su","-",stdin=PIPE,stdout=PIPE,close_fds=True,shell=True) > > > > how I thought that it was supposed to work was it would all

Re: [Tutor] subprocess and signals

2007-08-07 Thread Noufal Ibrahim
Eric Brunson wrote: > Noufal Ibrahim wrote: [..] >> def createSignalDelegator(p): >> def sighandler(signal,frame,pmake = p): >> os.kill(pmake.pid,signal) >> return sighandler >> >> pmake = subprocess.Popen(pmake_cmd, bufsize = 1, stdout = >> subprocess.PIPE, stderr = subprocess.

Re: [Tutor] subprocess and signals

2007-08-07 Thread Eric Brunson
Noufal Ibrahim wrote: > Hello everyone, >I've come across a situation which is somewhat confusing to me. >I googled for some details and came across another email thread on > this very list but couldn't really glean a solution out of it. > >I have a program (a compiled binary) for whic

Re: [Tutor] subprocess and launching an editor

2007-06-22 Thread Alan Gauld
"Jason Massey" <[EMAIL PROTECTED]> wrote > gedit launches with a blank file called window1. The python shell > is now > waiting for gedit to exit before it does anything else. > > 2nd console > --- import subprocess subprocess.call('gedit --new-window window2',shell=True) >

Re: [Tutor] subprocess and launching an editor

2007-06-22 Thread Alan Gauld
"Brian van den Broek" <[EMAIL PROTECTED]> wrote > gedit is the default text editor on my ubuntu feisty system, so in > the > first instance, I've tried to do this with gedit. The > subprocess.call: > > >>> subprocess.call("gedit somefilename", shell=True) > You should probably check the VISUAL

Re: [Tutor] subprocess and launching an editor

2007-06-22 Thread Jason Massey
I'm running Feisty as well. I launched python in two separate consoles and tried this: 1st console import subprocess subprocess.call('gedit --new-window window1',shell=True) gedit launches with a blank file called window1. The python shell is now waiting for gedit to exit be

Re: [Tutor] subprocess & pyw conflict ?

2006-12-07 Thread Dave S
On Thursday 07 December 2006 10:25, Dave S wrote: > On Thursday 07 December 2006 00:31, Luke Paireepinart wrote: > > Dave S wrote: > > > Hi all, > > > > > > I thought I had my solution with subprocess ... my test code ... > > > > > > > > > > > > #!/usr/bin/env python > > > # -*- coding: iso8859_1 -

Re: [Tutor] subprocess & pyw conflict ?

2006-12-07 Thread Dave S
On Thursday 07 December 2006 00:31, Luke Paireepinart wrote: > Dave S wrote: > > Hi all, > > > > I thought I had my solution with subprocess ... my test code ... > > > > > > > > #!/usr/bin/env python > > # -*- coding: iso8859_1 -*- > > > > import subprocess > > > > a = subprocess.Popen('tasklist.ex

Re: [Tutor] subprocess & pyw conflict ?

2006-12-06 Thread Luke Paireepinart
Dave S wrote: > Hi all, > > I thought I had my solution with subprocess ... my test code ... > > > > #!/usr/bin/env python > # -*- coding: iso8859_1 -*- > > import subprocess > > a = subprocess.Popen('tasklist.exe', bufsize=0, stdout=subprocess.PIPE, > universal_newlines=True) > op = a.s