Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#45 connecting a string port to a process

closed-works-for-me
Olin Shivers
run-time (53)
5
2001-05-29
2001-05-29
No

From: Allyn Dimock <dimock@deas.harvard.edu>
Cc: "Brian D. Carlstrom" <bdc@ai.mit.edu>, "Olin
Shivers" <shivers@ai.mit.edu>,
"Allyn Dimock" <dimock@deas.harvard.edu>
Subject: in scsh: can you connect a string port to a
process?
Date: 13 Jan 2000 17:16:08 -0500

The following message is a courtesy copy of an article
that has been posted as well.

In scsh: can you connect a string port to a process?

I am looking to feed a computed string (a C-shell
script) to a
process, and was trying to see if I could get away
without first
writing it to a file.

the code

(define main
(lambda ()
(let* (...
(input ...)
(input-as-port (make-string-input-port
input)))
(run (/bin/csh)
(= 0 ,input-as-port)
(= 2 1)))))

fails with
Error: Not a file descriptor or fdport.
#{Extensible-input-port}

Writing out to a file and (run (/bin/csh)
(< ,tmpfile)) works [of course].

Is there a way in scsh to feed text directly to the
stdin of another
process?

-- Allyn

Discussion

  • Logged In: YES
    user_id=27364

    A slightly simpler example. Obviously there is no real file
    descriptor underneath. One could use a unix domain socket
    on unix (but not win32 at the moment) or a plain socket or
    perhaps a ptty or something odd.

    Do we want to do this automatically?

    Scsh 0.5.3
    > (run ("cat") (= 0 ,(make-string-input-port "")))

    Error: Not a file descriptor or fdport.
    #{Extensible-input-port}
    256
    >

     
  • Olin Shivers
    Olin Shivers
    2001-05-29

    • status: open --> closed-works-for-me
     
  • Olin Shivers
    Olin Shivers
    2001-05-29

    Logged In: YES
    user_id=101304

    This is an important feature, and scsh supports it. Use the
    << redir.
    In your example,
    (run (cat) (<< ,input))

    Converting it to a port -- you're working too hard.

    (Scsh implements this by forking off a subprocess that
    writes the bits
    down a pipe.)
    -Olin