Sponsored Content
Top Forums Shell Programming and Scripting What is issue with this script? Post 302819575 by PikK45 on Tuesday 11th of June 2013 04:27:10 AM
Old 06-11-2013
out=$out$i ==> adds existing value of out if any and value of i together and store it in out itself.

In this part,
Code:
out=""
 while [ $j -lt $i ]
 do
  out=$out$i
  j=`expr $j + 1`
 done
echo "$out"

1. out is first set to nothing.
2. enters while loop with i value as 5 [example]
3. j is 0 in the beginning and on entering out=""|5 ==> used | for separating values of OUT and i
4. i=5 , j = 1, out=5|5
i=5, j=2, out=55|5
i=5,j=3,out=555|5
i=5,j=4,out=5555|5
i=5,j=5 => while loops exits
5. print the value of out as 55555

Is this enough?? Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script: issue changing directories in script

I am working on a script that checks two arguments at the command line. The first argument is a search pattern, the second can be a file or a directory, if it is a file a second script is called that checks it for the search pattern. If the second argument is a directory, it checks for the search... (5 Replies)
Discussion started by: Breakology
5 Replies

2. Shell Programming and Scripting

Issue with the script

#!/bin/ksh set -x SQLSTR="LOGIN/PASSWORD" sqlplus -s ${SQLSTR} @<<EOF set pagesize 0 feedback off verify off heading off echo off; UPDATE TABLE NAME SET VALUE = VALUE + 1 where VALUE2 = 'ABCDE'; exit; COMMIT; EOF i am not able to update the column and not able to exit from sqlplus. ... (7 Replies)
Discussion started by: karthicss
7 Replies

3. Shell Programming and Scripting

Script running from another script issue

Hello All, I am ruuning the below script. userchecking.sh ########################### #! /bin/ksh NIS_SCRIPT_HOME="/mot/systems/NIS_SCRIPT_NEW" . $NIS_SCRIPT_HOME/common.env WORK_DIR="/mot/systems/scripts/" #WORK_DIR="/mot/b36376/myscripts/nis_user_automation"... (1 Reply)
Discussion started by: ajaincv
1 Replies

4. Shell Programming and Scripting

Script Issue

#!/bin/bash ########################################### ADMIN="usera@mblonline.com" AMQ="userb@mblonline.com" SUBJECT="Remote Shutdown Client Status" MAIL="/bin/mail" ########################################### DAT=`date '+%d-%b-%Y'` PLUGIN="/usr/lib/nagios/plugins/check_nrpe" PORT="5666"... (2 Replies)
Discussion started by: telnor
2 Replies

5. Shell Programming and Scripting

Script issue

Hi Folks, I am going through a sample script which is not working. Also i want to understand the certain syntaxes #!/bin/sh clear x="y" echo "enter ur 1st no." read n1 echo "enter ur 2nd no." read n2 while do clear echo "1.sum" echo "2.subtraction" echo "3.product"... (3 Replies)
Discussion started by: rafa_fed2
3 Replies

6. Shell Programming and Scripting

Issue with script

Hi, I have a script which when i run in manually it runs properly, but when i run the same script using UC4 scheduler it dose not run properly. Below is the code i am using. i am not sure what is happening when i run this through UC4 the files are not generated. but when i run this manually it... (1 Reply)
Discussion started by: Mohammed_Tabish
1 Replies

7. Shell Programming and Scripting

Issue with the script

I am trying to run a script which ftp the files from one server to another. Below is the script - #!/bin/bash echo "Please enter no : " read variable echo "You entered: $input_variable" host=xxxxx USER=xxx PASSWORD=xxx ftp -inv $HOST <<EOF user $USER $PASSWORD cd... (4 Replies)
Discussion started by: chandraprakash
4 Replies

8. Shell Programming and Scripting

Issue in Script

I developed a script to group by 1st column and sum few of the column which are required, but while executing sum of 2nd column which has decimals in place is not getting correct sum. below is the script awk -F, '{a+=$2;b+=$33;c+=$58;d+=$11;e+=$50;}END{for(i in a)printf... (2 Replies)
Discussion started by: rramkrishnas
2 Replies

