From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Questions about (open-input-output-pipe Date: Tue, 10 Nov 2020 14:27:34 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17499"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: luhux Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Nov 10 15:28:20 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcUdA-0004S2-2w for guile-user@m.gmane-mx.org; Tue, 10 Nov 2020 15:28:20 +0100 Original-Received: from localhost ([::1]:56926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcUd9-00058D-2N for guile-user@m.gmane-mx.org; Tue, 10 Nov 2020 09:28:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcUcf-00055w-SO for guile-user@gnu.org; Tue, 10 Nov 2020 09:27:49 -0500 Original-Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:33697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcUcd-0004hS-Vl for guile-user@gnu.org; Tue, 10 Nov 2020 09:27:49 -0500 Original-Received: by mail-ej1-x62f.google.com with SMTP id 7so17843643ejm.0 for ; Tue, 10 Nov 2020 06:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cUwOSv5wB8NYOl+MRB8/fiRCCd/hhgz5uleetQwlzVE=; b=fNHk94GPcQ1UVt3MSsAmVJCGfc+l72iVKkpW+C4aSAuZTF/2vTgt79o8Z/gT2ra7V2 crZm0YQPd1+nDb0faEgobNJRUrq2WxcXsSg6sFwiiHlXmecG4DqcBPdZYEC9yYUeIWv+ tGuZS9Tnw2SAakWjbRiV7Iub9W1hwpHNAkGqNecNIgHAsfmGACehs3MEfaSFsNCeTsn2 iy/ymKa+TMufYQIs2UAVnWvN45RCUIA+HwUGxegQ9ZIEdjKJblYLq/+vUOWWU5BfM7w8 Q5EXNq2CwgaS/ZIpZuDgSlXqoX1f+dDRr7JLD+BPc5GwetY41NI/romZBeYjujYCfJm+ 7FMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cUwOSv5wB8NYOl+MRB8/fiRCCd/hhgz5uleetQwlzVE=; b=KIQfP4wX64aMOqbbIZYoonH3Lv+A/86iLm1Am5bLflSUpv1jGNOiDc4AefxcVt6K87 fOZ8htoPYWRoV4XGukALdcih4q91/0mB0JfubbuJ1cVqY3X15jMJny6qPVeeaKetcumv jmIEtLCqZiNoINfO3ueWGNmSoJItuRpGP591Eu+OCyox+nCnm28fIdd8hLJ3EpHpg8dR +uKeyzteWiIbKRn8HK5knvx/15ffccay0dShlyF+CRtsEHN7BjP4cR6wk6l1o0xp1X8A V8prls68ts1tcEf2ogSUU9SLoUlYxwvI5oDZNHKGIoUf5L1SQIKdZf3y7EJW4jeUIlXD RaQg== X-Gm-Message-State: AOAM530ofW+Rm0VxnYJ+w64i2rMbHE9G/KJF2LqiF2SaG7PTYCvN/+3+ 82oAaB910AQAVY46yi9s9SPec8mmOWYGu6+2ue0= X-Google-Smtp-Source: ABdhPJwcRA5LZpH1WD/0ghloaZ/kqLigeF+qGtGc3AxOJYDjihIk7S9lOfS/r0AIQbNMBT0P95Taatl9JqWN3wMBExQ= X-Received: by 2002:a17:906:ccd3:: with SMTP id ot19mr21143774ejb.44.1605018465616; Tue, 10 Nov 2020 06:27:45 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=neiljerram@gmail.com; helo=mail-ej1-x62f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17015 Archived-At: I guess it's because "wg pubkey" has not yet seen EOF on its input, i.e. it doesn't know that the input is complete. If that's right, I'm afraid I don't know how to fix it. Presumably you need a call that closes half of the port, but still allows reading the "wg pubkey" output from it. Alternatively, it might be buffering, i.e. the private key hasn't yet reached "wg pubkey". In that case (force-output port) might help. Best wishes, Neil On Tue, 10 Nov 2020 at 08:51, luhux wrote: > Hello everyone > > I am a newbie to guile and I am learning to use guile to write scripts > > I want to implement this shell command: > > > wg pubkey < private > public > > > > This is a command to generate a key, > It inputs private key and EOF from stdin, then it outputs the public key > and exits. > > I implemented it using the following code in guile: > > > > (use-modules (ice-9 popen) > (ice-9 rdelim)) > > (define (wg-gen-private-key) > (let* ((port (open-input-pipe "wg genkey")) > (result (read-line port))) > (close-pipe port) > result)) > > (define (wg-gen-public-key private-key) > (let ((port (open-input-output-pipe "wg pubkey"))) > (display private-key port) > (let ((result (read-line port))) > (close-port port) > result))) > > > Then I executed the code to get the public key > > > > > scheme@(guile-user)> (wg-gen-public-key (wg-gen-private-key)) > > > > > but the code got stuck in this place: > > > > > (let ((result (read-line port))) > > > > > How should I do? > > There are too few Guile information on the Internet. Sorry for asking such > a basic question. > > luhux > >