From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.user Subject: Re: execlp Date: Wed, 23 Nov 2011 22:38:09 +0800 Message-ID: References: <4ECBC87E.7090000@bioch.ox.ac.uk> <4ECCE42F.8030404@bioch.ox.ac.uk> <20111123140331.GB3674@ccellier.rd.securactive.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=90e6ba4fc2ec61378704b267deb2 X-Trace: dough.gmane.org 1322059109 11908 80.91.229.12 (23 Nov 2011 14:38:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2011 14:38:29 +0000 (UTC) To: rixed@happyleptic.org, guile-user@gnu.org, Paul Emsley Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Nov 23 15:38:25 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RTDxr-0002M5-F7 for guile-user@m.gmane.org; Wed, 23 Nov 2011 15:38:19 +0100 Original-Received: from localhost ([::1]:37555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTDxq-0007dn-ES for guile-user@m.gmane.org; Wed, 23 Nov 2011 09:38:18 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTDxj-0007dG-8U for guile-user@gnu.org; Wed, 23 Nov 2011 09:38:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTDxh-0005cu-Kn for guile-user@gnu.org; Wed, 23 Nov 2011 09:38:11 -0500 Original-Received: from mail-vx0-f169.google.com ([209.85.220.169]:39241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTDxh-0005cp-HH for guile-user@gnu.org; Wed, 23 Nov 2011 09:38:09 -0500 Original-Received: by vcbfk26 with SMTP id fk26so1716827vcb.0 for ; Wed, 23 Nov 2011 06:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SDTCSEoPax/cMDxRrw0iuvjxZh+rxDaAYwzx9smWWa8=; b=nL1HgNLWPUhIjBQrX4B+bco+qQ1a7c38U6DTJrmizFaaXHzGbk2R0W5zyLpn3Js8o8 squgeIwN1kaSV/tTFvWXBRoAxjk70aXsMKiIRG981NshqKEAkaUrXrC1h4hOlxxK0OvV V2W7r6tD217KQIKSdmsiqqvSpnGChEc9vXiLg= Original-Received: by 10.220.178.140 with SMTP id bm12mr1729452vcb.218.1322059089130; Wed, 23 Nov 2011 06:38:09 -0800 (PST) Original-Received: by 10.52.31.165 with HTTP; Wed, 23 Nov 2011 06:38:09 -0800 (PST) In-Reply-To: <20111123140331.GB3674@ccellier.rd.securactive.lan> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.220.169 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8984 Archived-At: --90e6ba4fc2ec61378704b267deb2 Content-Type: text/plain; charset=UTF-8 On Wed, Nov 23, 2011 at 10:03 PM, wrote: > -[ Wed, Nov 23, 2011 at 08:28:56PM +0800, Nala Ginrut ]---- > > I think there's no such a given function in Guile to do this. > > But you can make it in a easy way in Guile: > > (catch 'system-error > > (lambda () (execlp "asdfasdf")) > > (lambda (k . e) > > (format #t "oh no~%~"))) > > > > PS: Maybe you need #f instead of "format" according to your letter. ;-) > > It's my understanding that the OP does not want to actually run the > program but merely knows either the file is in the PATH or not. > > I guess some-function would be something like : > > (use-modules (srfi srfi-1)) ; for any > (define (in-path? f) > (let ((path (string-split (getenv "PATH") #\:)) > (make-absolute (lambda (path) (string-append path "/" > f)))) > (any file-exists? (map make-absolute path)))) > > > Well, I realized that Paul want this some-function to detect whether file can be executed. [quote] My question is then, *is* there a way to determine if a string is executable? (And if so, how? :-) .[/quote] I confess that I didn't quite understand this question. So I guess there're two alternatives: 1. He needs some-function to detect each file in a path an return the result or #f; 2. He needs some-function to handle the error if a certain string can not be executed. --90e6ba4fc2ec61378704b267deb2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Wed, Nov 23, 2011 at 10:03 PM, <rixed@happyleptic= .org> wrote:
-[ Wed, Nov 23, 2011 at 08:28:56PM +0800, Nala Ginrut ]----
> I think there's no such a given function in Guil= e to do this.
> But you can make it in a easy way in Guile:
> (catch 'system-error
> =C2=A0 =C2=A0 (lambda () (execlp "asdfasdf"))
> =C2=A0 =C2=A0 =C2=A0 (lambda (k . e)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(format #t "oh no~%~"))) >
> PS: Maybe you need #f instead of "format" according to your = letter. ;-)

It's my understanding that the OP does not want to actually run t= he
program but merely knows either the file is in the PATH or not.

I guess some-function would be something like :

(use-modules (srfi srfi-1)) ; for any
(define (in-path? f)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((path =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= string-split (getenv "PATH") #\:))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(make-absolu= te (lambda (path) (string-append path "/" f))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(any file-exists? (= map make-absolute path))))



Well, I realized that Paul want this s= ome-function to detect whether file can be executed.=C2=A0
[quot= e]=C2=A0My question is then, *is* there a way to determine = if a string is executable? (And if so, how? :-) .[/quote]
I= confess that I didn't quite understand this question.
So I guess there're two alternatives:
1. He= needs some-function to detect each file in a path an return the result or = #f;
2. He needs some-function to handle the error if a certain string c= an not be executed.
--90e6ba4fc2ec61378704b267deb2--