LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-11-2011, 08:40 AM   #1
protocol
LQ Newbie
 
Registered: May 2005
Posts: 17

Rep: Reputation: 0
Question Bash Script Variables Handling


Hello all.

I have the following script:

Code:
#!/bin/bash

a='MIME-Version: 1.0\n'
b="Subject: Message Title\n"
c="From: someone@thatdomain.net\n"
d="Content-Type: text/html; charset=utf-8\n"
e="Content-Disposition: inline\n"
f="<html>Hello\n"
g="</html>\n"

all=$a$b$c$d$e$f$g

echo $all > sendmail someone@somedomain.com
I obviously wish to send (pipe?) the concatenated result of my a,b,c,d,e,f,g variables as input to sendmail command. However, it does not work.

Also, i wish to read the contents of a simple text file and assign that content to yet another variable that will also be used in this context.

Any help will be greatly appreciated.

Panos
 
Old 08-11-2011, 10:33 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
The pipe symbol is |

> is a redirection operator; as used in your script it should have created a file called sendmail with what you wanted to send to the sendmail command.

$all contains linends so you need to double quote it or bash will turn the linends into single spaces.
 
1 members found this post helpful.
Old 08-11-2011, 11:32 AM   #3
protocol
LQ Newbie
 
Registered: May 2005
Posts: 17

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by catkin View Post
The pipe symbol is |
$all contains linends so you need to double quote it or bash will turn the linends into single spaces.
Actually, i had to

echo -e $all | ...

that solved this particular problem.

Thank you for helping out.

 
  


Reply

Tags
bash, bash scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 09:37 AM
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 07:09 AM
Handling null options in a bash script which ought to have a value dairo Linux - General 2 03-16-2009 01:27 PM
help with complex bash script-XML handling panoskan Programming 4 09-18-2008 08:19 PM
Bash Script and Loop error handling Kedelfor Programming 5 05-22-2005 03:22 PM


All times are GMT -5. The time now is 10:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration