Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-01-2004, 02:36 PM   #1
LQ Newbie
Registered: Dec 2004
Distribution: Debian, SuSE
Posts: 6

Rep: Reputation: 0
Arrow process substitution

Bash supports process substitution. This allows you to open a file descriptor for either standard in or standard out for a process. For example, I can open fd 9 to read the output of the ls command:
exec 9< <(ls)
Now I can
read -u 9
or redirect that fd into another process:
cat <&9
I can do that with stdin as well
exec 9> >(cat)
My question is... is it possible to open two file descriptors for the process that represent stdin and stdout, so you can write to one, and get the result from the other? Right now, I'm accomplishing the same effect using named pipes for one end and a file descriptor for the other, but then you have to worry about cleaning up your temporary fifos and it's much less secure. Any suggestions?
Old 12-02-2004, 04:34 PM   #2
LQ Newbie
Registered: Dec 2004
Distribution: Debian, SuSE
Posts: 6

Original Poster
Rep: Reputation: 0
To Answer my own post... It looks like this is not possible in bash. It is however possible in zsh (and some others) with the coproc builtin. So, you can....

# start zsh
bash $ zsh
# start coproccess
zsh $ coproc somecommand_or_pipeline
# redirect its stdin and stdout to numbered fds
zsh $ exec 6>&p 7<&p
# run bash again, and the fd's get inherited
zsh $ bash
bash $

Last edited by jk3us; 12-09-2004 at 04:25 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Process Substitution joshholt Programming 4 10-11-2005 03:15 AM
Vim Substitution (specialized) infidel Linux - Software 7 05-07-2005 04:28 PM
sed substitution conditional frostillicus Linux - Newbie 3 04-17-2005 12:36 AM
sed substitution error BlkPoohba Programming 1 08-25-2004 02:00 PM
Is there any substitution to Ghost? Swift&Smart Linux - Software 12 06-22-2004 05:31 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:35 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration