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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:03:49+00:00 2026-06-10T20:03:49+00:00

I am trying to write a shell script, where emails get piped to (by

  • 0

I am trying to write a shell script, where emails get piped to (by an email forward in cpanel).

The shell script will then post the entire email to a url using curl.

The script looks like this:

curl -d "param=$1" http://localhost/stuff/

And the forward looks like this:

|/home/usr/script/curlthis.sh

This is only sort of working.

The email gets bounced back even though the curl posts to the url successfully. (it looks like only part of the email is getting posted, but I am not 100% sure)

I have been told the email bounces because I am not reading the stdin, but I am not sure why I need to do that and why I cannot use $1?

How can I read the entire contents of the pipe (then post it using curl), and will that stop the mail server from bouncing it back?

EDIT

Using the answer below here is what I came up with:

#!/bin/bash
m=$(cat -) 
escapedm="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$m")"
curl -silent -G -d "param=$escapedm" http://localhost/stuff/ 2>&1 >/dev/null

This part:

2>&1 >/dev/null

is shockingly important. If you don’t redirect the stdout/err to null then the email gets bounced back for whatever reason.

  • 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-10T20:03:51+00:00Added an answer on June 10, 2026 at 8:03 pm

    Your mail is being passed to the script as a stream on stdin, and not as a parameter ($1). Note that your forward script begins with a pipe, and that’s the mechanism passing the mail into your script.

    So you should be able to read this in your shell (bash?) using the read statement. See this SO answer for more details.

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

Sidebar

Related Questions

I'm trying to write a shell script that will make several targets into several
I'm trying to write a shell script that will execute a Hadoop MapReduce job
I am trying to write a shell script that will search for a regular
I'm trying to write a shell script that, when run, will set some environment
Background: I'm trying to write a shell script using php that will automatically checkout
I am trying to write a shell script to simulate the following problem: File
I am trying to write a shell script to delete all the sub directories
I'm trying to write a shell script to backup websites, I've got it to
I am trying to write a batch(for win) and a shell script for linux
I am trying to write a PHP script which executes shell functions for reporting.

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.