9. Shell Programming and Scripting

Issue with script

Hi, I am running below script using autosys. Though the script is running fine, it fails the workflow but the autosys job shows success. Can you please let me know where can i make change to script:- #!/bin/ksh #to test mail from directory set -x frequency=$1 param_file=/local/test... (4 Replies)
Discussion started by: rajrishi990
4 Replies

10. Shell Programming and Scripting

Issue with pwd for script run by double click on script (MacOS High SIerra)

Hello, I have the following script that just archives and clears some log files. #!/bin/bash # script: archive_logs_and_clear # add date to logfile names and copy archive directory # clear logs # change to script directory cd ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies
IO::Async::Listener(3pm)				User Contributed Perl Documentation				  IO::Async::Listener(3pm)

NAME
"IO::Async::Listener" - listen on network sockets for incoming connections SYNOPSIS
use IO::Async::Listener; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $listener = IO::Async::Listener->new( on_stream => sub { my ( undef, $stream ) = @_; $stream->configure( on_read => sub { my ( $self, $buffref, $eof ) = @_; $self->write( $$buffref ); $$buffref = ""; return 0; }, ); $loop->add( $stream ); }, ); $loop->add( $listener ); $listener->listen( service => "echo", socktype => 'stream', on_resolve_error => sub { print STDERR "Cannot resolve - $_[0] "; }, on_listen_error => sub { print STDERR "Cannot listen "; }, ); $loop->run; This object can also be used indirectly via an "IO::Async::Loop": use IO::Async::Stream; use IO::Async::Loop; my $loop = IO::Async::Loop->new; $loop->listen( service => "echo", socktype => 'stream', on_stream => sub { ... }, on_resolve_error => sub { print STDERR "Cannot resolve - $_[0] "; }, on_listen_error => sub { print STDERR "Cannot listen "; }, ); $loop->run; DESCRIPTION
This subclass of IO::Async::Handle adds behaviour which watches a socket in listening mode, to accept incoming connections on them. A Listener can be constructed and given a existing socket in listening mode. Alternatively, the Listener can construct a socket by calling the "listen" method. Either a list of addresses can be provided, or a service name can be looked up using the underlying loop's "resolve" method. EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_accept $clientsocket Invoked whenever a new client connects to the socket. on_stream $stream An alternative to "on_accept", this an instance of IO::Async::Stream when a new client connects. This is provided as a convenience for the common case that a Stream object is required as the transport for a Protocol object. on_socket $socket Similar to "on_stream", but constructs an instance of IO::Async::Socket. This is most useful for "SOCK_DGRAM" or "SOCK_RAW" sockets. on_accept_error $socket, $errno Optional. Invoked if the "accept" syscall indicates an error (other than "EAGAIN" or "EWOULDBLOCK"). If not provided, failures of "accept" will simply be ignored. PARAMETERS
The following named parameters may be passed to "new" or "configure": on_accept => CODE on_stream => CODE on_socket => CODE CODE reference for the event handlers. Because of the mutually-exclusive nature of their behaviour, only one of these may be set at a time. Setting one will remove the other two. handle => IO The IO handle containing an existing listen-mode socket. METHODS
$name = $listener->sockname Returns the "sockname" of the underlying listening socket $family = $listener->family Returns the socket address family of the underlying listening socket $socktype = $listener->socktype Returns the socket type of the underlying listening socket $listener->listen( %params ) This method sets up a listening socket using the addresses given, and will invoke the "on_accept" callback each time a new connection is accepted on the socket. Addresses may be given directly, or they may be looked up using the system's name resolver. If multiple addresses are given, or resolved from the service and hostname, then each will be attempted in turn until one succeeds. In plain address mode, the %params hash takes the following keys: addrs => ARRAY Reference to an array of (possibly-multiple) address structures to attempt to listen on. Each should be in the layout described for "addr". Such a layout is returned by the "getaddrinfo" named resolver. addr => ARRAY Shortcut for passing a single address to listen on; it may be passed directly with this key, instead of in another array of its own. This should be in a format recognised by IO::Async::OS's "extract_addrinfo" method. See also the "EXAMPLES" section. In named resolver mode, the %params hash takes the following keys: service => STRING The service name to listen on. host => STRING The hostname to listen on. Optional. Will listen on all addresses if not supplied. family => INT socktype => INT protocol => INT flags => INT Optional. Other arguments to pass along with "host" and "service" to the "getaddrinfo" call. socktype => STRING Optionally may instead be one of the values 'stream', 'dgram' or 'raw' to stand for "SOCK_STREAM", "SOCK_DGRAM" or "SOCK_RAW". This utility is provided to allow the caller to avoid a separate "use Socket" only for importing these constants. on_resolve_error => CODE A continuation that is invoked when the name resolution attempt fails. This is invoked in the same way as the "on_error" continuation for the "resolve" method. It is necessary to pass the "socktype" hint to the resolver when resolving the host/service names into an address, as some OS's "getaddrinfo" functions require this hint. A warning is emitted if neither "socktype" nor "protocol" hint is defined when performing a "getaddrinfo" lookup. To avoid this warning while still specifying no particular "socktype" hint (perhaps to invoke some OS-specific behaviour), pass 0 as the "socktype" value. In either case, the following keys are also taken: on_listen => CODE Optional. A callback that is invoked when the listening socket is ready. $on_listen->( $listener ) on_listen_error => CODE A continuation this is invoked after all of the addresses have been tried, and none of them succeeded. It will be passed the most significant error that occurred, and the name of the operation it occurred in. Errors from the listen(2) syscall are considered most significant, then bind(2), then sockopt(2), then finally socket(2). on_fail => CODE Optional. A callback that is invoked if a syscall fails while attempting to create a listening sockets. It is passed the name of the syscall that failed, the arguments that were passed to it, and the error generated. I.e. $on_fail->( "socket", $family, $socktype, $protocol, $! ); $on_fail->( "sockopt", $sock, $optname, $optval, $! ); $on_fail->( "bind", $sock, $address, $! ); $on_fail->( "listen", $sock, $queuesize, $! ); queuesize => INT Optional. The queue size to pass to the listen(2) calls. If not supplied, then 3 will be given instead. reuseaddr => BOOL Optional. If true or not supplied then the "SO_REUSEADDR" socket option will be set. To prevent this, pass a false value such as 0. v6only => BOOL Optional. If defined, sets or clears the "IPV6_V6ONLY" socket option on "PF_INET6" sockets. This option disables the ability of "PF_INET6" socket to accept connections from "AF_INET" addresses. Not all operating systems allow this option to be disabled. As a convenience, it also supports a "handle" argument, which is passed directly to "configure". EXAMPLES
Listening on UNIX Sockets The "handle" argument can be passed an existing socket already in listening mode, making it possible to listen on other types of socket such as UNIX sockets. use IO::Async::Listener; use IO::Socket::UNIX; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $listener = IO::Async::Listener->new( on_stream => sub { my ( undef, $stream ) = @_; $stream->configure( on_read => sub { my ( $self, $buffref, $eof ) = @_; $self->write( $$buffref ); $$buffref = ""; return 0; }, ); $loop->add( $stream ); }, ); $loop->add( $listener ); my $socket = IO::Socket::UNIX->new( Local => "echo.sock", Listen => 1, ) or die "Cannot make UNIX socket - $! "; $listener->listen( handle => $socket, ); $loop->run; Passing Plain Socket Addresses The "addr" or "addrs" parameters should contain a definition of a plain socket address in a form that the IO::Async::OS "extract_addrinfo" method can use. This example shows how to use the "Socket" functions to construct one for TCP port 8001 on address 10.0.0.1: $listener->listen( addr => { family => "inet", socktype => "stream", port => 8001, ip => "10.0.0.1", }, ... ); This example shows another way to listen on a UNIX socket, similar to the earlier example: $listener->listen( addr => { family => "unix", socktype => "stream", path => "echo.sock", }, ... ); AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Listener(3pm)
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy