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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:27:11+00:00 2026-05-24T08:27:11+00:00

Is there a way to tell curl to output errors to stderr, and everything

  • 0

Is there a way to tell curl to output errors to stderr, and everything else to stdout?

The reason is that I am using curl from the command line (actually a cronjob) to upload a file to an FTP site every evening. Unfortunately because curl outputs status information on stderr, I receive an e-mail about an error when nothing actually went wrong. (I’m redirecting stdout to a log file, but leaving stderr unchanged so that cron will e-mail it to me if there is any output.)

There are options to make curl silent, or output everything to stdout, however both these alternatives prevent errors from appearing on stderr – meaning I won’t get an e-mail when there is actually an error I want to know about.

So is there a way to make curl only output errors on stderr, but leave normal output intact on stdout?

  • 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-24T08:27:12+00:00Added an answer on May 24, 2026 at 8:27 am

    After some more experimentation I have come up with the following workaround, but I’m still open to better alternatives.

    It works by temporarily storing all output (stdout and stderr) in a temporary file, and then sending the contents of that file to stderr or stdout depending on curl’s exit code. If curl failed the entire output will go to stderr (and be e-mailed to me thanks to cron), but if curl succeeded the output will go to stdout instead (which is redirected to a log file in the cron command, resulting in no e-mail.)

    # Get a temporary filename
    CURL_LOG=`tempfile`
    
    (
      # Run curl, and stick all output in the temp file
      /usr/bin/curl --verbose ... > "$CURL_LOG" 2>&1
    ) || (
      # If curl exited with a non-zero error code, send its output to stderr so that
      # cron will e-mail it.
      cat "$CURL_LOG" > /dev/stderr
      rm "$CURL_LOG"
      exit 1
    )
    
    # Otherwise curl completed successfully, so send the output to stdout (which
    # is redirected to a log file in crontab)
    cat "$CURL_LOG"
    rm "$CURL_LOG"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to tell the php complier that I want a specific
Is there a way to tell how to get a file size that is
Is there a way to tell Tomcat 7 the path to the JVM that
Is there a way to tell Spring to load classes from a given URL
is there any way to tell doctrine automaticaly create schema tables without using this
I've noticed that curl can tell whether or not I'm redirecting its output (in
Is there a way to tell MS SQL that a query is not too
Is there way to tell IntelliJ IDEA which output folder to use for GWT
Is there a way to tell Mercurial that a specified ascii file should be
Is there any way to tell GCC to not initialize a particular global array

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.