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
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,321 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  Why is copying and pasting a block now broken? WagmoreBarkless 2 1,384 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 1,224 May-04-2022, 11:40 PM
Last Post: Larz60+
  Duplex Named Pipe with Python Server and C# Clients raybowman 1 2,379 Dec-03-2020, 09:58 PM
Last Post: Gribouillis
  Python broken if moved to a different folder ecastrotns 3 2,421 Oct-26-2020, 10:53 PM
Last Post: ecastrotns
  2 or more processes on the write end of the same pipe Skaperen 4 3,844 Sep-27-2020, 06:41 PM
Last Post: Skaperen
  STT: recognition connection failed: [Errno 32] Broken pipe GrahamBerends 0 5,038 Jul-18-2020, 11:00 PM
Last Post: GrahamBerends
  multiprocessing Pipe.poll very slow seandepagnier 0 2,348 Mar-09-2020, 03:10 AM
Last Post: seandepagnier
  Python DateTime is broken 10OctNotOct10a1 8 4,713 Jan-03-2020, 07:54 AM
Last Post: snippsat
  Broken interpreter? fcktheworld587 1 2,250 Dec-26-2019, 08:29 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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