Write something to another script - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Write something to another script (/thread-15595.html) |
Write something to another script - Lsxbash - Jan-23-2019 I just want to write something to another script like this example; When i write msfconsole to terminal is going to opening metasploit so i can do this with os.system() code too , but when metasploit is working can still run my codes? RE: Write something to another script - nilamo - Jan-23-2019 I assume if you use the subprocess module, and pipe output into the program's stdin, it'd work how you'd expect. But I'm not entirely sure what you're asking, so that's just a guess. Could you maybe write some pseudocode, showing what you'd want to happen? RE: Write something to another script - Lsxbash - Jan-23-2019 @nilamo of course man thanks for reply. Quote:x = input("exploit name.:")OUT: ============================ OUT: METASPLOIT OUT: logos etc. OUT: OUT: ============================ in: x (i want to write my own codes to here but i can't write because my codes end of after os.system("msfconsole") code) RE: Write something to another script - nilamo - Jan-23-2019 I don't think you want to be using os.system() . That's alright if what you're doing is running a command, and you don't really care what the output of that command is, or you don't want to interact with it.You do want to interact with it. So I think you should try the subprocess module: https://docs.python.org/3/library/subprocess.html Using stdin=PIPE and stdout=PIPE, you can communicate with the external process and send commands to it. You can also look into the pexpect module, though that isn't built into python. https://pexpect.readthedocs.io/en/stable/
|