Problem while displaying(cat) file content inside telnet loop .


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while displaying(cat) file content inside telnet loop .
# 1  
Old 12-01-2015
Problem while displaying(cat) file content inside telnet loop .

Hi Team,

Not getting the file output inside my email which i am sending from unix box. . Please refer the below code :

Code:
#!/bin/sh

  {
sleep 5
echo ehlo 10.56.185.13
sleep 3
echo mail from: oraairtel@CNDBMUREAPZP02.localdomain
sleep 3
echo rcpt to: saurabhtripathi@anniksystems.com
sleep 5
echo DATA
echo Subject: Alert !!! Back up Failed
echo ""
echo "Hello Team,"
sleep 1s
echo ""
sleep 1s
echo "Alert Back up failed . Please check !"
sleep 1s
echo ""
cat BHARTI_INDIA_EOD.log
sleep 1s
echo "Cheers"
echo ""
echo .
sleep 5
echo quit
} | telnet 10.56.131.8 25

output :

Code:
Hello Team,

Alert Back up failed . Please check !
Cheers.


Expected output -----------------------------

Code:
Hello Team,

Alert Back up failed . Please check !

(Here cat the output file)

Cheers.

I am using Red Hat Enterprise Linux Server release 6.6 .

Thanks

Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 12-01-2015 at 09:53 AM..
# 2  
Old 12-01-2015
With RH6 use mailx -a "filename" to attach a file.

Code:
echo "Fixed text I want to say
More text
More text" > msg.txt
cat errorfilename >>msg.txt
mailx -s 'Subject goes here' -a "msg.txt"   name@mycompany.com

Trying to d use the smtp protocol directly means you have to follow it scupulously - try the above approach first.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating new file inside a for loop

Hi, I have list of files present in a folder. I want to search for a particular keyword sequentially and create a file which will be later used by some other program. Input files: $ ls a.dsx b.dsx c.dsx Dataline_.txt Dataline.txt loop.sh $ cat *.dsx help tyiis global for i in... (4 Replies)
Discussion started by: mac4rfree
4 Replies

2. Shell Programming and Scripting

How to save sorted content of a inside the same file?

Hi All, When i use sort Test, here is the output: $ sort Test a b b c d e f g h i But the contents in the file remain unsorted, how to do that? ]$ cat Test g i (6 Replies)
Discussion started by: chandrakanth
6 Replies

3. Shell Programming and Scripting

Problem passing a search pattern to AWK inside a script loop

Learning, stumbling! My progress in shell scripting is slow. Now I have this doubt: I have the following file (users.txt): AU0909,on AU0309,off AU0209,on AU0109,off And this file (userson.txt) AU0909 AU0209 AU0109 AU0309 I just want to set those users on userson.txt to "off" in... (14 Replies)
Discussion started by: quinestor
14 Replies

4. Shell Programming and Scripting

Loop through hosts file - cat /etc/resolv.conf

Hello... I am trying to loop through my hosts file that contains 100+ servers to check or update the nameservers on them... My while loop is breaking after the first server responds... #!/bin/bash while read line; do a=( $(echo $line | tr " " "\n") ) if }" != "" ] && }" != "#" ] &&... (1 Reply)
Discussion started by: CompSCI
1 Replies

5. Shell Programming and Scripting

chmod to stop cat from displaying the file?

Hi, Im struggling with what chmod to change the permission of a file in the current directory named MyFile so the command "cat MyFile" fails to display the file.?? (10 Replies)
Discussion started by: tryintolearn
10 Replies

6. Shell Programming and Scripting

how to add string inside the file's content

Hi, How to add string inside the file. In this case adding 63 in the beginning of each line. Thnks. e.g. what is inside the file Mobile Number Portability 9051151234 9051261345 9051393245 9051412345 9051507654 should like this as output: Mobile Number Portability (7 Replies)
Discussion started by: shtobias
7 Replies

7. Shell Programming and Scripting

file creation inside loop

i=1 while do touch TC$i.txt i=`expr $1 + 1` done echo "files created successfully" What is wrong with code...its running continuosly... (4 Replies)
Discussion started by: villain41
4 Replies

8. UNIX for Dummies Questions & Answers

problem in reading inside a while loop

I am not able to read inside a while though i get the message "inside read" the cursor doesnt prompt from the console cat file | while read ln_new_engine_dirs do echo "inside $ln_new_engine_dirs" if then read nn echo "inside read" fi done Thanks in advance (3 Replies)
Discussion started by: ssuresh1999
3 Replies

9. UNIX for Dummies Questions & Answers

Using a variable inside a file to cat another.

I have a question to do and it's somewhat confusing. It says, and I quote "Create a file called file_1 with three lines of text in it. Create a shell variable called "f_name", assign it the string "file_1". Use the cat command and the variable "f_name" to display the contents of the file... (3 Replies)
Discussion started by: MaestroRage
3 Replies

10. UNIX for Dummies Questions & Answers

grep/cat/more -- search in a txt file and display content from a specific "keyword"

Hi, I have a .txt file Sample: ===================== NEXT HOST ===================== AEADBAS001 ip access-list extended BLA_Incoming_Filter ip access-list extended BLA_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx =====================... (4 Replies)
Discussion started by: I-1
4 Replies
Login or Register to Ask a Question