CrAc
0
Moinsen 
Ich habe endlich wieder an meinem WartY gearbeitet.
Funzt auch eig. ganz gut.
Jetzt treten probleme in folgender form auf:
Das '>' ist ein Command-prompt dings
folglich meine eingaben
Zur selben zeit beim server app:
wie man sieht wird nur das erste command geparst...
hier der quellcode:
Client -do.py
Server a.py
Danke im vorraus, und sry für den riesigen Thread
/e: Quellcode vom Client beschnitten

Ich habe endlich wieder an meinem WartY gearbeitet.
Funzt auch eig. ganz gut.
Jetzt treten probleme in folgender form auf:
Code:
crac@crac-desktop:~/Dokumente$ python do.py
======================================
WartY Server-Client VS 0.2 - Welcome!
======================================
Enter Commands please! (hlp for help)
connect
IP-Adresse:
Port:
Got you on ('127.0.0.1', 37749)
> uptime
23:51:40 up 5:13, 3 users, load average: 0.98, 0.95, 0.97
> lsusb
23:51:40 up 5:13, 3 users, load average: 0.98, 0.95, 0.97
> lsusb
Das '>' ist ein Command-prompt dings

folglich meine eingaben
Zur selben zeit beim server app:
Code:
crac@crac-desktop:~/Dokumente$ python a.py
('running command:', 'uptime')
wie man sieht wird nur das erste command geparst...
hier der quellcode:
Client -do.py
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Made by: CrAc / ZeeX
#Whats WartY?:
#WartY is made, to connect to a Server for remote administration.
#You have to verify and type a password...
#after that you're able to command the Server how you supposed to do
#-----------------------------
# finally: s.close()
#while True:
#print ("Connected to Host")
# s.recv(1024)
#print "[%s] %s" % (ip,antwort)
#-----------------------------
print "\n======================================\n WartY Server-Client VS 0.2 - Welcome!\n======================================\n"
import socket
import sys
import os
import subprocess
#connect to server
def connect():
port = 1111
ip = raw_input("IP-Adresse: ") or "127.0.0.1"
port_int = raw_input("Port: ")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, port))
except socket.error, (value,message):
print ("Unable to connect:\n" + message +"\nPlease Try again:\n")
connect()
try:
while True:
data = s.recv(1024)
print data
data = raw_input('> ')
if not data:
break
s.send(data)
finally:
s.close()
#command prompt on startup
def prompt():
while True:
inpt = raw_input("Enter Commands please! (hlp for help)\n")
if inpt == "hlp":
print ("commands:\n'hlp'.....help\n'makesrv'.....create new Server\n'exit'.....exit Warty\n'info'.....get information about WartY and its usage")
elif inpt == "makesrv":
makesrv()
elif inpt == "connect":
connect()
elif inpt == "info":
info()
elif inpt == "exit":
sys.exit()
else:
print "Wrong command - please verify if command is valid!"
if __name__ == "__main__":
prompt()
Server a.py
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import socket
import threading, thread
import os
import subprocess
import sys
import logging
PORT = 1111
PASS = 'passw'
logging.basicConfig (
filename = "WartY.log",
filemode = "a",
level = logging.DEBUG,
format = "%(asctime)s [%(levelname)-8s] %(module)s, %(funcName)s, %(lineno)s -|- %(message)s" )
logging.info("Session started")
closeMessage = ("Quit Warty...")
#run received commands
def exe(s,command):
process = subprocess.Popen(command, stdout=subprocess.PIPE)
process.wait()
data = process.stdout.read()
logging.info(data)
for line in data.split('\n'):
s.send(data)
#accept connections
def con():
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#make socket
try:
logging.info("listener bind on", PORT)#writing to logfile
listener.bind(('',PORT))#bin socket on port
except ValueError,e:
logging.error(e)#writing error to logfile
print e#print error
listener.listen(5)#socket is listening
while True:
s,addr = listener.accept()#accept incoming connections
s.send('Got you on %s' % str(addr))
logging.info("Connection from: %s" % str(addr))
command = s.recv(1024)
if command >= 0:
try:
print ("running command:", command)
logging.info("command:", command)
exe(s,command)
except OSError, e:
logging.error("Execution failed:", e)
print >>sys.stderr, "Execution failed:", e
logging.info("Socket closed")
s.close()
if __name__ == "__main__":
con()
Danke im vorraus, und sry für den riesigen Thread

/e: Quellcode vom Client beschnitten