09-30-2009
If your working on Unix/Linux you can use HERE Documents in a shell script, like this:
#!/bin/bash
( sqlclient user@password << EOF
Select count(1),Client_id from TABLE_A group by Client_id;
Select count(1),Client_id from TABLE_B group by Client_id;
disconn
EOF
) > query_op_file
If both the queries don't give desired output into the file, then get the output individually and then:
cat 2nd_query_op_file >> 1st_query_op_file (appends output of 2nd query to the first one)
10 More Discussions You Might Find Interesting
1. Programming
Hi I am new to using pl/sql on a unix platform and am having trouble writing to a file from within a block. Below is an example of the code that I have. I know that I need to use UTL_FILE to accomplish this; however, I keep getting errors. Can someone please help me?
I am trying to create a... (1 Reply)
Discussion started by: stky13
1 Replies
2. Shell Programming and Scripting
Hi,
I am trying to do the following using AWK program.
1. Read the input data file
2. Parse the record and see if it contains errors
3. If the record contains errors, then write it into Reject file, else, write into usual output file or display it on the screen
Here is what I have done -... (6 Replies)
Discussion started by: vidyak
6 Replies
3. Shell Programming and Scripting
I'm having problems with writing my sql results to a file:
sqlplus -S username/password@DB <<!!
set echo off
set verify off
set showmode off
set feedback off
set timing off
set linesize 250
set wrap off
set pagesize 0
set newpage none
set tab off
set trimspool on
set colsep... (1 Reply)
Discussion started by: avillanueva
1 Replies
4. Shell Programming and Scripting
Hi,
I have a file in which I have database information along with 1 SELECT statement. Only 1 statement would be there. I want to grep this SELECT STATEMENT only and write into a separate file.
Input File format:
Database_Name:<database>
Schema_Name:<schema>
Table_Name:<table>
Select *... (3 Replies)
Discussion started by: ustechie
3 Replies
5. Shell Programming and Scripting
Hi All,
I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file.
Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I have 1000 files names data1.txt through data1000.txt inside a folder. I want to write a script that will take each first line from the files and write them as output into a new file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies
7. Shell Programming and Scripting
Hi All,
I have an input file containing data as below:
Input.DAT
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111... (11 Replies)
Discussion started by: sagar.cumar
11 Replies
8. Shell Programming and Scripting
Hi
I am trying to write output to a file in columns
I have file in the follwoing:
# cat file
abc
def
#
I am trying to write next output as like
# cat file
abc 123
def 345
#
:mad: (6 Replies)
Discussion started by: Priya Amaresh
6 Replies
9. Shell Programming and Scripting
HI
I am trying to grep 3 characters from hostname and append a character at the end.
I tried as in the following:
root@abag3:~# hostname | cut -c1-3
hyu
Now I am trying to append "g" at the end of this output as in the following.
root@abag3:~# hostname | cut -c1-3 | sed -s... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies
10. Shell Programming and Scripting
Hello,
I am having problem while redirecting output to a file where as on console output is proper.
for dir in */; do printf "%s, " "$dir"; ls -m "$dir"; echo; done > output.txt
Output of above command is coming in single line but when i am redirecting output to a file, single line i... (10 Replies)
Discussion started by: Manoj Rajput
10 Replies
LEARN ABOUT MOJAVE
io::select5.18
IO::Select(3pm) Perl Programmers Reference Guide IO::Select(3pm)
NAME
IO::Select - OO interface to the select system call
SYNOPSIS
use IO::Select;
$s = IO::Select->new();
$s->add(*STDIN);
$s->add($some_handle);
@ready = $s->can_read($timeout);
@ready = IO::Select->new(@handles)->can_read(0);
DESCRIPTION
The "IO::Select" package implements an object approach to the system "select" function call. It allows the user to see what IO handles, see
IO::Handle, are ready for reading, writing or have an exception pending.
CONSTRUCTOR
new ( [ HANDLES ] )
The constructor creates a new object and optionally initialises it with a set of handles.
METHODS
add ( HANDLES )
Add the list of handles to the "IO::Select" object. It is these values that will be returned when an event occurs. "IO::Select" keeps
these values in a cache which is indexed by the "fileno" of the handle, so if more than one handle with the same "fileno" is specified
then only the last one is cached.
Each handle can be an "IO::Handle" object, an integer or an array reference where the first element is an "IO::Handle" or an integer.
remove ( HANDLES )
Remove all the given handles from the object. This method also works by the "fileno" of the handles. So the exact handles that were
added need not be passed, just handles that have an equivalent "fileno"
exists ( HANDLE )
Returns a true value (actually the handle itself) if it is present. Returns undef otherwise.
handles
Return an array of all registered handles.
can_read ( [ TIMEOUT ] )
Return an array of handles that are ready for reading. "TIMEOUT" is the maximum amount of time to wait before returning an empty list,
in seconds, possibly fractional. If "TIMEOUT" is not given and any handles are registered then the call will block.
can_write ( [ TIMEOUT ] )
Same as "can_read" except check for handles that can be written to.
has_exception ( [ TIMEOUT ] )
Same as "can_read" except check for handles that have an exception condition, for example pending out-of-band data.
count ()
Returns the number of handles that the object will check for when one of the "can_" methods is called or the object is passed to the
"select" static method.
bits()
Return the bit string suitable as argument to the core select() call.
select ( READ, WRITE, EXCEPTION [, TIMEOUT ] )
"select" is a static method, that is you call it with the package name like "new". "READ", "WRITE" and "EXCEPTION" are either "undef"
or "IO::Select" objects. "TIMEOUT" is optional and has the same effect as for the core select call.
The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing
and have exceptions respectively. Upon error an empty list is returned.
EXAMPLE
Here is a short example which shows how "IO::Select" could be used to write a server which communicates with several sockets while also
listening for more connections on a listen socket
use IO::Select;
use IO::Socket;
$lsn = IO::Socket::INET->new(Listen => 1, LocalPort => 8080);
$sel = IO::Select->new( $lsn );
while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if($fh == $lsn) {
# Create a new socket
$new = $lsn->accept;
$sel->add($new);
}
else {
# Process socket
# Maybe we have finished with the socket
$sel->remove($fh);
$fh->close;
}
}
}
AUTHOR
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to <perlbug@perl.org>.
COPYRIGHT
Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
perl v5.18.2 2014-01-06 IO::Select(3pm)