Unix command to send mail having subject from a variableWhy does my shell script choke on whitespace or other...
Bringing Power Supplies on Plane?
Is it really Security Misconfiguration to show a version number?
What would it take to get a message to another star?
Help, I cannot decide when to start the story
What evidence points to a long ō in the first syllable of nōscō's present-tense form?
How does the Moon's gravity affect Earth's oceans despite Earth's stronger gravitational pull?
Why does Japan use the same type of AC power outlet as the US?
Scam? Phone call from "Department of Social Security" asking me to call back
Why do my bicycle brakes get worse and feel more 'squishy" over time?
What's a good pattern to calculate a variable only when it is used the first time?
Adding things to bunches of things vs multiplication
When did Bilbo and Frodo learn that Gandalf was a Maia?
Output the list of musical notes
Why don't modern jet engines use forced exhaust mixing?
Can anybody tell me who this Pokemon is?
Is Thieves' Cant a language?
What allows us to use imaginary numbers?
How do I call a 6-digit Australian phone number with a US-based mobile phone?
Units of measurement, especially length, when body parts vary in size among races
Sum Square Difference, which way is more Pythonic?
Number in overlapping range
Did Pope Urban II issue the papal bull "terra nullius" in 1095?
What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?
Is there any official ruling on how characters go from 0th to 1st level in a class?
Unix command to send mail having subject from a variable
Why does my shell script choke on whitespace or other special characters?Security implications of forgetting to quote a variable in bash/POSIX shellsWhen is double-quoting necessary?How to display entire subject line in `mail`?Using mailx without storing a passwordHow to set mail subject using variable and ensure attachment is not included in email bodyUnix command 'mail', send mail to an .onion address mailUnix--Send attachment, subject and body of the mail using mailxSend raw message with mailx commandHow to get response from mail commandUnattended upgrades won’t use mailx when run by Systemdhow to send a mail with attachment using sendmail command in unix
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
We have created a UNIX program which is used to send mails. In that program we are fetching the mail subject and body based on user inputs (through Oracle Concurrent Program)
For example:
The complete user inputs of concurrent program are storing in $1
variable which is as below:
XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12"
FCP_USERID=5667
FCP_USERNAME="SRI"
FCP_PRINTER="noprint"
FCP_SAVE_OUT=Y
FCP_NUM_COPIES=1
"9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv"
"/tmp_mnt2/attachments"
"Sri.B@xx.com"
"This is the subject for the mail"
"PFA for the list of Invoices that are stuck in workflow."
Here, subject for mail is This is the subject for the mail
which we are storing in variable SUB
and body for mail is PFA for the list of Invoices that are stuck in workflow.
which we are storing in another variable FCP_BODY
.
Now, I wrote as below to send mail
echo "Hello,
${FCP_BODY}
Thanks,
Bommi
"| mailx -s $SUB
But, in the mail I received, the body is coming properly, but subject is coming just This
.
Can anyone please help me on how to fetch the complete subject to send mail?
mailx
add a comment |
We have created a UNIX program which is used to send mails. In that program we are fetching the mail subject and body based on user inputs (through Oracle Concurrent Program)
For example:
The complete user inputs of concurrent program are storing in $1
variable which is as below:
XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12"
FCP_USERID=5667
FCP_USERNAME="SRI"
FCP_PRINTER="noprint"
FCP_SAVE_OUT=Y
FCP_NUM_COPIES=1
"9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv"
"/tmp_mnt2/attachments"
"Sri.B@xx.com"
"This is the subject for the mail"
"PFA for the list of Invoices that are stuck in workflow."
Here, subject for mail is This is the subject for the mail
which we are storing in variable SUB
and body for mail is PFA for the list of Invoices that are stuck in workflow.
which we are storing in another variable FCP_BODY
.
Now, I wrote as below to send mail
echo "Hello,
${FCP_BODY}
Thanks,
Bommi
"| mailx -s $SUB
But, in the mail I received, the body is coming properly, but subject is coming just This
.
Can anyone please help me on how to fetch the complete subject to send mail?
mailx
Since$SUB
variable contains multiple words you should quote the variable with| mailx -s "$SUB"
– user000001
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather thanmailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.
– cas
yesterday
add a comment |
We have created a UNIX program which is used to send mails. In that program we are fetching the mail subject and body based on user inputs (through Oracle Concurrent Program)
For example:
The complete user inputs of concurrent program are storing in $1
variable which is as below:
XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12"
FCP_USERID=5667
FCP_USERNAME="SRI"
FCP_PRINTER="noprint"
FCP_SAVE_OUT=Y
FCP_NUM_COPIES=1
"9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv"
"/tmp_mnt2/attachments"
"Sri.B@xx.com"
"This is the subject for the mail"
"PFA for the list of Invoices that are stuck in workflow."
Here, subject for mail is This is the subject for the mail
which we are storing in variable SUB
and body for mail is PFA for the list of Invoices that are stuck in workflow.
which we are storing in another variable FCP_BODY
.
Now, I wrote as below to send mail
echo "Hello,
${FCP_BODY}
Thanks,
Bommi
"| mailx -s $SUB
But, in the mail I received, the body is coming properly, but subject is coming just This
.
Can anyone please help me on how to fetch the complete subject to send mail?
mailx
We have created a UNIX program which is used to send mails. In that program we are fetching the mail subject and body based on user inputs (through Oracle Concurrent Program)
For example:
The complete user inputs of concurrent program are storing in $1
variable which is as below:
XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12"
FCP_USERID=5667
FCP_USERNAME="SRI"
FCP_PRINTER="noprint"
FCP_SAVE_OUT=Y
FCP_NUM_COPIES=1
"9614556_SUP12_XX_Workflow_Stuck_AP_Invoices.csv"
"/tmp_mnt2/attachments"
"Sri.B@xx.com"
"This is the subject for the mail"
"PFA for the list of Invoices that are stuck in workflow."
Here, subject for mail is This is the subject for the mail
which we are storing in variable SUB
and body for mail is PFA for the list of Invoices that are stuck in workflow.
which we are storing in another variable FCP_BODY
.
Now, I wrote as below to send mail
echo "Hello,
${FCP_BODY}
Thanks,
Bommi
"| mailx -s $SUB
But, in the mail I received, the body is coming properly, but subject is coming just This
.
Can anyone please help me on how to fetch the complete subject to send mail?
mailx
mailx
edited yesterday
dr01
17.4k11 gold badges56 silver badges78 bronze badges
17.4k11 gold badges56 silver badges78 bronze badges
asked yesterday
BommiBommi
31 silver badge2 bronze badges
31 silver badge2 bronze badges
Since$SUB
variable contains multiple words you should quote the variable with| mailx -s "$SUB"
– user000001
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather thanmailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.
– cas
yesterday
add a comment |
Since$SUB
variable contains multiple words you should quote the variable with| mailx -s "$SUB"
– user000001
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather thanmailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.
– cas
yesterday
Since
$SUB
variable contains multiple words you should quote the variable with | mailx -s "$SUB"
– user000001
yesterday
Since
$SUB
variable contains multiple words you should quote the variable with | mailx -s "$SUB"
– user000001
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather than
mailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.– cas
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather than
mailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.– cas
yesterday
add a comment |
1 Answer
1
active
oldest
votes
You need to quote the variable $SUB
:
... mailx -s "$SUB"
Explanation: A variable containing spaces is going to be subject to word splitting. That is, if you have the command
mailx -s $SUB
and the variable $SUB
contains the string "This is the subject for the mail"
the previous command gets expanded as
mailx -s This is the subject for the mail
i.e. the -s
flag (Subject) gets only the argument This
, and the rest of the words are passed as other arguments, and (in most cases) handled like garbage.
Instead,
mailx -s "$SUB"
gets expanded as
mailx -s "This is the subject for the mail"
which is what you wanted.
Related questions and answers:
- When is double-quoting necessary?
- Security implications of forgetting to quote a variable in bash/POSIX shells
- Why does my shell script choke on whitespace or other special characters?
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535544%2funix-command-to-send-mail-having-subject-from-a-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to quote the variable $SUB
:
... mailx -s "$SUB"
Explanation: A variable containing spaces is going to be subject to word splitting. That is, if you have the command
mailx -s $SUB
and the variable $SUB
contains the string "This is the subject for the mail"
the previous command gets expanded as
mailx -s This is the subject for the mail
i.e. the -s
flag (Subject) gets only the argument This
, and the rest of the words are passed as other arguments, and (in most cases) handled like garbage.
Instead,
mailx -s "$SUB"
gets expanded as
mailx -s "This is the subject for the mail"
which is what you wanted.
Related questions and answers:
- When is double-quoting necessary?
- Security implications of forgetting to quote a variable in bash/POSIX shells
- Why does my shell script choke on whitespace or other special characters?
add a comment |
You need to quote the variable $SUB
:
... mailx -s "$SUB"
Explanation: A variable containing spaces is going to be subject to word splitting. That is, if you have the command
mailx -s $SUB
and the variable $SUB
contains the string "This is the subject for the mail"
the previous command gets expanded as
mailx -s This is the subject for the mail
i.e. the -s
flag (Subject) gets only the argument This
, and the rest of the words are passed as other arguments, and (in most cases) handled like garbage.
Instead,
mailx -s "$SUB"
gets expanded as
mailx -s "This is the subject for the mail"
which is what you wanted.
Related questions and answers:
- When is double-quoting necessary?
- Security implications of forgetting to quote a variable in bash/POSIX shells
- Why does my shell script choke on whitespace or other special characters?
add a comment |
You need to quote the variable $SUB
:
... mailx -s "$SUB"
Explanation: A variable containing spaces is going to be subject to word splitting. That is, if you have the command
mailx -s $SUB
and the variable $SUB
contains the string "This is the subject for the mail"
the previous command gets expanded as
mailx -s This is the subject for the mail
i.e. the -s
flag (Subject) gets only the argument This
, and the rest of the words are passed as other arguments, and (in most cases) handled like garbage.
Instead,
mailx -s "$SUB"
gets expanded as
mailx -s "This is the subject for the mail"
which is what you wanted.
Related questions and answers:
- When is double-quoting necessary?
- Security implications of forgetting to quote a variable in bash/POSIX shells
- Why does my shell script choke on whitespace or other special characters?
You need to quote the variable $SUB
:
... mailx -s "$SUB"
Explanation: A variable containing spaces is going to be subject to word splitting. That is, if you have the command
mailx -s $SUB
and the variable $SUB
contains the string "This is the subject for the mail"
the previous command gets expanded as
mailx -s This is the subject for the mail
i.e. the -s
flag (Subject) gets only the argument This
, and the rest of the words are passed as other arguments, and (in most cases) handled like garbage.
Instead,
mailx -s "$SUB"
gets expanded as
mailx -s "This is the subject for the mail"
which is what you wanted.
Related questions and answers:
- When is double-quoting necessary?
- Security implications of forgetting to quote a variable in bash/POSIX shells
- Why does my shell script choke on whitespace or other special characters?
edited 23 hours ago
answered yesterday
dr01dr01
17.4k11 gold badges56 silver badges78 bronze badges
17.4k11 gold badges56 silver badges78 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535544%2funix-command-to-send-mail-having-subject-from-a-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Since
$SUB
variable contains multiple words you should quote the variable with| mailx -s "$SUB"
– user000001
yesterday
Possible duplicate of Why does my shell script choke on whitespace or other special characters?
– ilkkachu
yesterday
also, if you are sending attachments in the message (e.g. a .CSV file), you probably want to use a tool that knows how to do mime attachments correctly, rather than
mailx
. e.g. mime-construct - this is available packaged for debian, and probably other distros too.– cas
yesterday