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 7679735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:56:46+00:00 2026-05-31T17:56:46+00:00

I am puzzled, simple code fails to return error for PIPE2 open, but does

  • 0

I am puzzled, simple code fails to return error for PIPE2 open, but does it for similar PIPE3!
I read perl processes pipe openings differently if there are any meta characters, but I do not know how to write code with correct error check for invalid pipe. How can I check PIPE2 open failed? $? or $! did not pickup error either.
Thanks.

open(PIPE2,"|/bin/echod 'sometxt'")||die "Pipe2 cannot open\n";
print PIPE2 "echoed 2\n";
close PIPE2;

open(PIPE3,"|-","/bin/echod sometxt")||die "Pipe3 cannot open\n";
print PIPE3 "echoed 3\n";
close PIPE3;

From command prompt after execution:

sh: /bin/echod: No such file or directory   
Pipe3 cannot open

This is perl, v5.8.8 built for x86_64-linux-thread-multi

  • 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-05-31T17:56:47+00:00Added an answer on May 31, 2026 at 5:56 pm

    When you use the fancy "|-" style, you are not specifying a shell command to run, but rather a list of arguments to be passed to the execvp(2) syscall.

    open(PIPE2,"|/bin/echod 'sometxt'")      || die "Pipe2 cannot open: $!";
    print PIPE2 "echoed 2\n";
    close(PIPE2)                             || die "Pipe2 cannot close: $!";
    

    versus

    open(PIPE3,"|-","/bin/echod", "sometxt") || die "Pipe3 cannot open: $!";
    print PIPE3 "echoed 3\n";
    close(PIPE3)                             || die "Pipe3 cannot close: $!";
    

    The second form is used only when you don’t want the shell expanding wildcards, interpreting pipe and redirect symbols, etc. when you pass in variables of unknown content.

    The first form is for when you do want that to happen, or when you have constant strings or string of known content in the command. I virtually always use the first form, reserving the second form for tricky situations like

    open(GREPPER, "grep $expr @files |")
    

    because it’s a thankless and fairly impossible job trying to figure out the right quoting on $expr there.

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

Sidebar

Related Questions

Experiencing jquery in rails through .js.erb templates; but completely puzzled by a simple problem
Really puzzled on this, probably simple but it is the day after New Years.
I'm doing simple divisions in c#, and I am a bit puzzled by its
This one has me puzzled. It seemed like an easy task, but the solution
I'm puzzled with this test script: #!perl use strict; use warnings; use encoding 'utf8';
I have a problem with some simple code. The photo's, either picked or taken
I'm looking at some sample code and I'm puzzled over the lack of declaration
I'm trying to retrieve an Application.Resources element from code behind and I'm puzzled since
I'm trying to create a simple application that does a HTTP request/response on a
Ok, so I'm trying to make some simple code to display news articles from

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.