Skip to content
Advertisement

Tag: subprocess

(py2.7) long “echo” via subprocess

I’m starting to write some python code to initiate new servers/VM(s) with proxy servers This hasn’t been working due to syntax error so I tried dividing n into But still this syntax error? Thanks! I’ve tried many combinations of ‘ and ” but no luck. Answer The problem is “echo “http_proxy=”http://proxy.srx.com:80/””… is not a valid string you should use:

Python popen() – communicate( str.encode(encoding=”utf-8″, errors=”ignore”) ) crashes

Using Python 3.4.3 on Windows. My script runs a little java program in console, and should get the ouput: This leads to a normal ‘UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x9d in position 135: character maps to < undefined>’. Now I want to ignore errors: This leads to a more interesting error I found no help for using google: TypeError:

How to pass variables in parent to subprocess in python?

I am trying to have a parent python script sent variables to a child script to help me speed-up and automate video analysis. I am now using the subprocess.Popen() call to start-up 6 instances of a child script but cannot find a way to pass variables and modules already called for in the parent to the child. For example, the

running multiple bash commands with subprocess

If I run echo a; echo b in bash the result will be that both commands are run. However if I use subprocess then the first command is run, printing out the whole of the rest of the line. The code below echos a; echo b instead of a b, how do I get it to run both commands? Answer

Python subprocess and user interaction

I’m working on a GUI front end in Python 2.6 and usually it’s fairly simple: you use subprocess.call() or subprocess.Popen() to issue the command and wait for it to finish or react to an error. What do you do if you have a program that stops and waits for user interaction? For example, the program might stop and ask the

Terminal text becomes invisible after terminating subprocess

After terminating an ffmpeg subprocess, the terminal gets messed up – typed characters are invisible! The input still works in that commands can be executed, but keyboard input is not echoed to the terminal. Issuing shell command reset puts everything back to normal (or !reset from within ipython), so a workaround the issue is calling os.system(‘reset’) inside the script. Other

How to get exit code when using Python subprocess communicate method?

How do I retrieve the exit code when using Python’s subprocess module and the communicate() method? Relevant code: Should I be doing this another way? Answer Popen.communicate will set the returncode attribute when it’s done(*). Here’s the relevant documentation section: So you can just do (I didn’t test it but it should work): (*) This happens because of the way

How to attach debugger to a python subproccess?

I need to debug a child process spawned by multiprocessing.Process(). The pdb degugger seems to be unaware of forking and unable to attach to already running processes. Are there any smarter python debuggers which can be attached to a subprocess? Answer Winpdb is pretty much the definition of a smarter Python debugger. It explicitly supports going down a fork, not

Advertisement