wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes call servlet from script sh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "call servlet from script sh" Watch "call servlet from script sh" New topic
Author

call servlet from script sh

Thomas Beaujard
Greenhorn

Joined: Jan 31, 2007
Posts: 12
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

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Thomas Beaujard
Greenhorn

Joined: Jan 31, 2007
Posts: 12
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Dec 11, 2004
Posts: 13410

I'm going to move this to our Linux/Unix forum since it's not really servlet specific.
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

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

Joined: Jan 31, 2007
Posts: 12
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
Marshal

Joined: Mar 22, 2005
Posts: 41114
    
  45
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.


Ping & DNS - my free Android networking tools app
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: call servlet from script sh
 
Similar Threads
Retrieve WL command-line (-Dname=value)
calling cgi script
from a applet how can i call a servlet??
how can create datasources during build time? (connection pooling api?)
how to get result from java when java thread is running in background