Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:13:53+00:00 2026-06-17T01:13:53+00:00

I have a bash-script in which I want to communicate to the user on

  • 0

I have a bash-script in which I want to communicate to the user on standard out, but also send commands to a sub-process via a file descriptor — like this:

# ...
# ...

echo "Hello user, behold a cleared gnuplot window"

# pass the string "clear" to gnuplot via file descriptor 3
echo "clear" >&3  

So I thought I could “set this up” by first starting the subprocess like this:

#!/bin/bash

# Initiate(?) file descriptor 3, and let it direct to a newly 
# started gnuplot process:
exec >3 >( gnuplot )

But that yields an error:

/dev/fd/63: Permission denied

Is this to be expected?

I don’t understand what’s going on. (Am I doing something wrong? Can it be that my system has some special security settings, disallowing what I’m trying to do? (Running Ubuntu Linux 12.10.))

“Workaround” — the following seems to be equivalent with what I am trying to do, and works without errors:

#!/bin/bash

# open fd 3 and direct to where fd 1 directs to, i.e. std-out 
exec 3>&1 

# let fd 1 direct to a newly opened gnuplot process
exec 1> >( gnuplot ) 

# fd 1 now directs to the gnuplot process, and fd 3 directs to std-out.
# I would like it the other way around. So we'll just swap fd 1 and 3 
# (using an extra file descriptor, fd 4, as an intermediary)

exec 4>&1 # let fd 4 direct to wherever fd 1 directs to (the gnuplot process)
exec 1>&3 # let fd 1 direct to std-out 
exec 3>&4 # let fd 3 direct to the gnuplot process
exec 4>&- # close fd 4

Or, as one-liner:

#!/bin/bash
exec 3>&1 1> >( gnuplot ) 4>&1 1>&3 3>&4 4>&- 

Why is this working, but the initial version isn’t?

Any help much appreciated.

$ bash --version
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
[...]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:13:55+00:00Added an answer on June 17, 2026 at 1:13 am

    You have a typo; use exec 3> >( gnuplot ) instead of exec >3 >( gnuplot ).

    BTW, yes it’s expected. exec >3 >( gnuplot ) redirects stdout to a file named 3, then tries to execute >( gnuplot ) (which translates to /dev/fd/63) as a program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Makefile from which I want to call another external bash script
I basically have a bash script which executes 5 commands in a row. I
I have a bash script which need to execute some php scripts and to
Currently I have a bash script which runs the find command, like so: find
I have written a bash script which installs a number of packages, however for
I have small script in bash, which is generating graphs via gnuplot. Everything works
I have a shell script which I want to run without using the sh
I have a bash script that mounts and unmounts a device, which performing some
I have a bash script which is getting options (using getopts). Let say they
I have a bash script in which i define a certain path as such:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.