• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

call servlet from script sh

 
Thomas Beaujard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would like to call simply a servlet from an unix script (sh). The idea is that the script will be executed directly on the Application Server (Websphere).

Has anyone done anything similar yet?

Thanks in advance.

Thom
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, this is done all the time.

Take a look at the wget program.
All the hard work has already been done for you.
http://linux.die.net/man/1/wget
 
Thomas Beaujard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer.

Is wget installed by default on AIX server or is it an external library?

Basically I'm trying to do this just by using the actual capacity of the OS.

Cheers
Thom
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure about AIX.
It's an open source program so you should be able to download the source and compile for most any Unix.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to our Linux/Unix forum since it's not really servlet specific.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wget and cURL are the best options but they don't come with AIX. They're both easy to compile if you have a C compiler. If you don't want to compile either of them, pWare has them already compiled.
 
Thomas Beaujard
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for your message.

I really want to use perl and IO::socket, I do not have much choice.
However, I am having a hard time to make it work. The code I use does not do anything. (see my code below)

All ideas are welcome.

Cheers,
Thom

code:

use IO::Socket;
$type_connection = "close";

$requete ="GET "./context/servletname." HTTP/1.0\r\n
Host: ".servername ort."\r\n
User-Agent: Agent Batch\r\n
Connection: ".$type_connection."\n\r\n\r";

$remote = IO::Socket::INET->new(servername ort) || die "Connection impossible";
print $remote "$requete";
while ( <$remote> ) { print }
close $remote;
print "Requ\210te HTTP envoy\202e";
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick googling found this article which looks highly relevant: http://www.perlfect.com/articles/sockets.shtml

I'm sure there are HTTP module for Perl that allow you to operate in a higher level, though; have a look at CPAN.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer:
I'm sure there are HTTP module for Perl that allow you to operate in a higher level, though; have a look at CPAN.


That would be libwww-perl, aka LWP, which comes bundled with Perl distributions like the one from ActiveState. It even installs a "GET" or lwp-request command that you can use straight from shell scripts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic