hey guys n girls, im using python 3.1.2
i am currently creating a process to:
1) check a directory does not exist,
2) check for illegal char's from a list i have made,
3) pass it to a program,-program creates directory,
4) and passes a value back to python
5) and loop until told otherwise

i have got to the point where i have to pass the string / text to a program and this is where i have hit a brick wall?

what and how should i pass the text across (i would prefer to use something like "cmd")
i can get cmd to open a program from within my python script but cannot get it to pass any text or strings across to the program.

any help would be fantastic or any suggestions on what module or function to use

string=input('enter new directory name: ')

i need to pass the input from the user to a external program (a text based program) i haven't posted my whole code as it all works smoothly apart from me being a newbie and not being able to work this problem out
thanks again

Why you do not do everything in Python? What external program does except creating the directory?

the external program then sets conditions for the folder and puts databases in to it and creates log files?
i just need the command for typing a string or text in to a external program as i can get it to open the program but not to type anything?

the external program then sets conditions for the folder and puts databases in to it and creates log files?
i just need the command for typing a string or text in to a external program as i can get it to open the program but not to type anything?

You must tell us how the external program usually receives these strings: from command line options ? from an interactive session in a terminal ? from a GUI ?, from a socket ?

Edited 6 Years Ago by Gribouillis: n/a

well atm while i am editing this file i am using runasdate.exe from an interactive session in terminal i can get it to open runasdate via a batch file but it wont pass the text / string though 2 runasdate

well atm while i am editing this file i am using runasdate.exe from an interactive session in terminal i can get it to open runasdate via a batch file but it wont pass the text / string though 2 runasdate

Try to run it with this Command class http://www.daniweb.com/code/snippet257449.html

com = Command('RunAsDate.exe 14\02\2005 "c:\temp\myprogram.exe" param1 param2 "').run()
if com.failed:
    print com.error
    print com.output

(replace the command line by your command line). Otherwise, try to use subprocess.Popen directly.

Edited 6 Years Ago by Gribouillis: n/a

i have tried using pexpect but it is not compatible with python 3.1 without a good hours of correcting errors and at the current point in time i do not have the time to do that.

i have tried using pexpect but it is not compatible with python 3.1 without a good hours of correcting errors and at the current point in time i do not have the time to do that.

Did you obtain results with the subprocess module ?

This article has been dead for over six months. Start a new discussion instead.