LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-07-2008, 01:25 AM   #1
Amey Joshi
LQ Newbie
 
Registered: Aug 2008
Posts: 7

Rep: Reputation: 0
Unhappy Not able to use nail command in scripting


Hi,
I am using "nail" command to send mail to users...Since i have to automate the mailing system..i have used this command in scripting..
Now my problem is that when i used this command, we have to press 'control +D '...but how can we achieve this automated scripting...
Following are the commands which i have tried out:

Code:
value=/opt/home/Test/status_reporting/status.html
nail -s test -a $value ameyjoshi@gmail.com
EOT
In the scripting...

Code:
#!/bin/sh0
value=/opt/home/Test/status_reporting/status.html
nail -s test -a $value ameyjoshi@gmail.com
`control +D`  ## :))))
echo Mailing complete...

Can anybody help regarding this..

Thanks in Advance!
 
Old 08-07-2008, 01:38 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
I think you are trying to mail the file status.html, right? If so, does this work:

value=/opt/home/Test/status_reporting/status.html
nail -s test -a $value ameyjoshi@gmail.com < $value
 
Old 08-07-2008, 01:49 AM   #3
Amey Joshi
LQ Newbie
 
Registered: Aug 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Smile

Thanks for your immediate reply!
Yes i am trying to mail status.html file.

The below command is working ...

Code:
value=/opt/home/Test/status_reporting/status.html
nail -s test -a $value ameyjoshi@gmail.com < $value
I have run this command seprately( not in the script)..
That means i have to add "< $value" in the script....

Thanks In Advance!
 
Old 08-07-2008, 01:50 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
That is correct.
 
Old 08-07-2008, 03:14 AM   #5
Amey Joshi
LQ Newbie
 
Registered: Aug 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you very much!
Now it is working fine!!
 
Old 08-07-2008, 12:54 PM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
You're attaching the file $value and putting it in the body of your mail. Doesn't either one of the 2 suffice?
ie
Code:
#as attachment only
echo "" | nail -s test -a $value ameyjoshi@gmail.com
#as mail body only
nail -s test ameyjoshi@gmail.com < $value
Just to explain what goes on here...
nail normally expects your keyboard input on its "stdin" (standard input). Using either a pipe "|" or the input
redirect "<", you can make the input come from a command or a file respectively, rather than the keyboard device.

The Ctrl-D (EOT) character on the keyboard is used to end the input, closing of the standard input that is read by nail.
The pipe and redirection will automatically close the standard input too, once they reach the end of the command's output (in case of pipe) or the end of the input file (in case of redirection).
 
  


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
Screen Command with Bash Scripting inthecrossfire Linux - Software 5 07-15-2008 02:18 PM
shell scripting/ bash/ a command with 3 parameters mayaabboud Programming 4 01-05-2008 11:22 AM
shell scripting/ the fc -l command ! mayaabboud Linux - Newbie 12 01-03-2008 07:38 PM
Bash command scripting otisthegbs Linux - General 6 07-06-2004 01:06 AM
scripting the unix command script lmcthbe Linux - General 7 05-28-2003 03:49 PM


All times are GMT -5. The time now is 07:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration