From: Kneo Fang
Subject: SBCL's (run-program ... :output out) is not working on Windows
Date: 
Message-ID: <g9agv3$cta$1@news.cn99.com>
Hi everyone,

I'm using SBCL on Windows. The following code returns "hi" on Linux, but 
an empty string on Windows:

(with-output-to-string (out)
   (run-program "echo" '("hi") :input t :output out :search t))

What should I do to make it work on Windows?


Thanks,
Kneo Fang

From: Raymond Wiker
Subject: Re: SBCL's (run-program ... :output out) is not working on Windows
Date: 
Message-ID: <m2abev0w5b.fsf@RAWMBP.local>
Kneo Fang <·········@gmail.com> writes:

> Hi everyone,
>
> I'm using SBCL on Windows. The following code returns "hi" on Linux,
> but an empty string on Windows:
>
> (with-output-to-string (out)
>   (run-program "echo" '("hi") :input t :output out :search t))
>
> What should I do to make it work on Windows?

	Just guessing here, but I think that "echo" is a shell
built-in (if you can all "cmd" a shell...)

(run-program "cmd" '("/c" "echo" "hi") ...) might work.
From: Kneo Fang
Subject: Re: SBCL's (run-program ... :output out) is not working on Windows
Date: 
Message-ID: <g9d3lf$i69$1@news.cn99.com>
Raymond Wiker wrote:
> Kneo Fang <·········@gmail.com> writes:
> 
>> Hi everyone,
>>
>> I'm using SBCL on Windows. The following code returns "hi" on Linux,
>> but an empty string on Windows:
>>
>> (with-output-to-string (out)
>>   (run-program "echo" '("hi") :input t :output out :search t))
>>
>> What should I do to make it work on Windows?
> 
> 	Just guessing here, but I think that "echo" is a shell
> built-in (if you can all "cmd" a shell...)
> 
> (run-program "cmd" '("/c" "echo" "hi") ...) might work.

Hi Raymond,

Thanks for you replay.

I forgot to mention that I had an echo program in my environment 
variable PATH.

If I write:
(process-output
  (run-program "echo" '("hi") :input t :output :stream :search t))

Then I can get "hi" from the returned stream.


Best wishes,
Kneo Fang
From: Richard M Kreuter
Subject: Re: SBCL's (run-program ... :output out) is not working on Windows
Date: 
Message-ID: <871w06hjas.fsf@progn.net>
Kneo Fang <·········@gmail.com> writes:

> Hi everyone,
>
> I'm using SBCL on Windows. The following code returns "hi" on Linux,
> but an empty string on Windows:
>
> (with-output-to-string (out)
>   (run-program "echo" '("hi") :input t :output out :search t))
>
> What should I do to make it work on Windows?

This is the sort of question that's best posed on the sbcl-help
mailing list, but the answer is that the modes of RUN-PROGRAM that
involve using a Lisp stream as input, output, or error for the
external program don't yet work on Windows.  Until that changes, as a
workaround, for most uses, you might have the external program write
its output to a file, and then read that file in from Lisp.

--
RmK
From: Kneo Fang
Subject: Re: SBCL's (run-program ... :output out) is not working on Windows
Date: 
Message-ID: <g9d3ur$4td$1@news.cn99.com>
Richard M Kreuter wrote:
> Kneo Fang <·········@gmail.com> writes:
> 
>> Hi everyone,
>>
>> I'm using SBCL on Windows. The following code returns "hi" on Linux,
>> but an empty string on Windows:
>>
>> (with-output-to-string (out)
>>   (run-program "echo" '("hi") :input t :output out :search t))
>>
>> What should I do to make it work on Windows?
> 
> This is the sort of question that's best posed on the sbcl-help
> mailing list, but the answer is that the modes of RUN-PROGRAM that
> involve using a Lisp stream as input, output, or error for the
> external program don't yet work on Windows.  Until that changes, as a
> workaround, for most uses, you might have the external program write
> its output to a file, and then read that file in from Lisp.
> 

Thank you, Richard.

I tried :OUTPUT :STREAM, and it could return a stream object, from which 
I could read process output as I expected:

(process-output
  (run-program "echo" '("hi") :input t :output :stream :search t))

So I think the :OUTPUT out should be supported too.

Anyway, I have a workaround. Next time I will send my question to 
sbcl-help mailing list as you suggested.

Thanks,
Kneo Fang