Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Getting console output when there is no console

why not just make it a function that returns a value? that what you want right, one function to take output from another?

Code
def func()
      do
      return did
(Feb 17, 2015 06:46 AM)Rorikstead Wrote:  The title might be kind of confusing, I apologize for that.

So basically, I'm trying to get the output of a cmd command that's run through a python script.
#!
Code
#!/usr/bin/python
import sys

def func(x):
    for arg in sys.argv:
      print arg

func(sys.argv)
console
Code
mrfree@orphan:~/Desktop/Scripts % python consoleargs.py butt plug help
consoleargs.py
butt
plug
help
mrfree@orphan:~/Desktop/Scripts %

Im confused as to what your doing tho, if you want the output of a cmd to be stored I would do it in a function using sys instead of a file, unless your taking in databases thru the cmd then I would use a file(no I would use a database module like pySQL or something)
Thanks for clarifying. I see what the problem is now, let me know if you find a working solution plz. Thanks

Edit:

Maybe something like this, we can also set it up so you can view while its running etc...
Code
import subprocess

def cmd():
      cmd = raw_input("Please Input cmd: ")
      subprocess.call("%s > out.txt" % cmd, shell = True)
      with open("/usr/home/mrfree/Desktop/Scripts/out.txt","r") as log:
      print log.read()

if __name__ == "__main__":
      cmd()


If that didn't get it, let me know and I'll try to help you figure it out if you want


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Flash7475Jan 22, 2020 10:57 PM 0 117 Jan 22, 2020 10:57 PM
Last Post: Flash7475
[Python] by mr_pedowbearFeb 12, 2017 10:24 AM 10 169 Feb 12, 2017 10:24 AM
Last Post: mr_pedowbear
[Java] by KingAroan_tempAug 14, 2015 03:55 AM 3 154 Aug 14, 2015 03:55 AM
Last Post: WildeThing