From owner-freebsd-questions@freebsd.org Tue Apr 20 16:24:14 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E081C5DE69C for ; Tue, 20 Apr 2021 16:24:14 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from mailout.qeng-ho.org (mailout.qeng-ho.org [217.155.128.244]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FPpsp037Rz3CS6 for ; Tue, 20 Apr 2021 16:24:13 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from arthur.home.qeng-ho.org (unknown [IPv6:2a02:8010:64c9:1::2]) by mailout.qeng-ho.org (Postfix) with ESMTP id 181C3B1490; Tue, 20 Apr 2021 17:23:58 +0100 (BST) Subject: Re: socat / ghostscript questions To: Paul Procacci , byrnejb@harte-lyne.ca Cc: FreeBSD Questions References: From: Arthur Chance Message-ID: <2ea846ea-65ad-e9ea-9400-2708271039f4@qeng-ho.org> Date: Tue, 20 Apr 2021 17:23:58 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FPpsp037Rz3CS6 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@qeng-ho.org designates 217.155.128.244 as permitted sender) smtp.mailfrom=freebsd@qeng-ho.org X-Spamd-Result: default: False [-3.29 / 15.00]; RCVD_TLS_LAST(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[217.155.128.244:from]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:217.155.128.240/29]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[qeng-ho.org]; ARC_NA(0.00)[]; SPAMHAUS_ZRD(0.00)[217.155.128.244:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.988]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com,harte-lyne.ca]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13037, ipnet:217.155.0.0/16, country:GB]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2021 16:24:14 -0000 On 20/04/2021 17:17, Paul Procacci wrote: > The hang is most likely because an EOF doesn't get trasmitted over the wire. > Adding a timeout I believe should fix the problem. > > nc -w 1 [addr] [port] < filename.txt Better to use the -N flag. -N shutdown(2) the network socket after EOF on the input. Some servers require this to finish their work. > On Tue, Apr 20, 2021 at 11:51 AM James B. Byrne via freebsd-questions < > freebsd-questions@freebsd.org> wrote: > >> I am trying to produce pdf files using socat and ghostscript. I have this >> command for socat: >> >> socat TCP4-LISTEN:9100,bind=192.168.216.41,fork,reuseaddr SYSTEM:'gs >> -dQUIET >> -dNOPROMPT -dBATCH -sDEVICE=pdfwrite -sOutputFile=/tmp/\"$(date >> -Iseconds)\".pdf -' >> >> >> Which I try to send a text file to using cat and nc: >> >> cat sshpipe3.txt | nc 192.168.216.41 9100 >> >> >> What happens is that the cat/nc pipe hangs. This is probably an artifact >> of >> how nc works but I need to check that is so. When I terminate nc with >> -c >> the socat gs instance reports an error: >> >> GPL Ghostscript 9.52: Unrecoverable error, exit code 1 >> 2021/04/20 11:32:51 socat[67296] E write(6, 0x800adf000, 128): Broken pipe >> >> This produces an empty file named like /tmp/2021-04-20T11:13:20-04:00.pdf. >> >> I am no doubt missing the obvious here so I have a few naive questions: >> >> 1. Is it possible to terminate the sending process without causing GS to >> issue >> an error? >> >> 2. Would printing from another host to that socat instance result in the >> same >> broken pipe error? >> >> 3. Why are the files that gs creates empty? >> >> 4. How do I send a text file to the socat instance so that it is converted >> to a >> pdf document? >> > -- Lebowskisort, aka dudesort, an O(1) sorting algorithm: "Man, the array is cool as it is. Let's go bowling."