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

  • Home
  • SEARCH
  • 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 930911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:24:56+00:00 2026-05-15T20:24:56+00:00

When I use IO::popen with a non-existent command, I get an error message printed

  • 0

When I use IO::popen with a non-existent command, I get an error message printed to the screen:

 irb> IO.popen "fakefake"
  #=> #<IO:0x187dec>
 irb> (irb):1: command not found: fakefake

Is there any way I can capture this error, so I can examine from within my script?

  • 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-15T20:24:56+00:00Added an answer on May 15, 2026 at 8:24 pm

    Yes: Upgrade to ruby 1.9. If you run that in 1.9, an Errno::ENOENT will be raised instead, and you will be able to rescue it.

    (Edit) Here is a hackish way of doing it in 1.8:

    error = IO.pipe
    $stderr.reopen error[1]
    pipe = IO.popen 'qwe' # <- not a real command
    $stderr.reopen IO.new(2)
    error[1].close
    
    if !select([error[0]], nil, nil, 0.1)
      # The command was found. Use `pipe' here.
      puts 'found'
    else
      # The command could not be found.
      puts 'not found'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use popen in a project, but I get: error: 'popen' was
I am trying to run a command from Python script(using Popen()) get the output
If I use PHP's popen command to execute a script, does is execute it
I am trying to use IO.popen in order to put (with .puts method) and
I'm trying to use subprocess.Popen to construct a sequence to grab the duration of
Python documentation to Popen states: Warning Use communicate() rather than .stdin.write, .stdout.read or .stderr.read
can I use Popen from python subprocess to close started process? For example, from
I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas
I am using popen to execute a command under linux, then 4 process wile
I am attempting to use Popen to automate a simple telnet session. In python

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.