Python Forum
BrokenPipeError: [Errno 32] Broken pipe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BrokenPipeError: [Errno 32] Broken pipe
#1
So I've been working on this remote command script for sometime now but my work has been hindered by this pesky error:
BrokenPipeError: [Errno 32] Broken pipe
I'm a new Coder so this is a pretty new experience for me.
client:
#!/usr/bin/env python3
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Host = input('Remote Host:')
port = 4444
s.connect((Host, port))
while True:
	cmd = input('Host-->Rhost:')
	cmd2 = cmd.encode('utf-8')
	s.sendall(cmd2)
	data = s.recv(1024)
	print(data)
server:
import socket
import platform
import subprocess
import time
s  = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Host = platform.node()
port = 4444
s.bind((Host, port))
s.listen(1)
conn, addr = s.accept()
while True:
	data = conn.recv(1024)
	data2 = data.decode('utf-8')
	z = subprocess.Popen(data2, shell=True, stdout=subprocess.PIPE,   stderr=subprocess.PIPE)
	
	time.sleep(10)
	z2 = z.stdout.read() + z.stderr.read()
	s.sendall(z2)
Reply
#2
It would be really helpful if I could get some help with this.
Reply
#3
please show complete unaltered error traceback, it contains very useful information that can be used to find the issue.
Gribouillis likes this post
Reply
#4
(May-04-2021, 09:56 AM)Larz60+ Wrote: please show complete unaltered error traceback, it contains very useful information that can be used to find the issue.

Sure no problem.

Traceback (most recent call last):
  File "/home/kali/Desktop/server.py", line 18, in <module>
    s.sendall(z2)
BrokenPipeError: [Errno 32] Broken pipe
Reply
#5
(May-04-2021, 09:56 AM)Larz60+ Wrote: please show complete unaltered error traceback, it contains very useful information that can be used to find the issue.

I Can tell its something with line 18 and above, but I'm not sure How I messed up the piping.
Reply
#6
conn.sendall(z2) looks much better to me than s.sendall(z2)
throwaway34 likes this post
Reply
#7
(May-05-2021, 09:23 AM)Gribouillis Wrote: conn.sendall(z2) looks much better to me than s.sendall(z2)

This seemed to fix it thank you sooo Much!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pipe traceback to a C program Alexandros 0 712 Oct-22-2024, 12:32 PM
Last Post: Alexandros
  Why is copying and pasting a block now broken? WagmoreBarkless 2 2,177 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 1,816 May-04-2022, 11:40 PM
Last Post: Larz60+
  Python broken if moved to a different folder ecastrotns 3 3,796 Oct-26-2020, 10:53 PM
Last Post: ecastrotns
  2 or more processes on the write end of the same pipe Skaperen 4 5,906 Sep-27-2020, 06:41 PM
Last Post: Skaperen
  STT: recognition connection failed: [Errno 32] Broken pipe GrahamBerends 0 6,685 Jul-18-2020, 11:00 PM
Last Post: GrahamBerends
  multiprocessing Pipe.poll very slow seandepagnier 0 3,123 Mar-09-2020, 03:10 AM
Last Post: seandepagnier
  Python DateTime is broken 10OctNotOct10a1 8 8,078 Jan-03-2020, 07:54 AM
Last Post: snippsat
  Broken interpreter? fcktheworld587 1 3,125 Dec-26-2019, 08:29 PM
Last Post: snippsat
  getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe" Birju_Barot 0 3,591 Jul-23-2019, 11:50 AM
Last Post: Birju_Barot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020