I am having a slight problem in finding a correct way to access a variable of a function in another function.
I am making a remote operations kind-of tool and so I need the command received to be processed [like 'exit' or 'nircmdc.exe' or 'telnet' etc].
The code below is not complete but it is the core:
def regular():
global data
data=c.recv(1024)
data=data.decode()
cmd=subprocess.Popen(data,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,err=cmd.communicate()
c.sendall(output+err)
def data_process():
data=regular().data
quit='exit'
nircmd='nircmdc'
if quit in data:
do_something()
elif nircmd in data:
do_else()
Here c is client connected to a socket "s" and s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
the program gives a error nonetype has no attribute data...
Help me sort this out