LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-03-2014, 12:06 PM   #1
kannan radhakrishnan
LQ Newbie
 
Registered: Dec 2014
Posts: 2

Rep: Reputation: Disabled
linux commands


Hi all,
I m new to shell scripts and I came across few commands which I didn't understand. Please can you explain to me about this.

cat - filename <<Here | sendemail -iot
From: xyz
To: xyz
Subject: xxxxx
Content-type: text/html; charset-us-ascii
Content-transfer-encoding: 7bit
mime-version: 1.0
Here

. I can understand tat send email is usig for sending the contents in the file. The file contains html tags.in the end an proper email is sent with all the details in tje file.
My doubt is why is it not working with a normail mail command. Also what is 'here' in the content above. And also y there is a - after cat. Appreciate your help.
 
Old 12-03-2014, 10:22 PM   #2
ttk
Member
 
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware
Posts: 461
Blog Entries: 17

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
cat will iterate through its arguments and write their contents to stdout.

In your example, its arguments were "-" and "filename".

cat understands "-" to represent its own stdin. "cat -" will read content from its stdin and write it to its stdout until there is no more data available from stdin.

So in your example, cat first reads content from stdin, and writes it to stdout, then reads content from "filename", and writes it to stdout.

"<< Here" is a bashism for reading text from the following lines up to "Here" (alone on its own line) and writing it to the stdin of the command to its left (in this case the cat command).

Open the bash man page and skip to the "Here Documents" section to read more about this feature:

http://linux.die.net/man/1/bash

As for why sendemail vs mailx, I would assume it is used so the email's headers could be given to it via stdin, but I'm not sure.

http://manpages.ubuntu.com/manpages/...ndEmail.1.html
 
Old 12-04-2014, 03:37 AM   #3
kannan radhakrishnan
LQ Newbie
 
Registered: Dec 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks a bunch !!
That was a spot on reply that i expected !!
thanks again
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Low Level commands (embedded Linux, terminal commands) JonCombat Linux - Newbie 2 01-05-2013 03:34 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 07:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 07:53 AM


All times are GMT -5. The time now is 06:46 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration