•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 427,222 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,280 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1144 | Replies: 5
![]() |
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
hi all,
i have written a shell-script which logs onto a mail-server using telnet and then tries to send the HELO command. The code for the same looks something like this:
The problem is that though the telnet connection is established the "HELO" command doesn't get executed. Kindly let me know what to do to get the "HELO" command executed.
Thanks in advance.
subhash
i have written a shell-script which logs onto a mail-server using telnet and then tries to send the HELO command. The code for the same looks something like this:
exec telnet 150.236.18.66 25; echo "HELO";
The problem is that though the telnet connection is established the "HELO" command doesn't get executed. Kindly let me know what to do to get the "HELO" command executed.
Thanks in advance.
subhash
telnet 150.236.18.66 25 <<EOF HELO whatever else you need to send the mail EOF
Better yet, have the script write everything it wants to send in a file and do
telnet 150.236.18.66 25 <<filename
Or, even better, simply create a properly formatted mail message and use sendmail to send it.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
But if i use the following code
then the telnet connection is getting closed before the HELO command is executed. Please help me out.
telnet 150.236.18.66 25 <<EOF HELO whatever else you need to send the mail EOF
then the telnet connection is getting closed before the HELO command is executed. Please help me out.
Well, it shouldn't be.
Using a "here document" is very standard for this sort of thing.
How do you know it is getting closed before sending that? (It's not something you'll see in the console, or anything.)
Edit: And the second example in my first post should be <filename, not <<filename.
Using a "here document" is very standard for this sort of thing.
How do you know it is getting closed before sending that? (It's not something you'll see in the console, or anything.)
Edit: And the second example in my first post should be <filename, not <<filename.
Last edited by masijade : Jul 16th, 2008 at 9:09 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Apr 2008
Posts: 39
Reputation:
Rep Power: 1
Solved Threads: 8
It actually probably should be in most secure environments...
Try this one:
set up the mailserver, USER and PWORD variables accordingly.
You usually need to authenticate with telnet.
Try this one:
telnet $mailserver <<END
user $USER $PWORD
/path/to/HELO
exit
ENDset up the mailserver, USER and PWORD variables accordingly.
You usually need to authenticate with telnet.
Last edited by omrsafetyo : Jul 16th, 2008 at 12:59 pm.
•
•
Join Date: Oct 2007
Posts: 275
Reputation:
Rep Power: 1
Solved Threads: 26
Hey There,
You can also try
and see if the mailserver isn't just dishing you for not identifying your origin.
or try
and, like omrsafetyo mentioned, you'll probably need to authenticate.
Best wishes,
Mike
Maybe, maybe not.
You can also try
HELO whateveryourdomainis.com
and see if the mailserver isn't just dishing you for not identifying your origin.
or try
EHLO ..etc, etc, etc
and, like omrsafetyo mentioned, you'll probably need to authenticate.
Best wishes,
Mike
Maybe, maybe not.
•
•
•
•
But if i use the following code
telnet 150.236.18.66 25 <<EOF HELO whatever else you need to send the mail EOF
then the telnet connection is getting closed before the HELO command is executed. Please help me out.
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Automating sftp (script) to copy files
- Next Thread: mailx & heredoc



Linear Mode