Skip navigation

Since i  have no idea how to script, going along i still try to script something.,… most of the time being unsuccessfull! 😦  My attempts are usually in either in Bash or Perl. Please do not laugh at my scripting ignorance –  i am a noob in this area!

The first script i tried out what the below:

Reading the first line of remote server’s service.



# file:

use IO::Socket;
# Provides an object-oriented interface for network sockets operations

my $server = shift;
# shift – host and service name are moved off the command line and placed in a variable called “server”

my $fh = IO::Socket::INET->new($server);
# Opening a network socket

my $line = <$fh>;
# <> to read a line from a text from the socket into the variable $line which will be immediately printed.

open (SAVEOUT,”>&STDOUT”);
#open file handler and copy it as STDOUT
open (STDOUT,”>results.txt”) or die “Can’t open results.txt: $!”;
#place the file handle contents into reults.txt (where create txt file if does not exist)

#the file will contain the below
print $line;
print “Client date: “;
system “date”;

#recall file handler and close it.
#print the remaining at the default (command line) prompt

open (STDOUT,”>&SAVEOUT”);
print “Done!\n”;

Chmod 775

./ <server-address:smtp>

Result.txt will contain:

220 Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Wed, 16 Jul 2008 21:42:25 +0200
Client date: Wed Jul 16 21:42:25 CEST 2008


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: