Closed Thread
Results 1 to 2 of 2

Thread: Trying to mimic a remote shell

  1. #1
    codeLoad is offline Newbie
    Join Date
    Feb 2009
    Posts
    16
    Rep Power
    0

    Trying to mimic a remote shell

    I am writing a simple secure shell type program (its not encrypted though) for windows and am having an issue feeding input to a process. I used the following code:

    Code:
    from subprocess import Popen, PIPE
    import sys
    
    p = Popen('netsh',shell=False,stdout=PIPE, stderr=PIPE, stdin=PIPE)
    
    while(True):
        m = raw_input(">")
        out = None
        try:
            p.stdin.write(m)
            out = p.stdout.read()
        except:
            print sys.exc_info()
        print p.returncode
        print out
    The problem is, the call to read() does not return. Anyone know a way to do this?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    deskchecked's Avatar
    deskchecked is offline Newbie
    Join Date
    Apr 2010
    Location
    Melbourne, Australia
    Posts
    29
    Rep Power
    0

    Re: Trying to mimic a remote shell

    Unfortunately, read() will block until data is available. The python docs may also have an option for performing non-blocking reads, but I don't know whether such support exists outside of sockets. If that's not an option, you'll probably need to use a separate thread for reads.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Remote WMI Info
    By Parabola in forum C# Programming
    Replies: 0
    Last Post: 12-16-2010, 12:04 PM
  2. Shell Server Backup Script to remote location
    By DEViANT in forum Bash / Shell Scripting
    Replies: 0
    Last Post: 10-16-2010, 01:53 AM
  3. remote console
    By h4x in forum General Programming
    Replies: 7
    Last Post: 10-11-2009, 12:49 PM
  4. Remote capabilities of VB.NET?
    By Dyroxide in forum Visual Basic Programming
    Replies: 2
    Last Post: 02-24-2009, 07:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts