os.system

How do I get data from stdin using os.system()

The only reliable method that I a have found for using a script to download text from wikipedia is with cURL. So far the only way I have for doing that is to call os.system(). Even though the output appears properly in the python shell I can't seem to the function it to return anything other than the exit code(0). Alternately somebody co...

Executing shell commands as given UID in Python

I need a way to execute the os.system() module as different UID's. It would need to behave similar to the following BASH code (note these are not the exact commands I am executing): su user1 ls ~ mv file1 su user2 ls ~ mv file1 The target platform is GNU Linux Generic. Of course I could just pass these to the os.system module, but h...

Python, trying to run a program from the command prompt

Hi All, I am trying to run a program from the command prompt in windows. I am having some issues. The code is below: commandString = "'C:\Program Files\WebShot\webshotcmd.exe' //url '" + columns[3] + "' //out '"+columns[1]+"~"+columns[2]+".jpg'" os.system(commandString) time.sleep(10) So with the single quotes I get "The filename, di...

Help with MySQL (.sql) and Shell Script

How do I call the following in a .sql file? mysql -u username -h serverip db -e "select a, b, c, d from mytable" > '/home/dump/result.txt'; I will then have to convert the tab separated file to csv for which I want to use sed. Is there a way to do it all in one line? (append sed command to convert the .txt file to csv) How to use ...

Python: How to execute a SQL file or command

Hi, I have this Python script: import sys import getopt import timeit import random import os import re import ibm_db import time from string import maketrans runs=5 queries=50 file = open("results.txt", "a") for r in range(5): print "Run %s\n" % r os.system("python reads.py -r1 -pquery1.sql -q50 -sespec") file.write('END...

Start local PHP script w/ local Python script

The Python program I'm writing needs to start a local PHP script outside of Python's process. The program also needs to pass params to the PHP script. So far this seems to start the script: os.system( path_to_script_here param param ) However, I'm pretty certain that Python remains running until the PHP script is complete. I've als...

Redirecting stdio from a command in os.system() in python

Usually I can change stdout in python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in python? Thank you ...

Overcoming os.system() limitation in Python 2.3

I am having a problem converting one of my company's scripts from csh to Python. The csh script calls an aliased command, but when I call that same aliased command via os.system(), it does not work. So, if foo is the aliased command: CSH Script (this works, executes foo): foo <argument> Python (this does not work, error claims foo ...

issue running a program (R) in Python to perform an operation (execute a script)

Hi all, I'm tying to execute an R script from python, ideally displaying and saving the results. Using rpy2 has been a bit of a struggle, so I thought I'd just call R directly. I have a feeling that I'll need to use something like "os.system" or "subprocess.call," but I am having difficulty deciphering the module guides. Here's the R...

Python 'source HOME/.bashrc' with os.system()

I am writing a python script (Linux) that is adding some shell aliases (writes them to HOME/.bash_aliases). In order to make an alias available immediately after it was written I should issue the following bash built-in: source HOME/.bashrc source is a bash built-in so I cannot just: os.system(source HOME/.bashrc) If i try somethi...

Python, os.system for command-line call (linux) not returning what it should?

I need to make some command line calls to linux and get the return from this, however doing it as below is just returning 0 when it should return a time value, like 00:08:19, I am testing the exact same call in regular command line and it returns the time value 00:08:19 so I am confused as to what I am doing wrong as I thought this was h...

Python, using os.system - Is there a way for Python script to move past this without waiting for call to finish?

I am trying to use Python (through Django framework) to make a Linux command line call and have tried both os.system and os.open but for both of these it seems that the Python script hangs after making the command line call as the call is for instantiating a server (so it never "finishes" as its meant to be long-running). I know for doin...