hi
i have two files
cat input.txt
123456| 43256
456482|5893242
cat data.txt
xv 123456 abcd dsk
sd 123456 afsfn dd
df 43256 asdf ff
ss 456482 aa
sf 5893242 ff ff
aa 5893242 aa aa
i need to read inputs from input.txt and find data for data.txt.
then i need to print them as a... (2 Replies)
hi all,
i have a while loop which i am using to read lines into an array:
k=0
exec 10<file
while read LINE <&10; do
ARRAY=$LINE
((k++))
done
exec 10>&-
echo ${ARRAY}
for some reason when i display the array it is not showing the last row in the file.
any help appreciated. (1 Reply)
I'm trying to run a set of commands on a remote machine using ssh in a shell script. One of the commands is unzip. But when the execution reaches this command, the script fails with an error that unzip is not found. Below is the code and the error snippet.
sourceDir=$1 ; filename=$3 ; destDir=$2... (4 Replies)
i have a script like below, i am trying to print "...." until a background process that was executed before is running,, the below does work and teh loop keeps on printing "..", can someone help where i am wrong.
/tmp/test/abc.sh &
until
do
echo "..\c"
done
abc.sh is the scipt... (8 Replies)
I'm trying to write a script using expect. I'd like the script to execute several commands when the ssh succeeds and i want it to exit if the ssh fails. Does this require to define a time out for the ssh command so that if the prompt is back before this defined time the next commands are executed??... (2 Replies)
Unable to set ssh passwordless authentication
I am unable to ssh with passwordless authentication from Windows client onto UBuntu server. The ssh version on UBuntu is OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e , while SSH on Windows Client is OpenSSH_5.1p1, OpenSSL 0.9.8k. I turned on ssh... (5 Replies)
Hi,
I am triggering a windows exe file using the below command.
ssh user@remoteserver command.exe -option1:xx /option2:yy
This command is working fine from windows command prompt. When I am triggering the same command from ssh I get the error message cant load
Any ideas to deal with... (2 Replies)
I have a constraint to follow organization policy. So i do not have much liberty.
ssh -i /opt/nonprod user1@hostone -t bash works while ssh -i /opt/nonprod -t bash user1@hostone fails
How can I get this to work when I am enforced to put -t bash before the user@hostname ?
Will share debug... (3 Replies)
I have two users on dest_host server viz wlsadm & wasadm.
From src_host server with root user I m able to passwordless login to wlsadm@dest_host however, the same fails for wasadm@dest_host
Below is the debug for both first the working ssh and then the non-working ssh.
Works:
... (6 Replies)
I have two linux servers viz 12.7.44.18 and 12.7.45.18
I wish to ssh from both these server to a destination AiX server 12.7.33.18
The ssh works from 12.7.44.18 -> 12.7.33.18 but fails from 12.7.45.18 -> 12.7.33.18
The openssl version on both linux source 12.7.44.18 and 12.7.45.18 is the... (7 Replies)
Discussion started by: mohtashims
7 Replies
LEARN ABOUT MOJAVE
net::server::psgi
Net::Server::PSGI(3) User Contributed Perl Documentation Net::Server::PSGI(3)NAME
Net::Server::PSGI - basic Net::Server based PSGI HTTP server class
TEST ONE LINER
perl -e 'use base qw(Net::Server::PSGI); main->run(port => 8080, ipv => "*")'
# runs a default echo server
SYNOPSIS
use base qw(Net::Server::PSGI);
__PACKAGE__->run(app => &my_echo_handler); # will bind IPv4 port 80
sub my_echo_handler {
my $env = shift;
my $txt = qq{<form method="post" action="/bam"><input type="text" name="foo"><input type="submit"></form>
};
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
require CGI::PSGI;
my $form = {};
my $q = CGI::PSGI->new($env);
$form->{$_} = $q->param($_) for $q->param;
$txt .= "<pre>".Data::Dumper->Dump([$env, $form], ['env', 'form'])."</pre>";
return [200, ['Content-type', 'text/html'], [$txt]];
}
DESCRIPTION
If you want a more fully featured PSGI experience, it would be wise to look at the Plack and Starman set of modules. Net::Server::PSGI is
intended as an easy gateway into PSGI. But to get the most out of all that PSGI has to offer, you should review the Plack and
Plack::Middleware. If you only need something a little more rudimentary, then Net::Server::PSGI may be good for you.
Net::Server::PSGI takes Net::Server::HTTP one level farther. It begins with base type MultiType defaulting to Net::Server::Fork. It is
easy to change it to any of the other Net::Server flavors by passing server_type => $other_flavor in the server configurtation. The port
has also been defaulted to port 80 - but could easily be changed to another through the server configuration. You can also very easily add
ssl by including, proto=>"ssl" and provide a SSL_cert_file and SSL_key_file.
For example, here is a basic server that will bind to all interfaces, will speak both HTTP on port 8080 as well as HTTPS on 8443, and will
speak both IPv4, as well as IPv6 if it is available.
use base qw(Net::Server::PSGI);
__PACKAGE__->run(
port => [8080, "8443/ssl"],
ipv => '*', # IPv6 if available
SSL_key_file => '/my/key',
SSL_cert_file => '/my/cert',
);
METHODS
"process_request"
This method has been overridden in Net::Server::PSGI - you should not use it while using Net::Server::PSGI. This overridden method
parses the environment and sets up request alarms and handles dying failures. It calls process_psgi_request once the request is ready
and headers have been parsed.
"process_psgi_request"
Used when psgi_enabled is true. During this method, find_psgi_handler will be called to return the appropriate psgi response handler.
Once finished, print_psgi_headers and print_psgi_body are used to print out the response. See PSGI.
Typically this method should not be overridden. Instead, an appropriate method for finding the app should be given to
find_psgi_handler or app.
"find_psgi_handler"
Used to lookup the appropriate PSGI handler. A reference to the already parsed $env hashref is passed. PATH_INFO will be initialized
to the full path portion of the URI. SCRIPT_NAME will be initialized to the empty string. This handler should set the appropriate
values for SCRIPT_NAME and PATH_INFO depending upon the path matched. A code reference for the handler should be returned. The
default find_psgi_handler will call the "app" method. If that fails a reference to the psgi_echo_handler is returned as the default
application.
sub find_psgi_handler {
my ($self, $env) = @_;
if ($env->{'PATH_INFO'} && $env->{'PATH_INFO'} =~ s{^ (/foo) (?= $ | /) }{}x) {
$env->{'SCRIPT_NAME'} = $1;
return &foo_app;
}
return $self->SUPER::find_psgi_handler($env);
}
"app"
Return a reference to the application being served. This should be a valid PSGI application. See PSGI. By default it will look at
the value of the "app" configuration option. The "app" method may also be used to set the "app" configuration option.
package MyApp;
use base qw(Net::Server::PSGI);
sub default_server_type { 'Prefork' }
sub my_app {
my $env = shift;
return [200, ['Content-type', 'text/html'], ["Hello world"]];
}
MyApp->run(app => &my_app);
# OR
sub app { &my_app }
MyApp->run;
# OR
my $server = MyApp->new;
$server->app(&my_app);
$server->run;
OPTIONS
In addition to the command line arguments of the Net::Server::HTTP base classes you can also set the following options.
app Should return a coderef of the PSGI application. Is returned by the app method.
AUTHOR
Paul T. Seamons paul@seamons.com
SEE ALSO
Please see also Plack, Starman,
Net::Server::Fork, Net::Server::INET, Net::Server::PreFork, Net::Server::PreForkSimple, Net::Server::MultiType, Net::Server::Single
Net::Server::SIG Net::Server::Daemonize Net::Server::Proto Net::Server::HTTP
perl v5.18.2 2012-06-11 Net::Server::PSGI(3)