Re: os.system and subprocess odd behavior

2012-12-18 Thread Cameron Simpson
On 18Dec2012 05:39, Dave Angel wrote: | On 12/18/2012 05:27 AM, Hans Mulder wrote: | > On 18/12/12 06:10:43, photonym...@gmail.com wrote: | >> I hope I understand the question... but shouldn't you wait for the process to complete before exiting? | >> | >> Something like: | >> | >> pid = subproces

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 17/12/12 21:56:50, py_genetic wrote: > /usr/local/Calpont/mysql/bin/mysql > --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB < > /home/myusr/jobs/APP_JOBS/JOB_XXX.SQL > /home/myusr/jobs/APP_JOBS/JOB_XXX.TXT If you're trying to interact with a MySQL database, then you should really

Re: os.system and subprocess odd behavior

2012-12-18 Thread py_genetic
Solved the issue, by injecting the query into the cmd line. Shell script worked fine as if I was cutting and pasting to the prompt. Seems to still be something with the subprocess receiving and exit code before or when the query finishes, just when I ask to to read from the .SQL file. example

Re: os.system and subprocess odd behavior

2012-12-18 Thread Oscar Benjamin
Can you trim content and interleave your response (instead of top-posting) please? On 18 December 2012 18:26, py_genetic wrote: > HOWEVER... > > when using this command from before no dice > > /usr/local/Calpont/mysql/bin/mysql > --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB <

Re: os.system and subprocess odd behavior

2012-12-18 Thread py_genetic
Oscar I can confirm this behavior from terminal. AND this works as well, simulating exactly what I'm doing permissions wise, and calling sudo python test.py below f1 = open('TESTDIR/file1.txt', 'w') f1.write('some test here\n') f1.close() cmd1 = 'cat < TESTDIR/file1.txt > TESTDIR/file2.txt' P

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 18/12/12 11:39:56, Dave Angel wrote: > On 12/18/2012 05:27 AM, Hans Mulder wrote: >> On 18/12/12 06:10:43, photonym...@gmail.com wrote: >>> I hope I understand the question... but shouldn't you wait for the process >>> to complete before exiting? >>> >>> Something like: >>> >>> pid = subprocess

Re: os.system and subprocess odd behavior

2012-12-18 Thread Dave Angel
On 12/18/2012 05:27 AM, Hans Mulder wrote: > On 18/12/12 06:10:43, photonym...@gmail.com wrote: >> I hope I understand the question... but shouldn't you wait for the process >> to complete before exiting? >> >> Something like: >> >> pid = subprocess.Popen(...) >> pid.wait() >> >> Otherwise, it'll

Re: os.system and subprocess odd behavior

2012-12-18 Thread Hans Mulder
On 18/12/12 06:10:43, photonym...@gmail.com wrote: > I hope I understand the question... but shouldn't you wait for the process to > complete before exiting? > > Something like: > > pid = subprocess.Popen(...) > pid.wait() > > Otherwise, it'll exit before the background process is done. Why w

Re: os.system and subprocess odd behavior

2012-12-17 Thread photonymous
I hope I understand the question... but shouldn't you wait for the process to complete before exiting? Something like: pid = subprocess.Popen(...) pid.wait() Otherwise, it'll exit before the background process is done. -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system and subprocess odd behavior

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 20:56, py_genetic wrote: > Oscar, seems you may be correct. I need to run this program as a superuser. > However, after some more tests with simple commands... I seem to be working > correctly from any permission level in python Except for the output write > command f

Re: os.system and subprocess odd behavior

2012-12-17 Thread py_genetic
Oscar, seems you may be correct. I need to run this program as a superuser. However, after some more tests with simple commands... I seem to be working correctly from any permission level in python Except for the output write command from the database to a file. Which runs fine if I past

Re: os.system and subprocess odd behavior

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 16:39, py_genetic wrote: > Thanks for verifying this for me Steven. I'm glad you are seeing it work. > It's really the strangest thing. > > The issue seems to be with the " > outfile.txt" portion of the command. > > The actual command is running a query on a verticalDB and d

Re: os.system and subprocess odd behavior

2012-12-17 Thread py_genetic
Thanks for verifying this for me Steven. I'm glad you are seeing it work. It's really the strangest thing. The issue seems to be with the " > outfile.txt" portion of the command. The actual command is running a query on a verticalDB and dumping the result. The EXACT command run from the comm

Re: os.system and subprocess odd behavior

2012-12-17 Thread py_genetic
Thanks! I am using .txt extensions. Sorry for being a little vague. -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system and subprocess odd behavior

2012-12-14 Thread Dieter Maurer
py_genetic writes: > Example of the issue for arguments sake: > > Platform Ubuntu server 12.04LTS, python 2.7 > > Say file1.txt has "hello world" in it. ^ Here, you speak of "file1.txt" (note the extension ".txt") > subprocess.Popen("cat < file1 > file2", shell = True) > subprocess

Re: os.system and subprocess odd behavior

2012-12-14 Thread Steven D'Aprano
On Fri, 14 Dec 2012 10:13:38 -0800, py_genetic wrote: > Example of the issue for arguments sake: > > Platform Ubuntu server 12.04LTS, python 2.7 > > Say file1.txt has "hello world" in it. > > subprocess.Popen("cat < file1 > file2", shell = True) > subprocess.call("cat < file1 > file2", shell =

os.system and subprocess odd behavior

2012-12-14 Thread py_genetic
Example of the issue for arguments sake: Platform Ubuntu server 12.04LTS, python 2.7 Say file1.txt has "hello world" in it. subprocess.Popen("cat < file1 > file2", shell = True) subprocess.call("cat < file1 > file2", shell = True) os.system("cat < file1 > file2") I'm finding that file2 IS crea