What's Up?

So, In my first python script, If a button is pressed, Then it defines a variable called var, With the content of "0" and then sends it over the net to another python script, And here's the problem.

When it comes to receiving the content of var.

var = client_socket.recv(512)

It stdout's this

sh: 0: not found

How come it does that?

See ya!

it looks like the remote is attempting to execute the "0" as a command. Check your code.

it looks like the remote is attempting to execute the "0" as a command. Check your code.

I've removed all lines to do with 'var' and just left ' var = client_socket.recv(512) ' And it still attempts to execute it.

Host.py

#!/usr/bin/python
import socket
from easygui import *
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("0.0.0.0", 5000))
server_socket.listen(5)

while 1:
        client_socket, address = server_socket.accept()
        button = buttonbox(msg='',choices=('button1','button2'),root=None)
        if ( button== 'button1'):
            data = enterbox(msg="Enter Text To Send")
        if ( button== 'button2'):
            var = "0"   
            client_socket.send(var)
            
        else:
            client_socket.close()

Guest.py

#!/usr/bin/python
import socket

ip = socket.gethostbyname('address.com')
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((ip, 5000))

while 1:
   data = client_socket.recv(512)
   print data
   var = client_socket.recv(512)
   print var

Still no joy however.

How about leaving the reserved name 'var' and use other name for the variable?

I'm I missing something here?

This line server_socket.bind(("0.0.0.0", 5000)) looks suspicious. Normally, the address of localhost is 127.0.0.1. You should try with this address.

How about leaving the reserved name 'var' and use other name for the variable?

I'm I missing something here?

var is not a reserved name in python.

This line server_socket.bind(("0.0.0.0", 5000)) looks suspicious. Normally, the address of localhost is 127.0.0.1. You should try with this address.

That was one of the first problems, For some reason or other it only works on 0.0.0.0, So anyone have any ideas on why it's doing this? I've tried changing the variable name but that doesn't work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.