I have run out of ideas as to why this select doesn't work in a script I am writing.
The script sources a file of common functions and I am trying to use a select statement within one of the functions -
When I look at the output I see the prompt is drawn twice, which suggests that the loop is taking input from somewhere and finding it wanting, so is prompting again?
OP -
I have tried every variation. I can get this to work without problem in simple test scripts. At present, no matter what I try, the script drops straight through the loop and the variable isn't set as the user never gets a chance to do anything.
Yes, like I said, I too can get it to work in other scripts.
In fact if I source this same file of functions and call the function with the menu in, it works?!?
I'm wondering why I am getting the prompt twice, that seems to be the only symptom. Have I messed up the environment somehow? I'm definitely not calling the function twice, but I'm getting the prompt twice after setting PS3....
I'm baffled.
---------- Post updated at 04:13 PM ---------- Previous update was at 03:43 PM ----------
I have replaced the select statement with a while read -e statement and the loop drops straight through like the select does.
I'm beginning to suspect that the code is not reading from standard in but maybe I have an open file descriptor within the code somewhere, 2000+ lines....
Are there any debug commands that let me look at what is being read from?
I know that there is a named pipe being held open by a background child process and I'm wondering if the read is being affected by this??
---------- Post updated at 04:48 PM ---------- Previous update was at 04:13 PM ----------
I think I'm getting somewhere now. The script runs multiple jobs via ssh on remote servers and then exits after they have completed.
Looking at the ps output and the lsof for the user I see a lot of open ssh connections -
I guess most of these are because I have been debugging the script and killing the script before it cleans up on exit. But I do wonder if there is a way of explicitly closing these connections and I still don't know if they are at the root of the problem of the read ...
---------- Post updated at 06:03 PM ---------- Previous update was at 04:48 PM ----------
I was correct to think it was reading from somewhere. I short circuited the function with this loop that explicitly reads from stdin -
Now it blocks on the read instead of dropping straight through.
I guess I should try and see where the select is reading from ...
---------- Post updated at 06:12 PM ---------- Previous update was at 06:03 PM ----------
Well, the "Fix" if it can be called that was to -
Although I would have preferred to understand where it was reading from without the explicit direction to read from stdin
Difficult to say without seeing the rest of your code. I suspect you're using this in some sort of loop with a file redirected into it, which 'select' takes to be stdin instead of the terminal...
Hi,
i want to do the following:
Grep the following kind of strings for the 15digit ID which is stored in filename1:
"14:06:51.396 INFO BMCREMEDYSD INPUT-ACTION Failed to retrieve Remedy Incident Modification record: 000000000039047 org.apache.axis2.AxisFault: Read timed out - complete... (9 Replies)
Hi all,
I'm using below code
processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS
whenever sqlerror exit sql.sqlcode;
set head off feedback off echo off pages 0
SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}'
... (8 Replies)
Hi Forum.
Need your expertise on the following question.
I have the following file which I would like to parse, find first block of SELECT statment and concatenate all input fields as 1 field (~ delimited):
Old File:
SELECT /*+ USE_HASH(CCOMM ICAR IMAP IAS IP IMAS IMPS IAP SPCA) */
... (5 Replies)
Hello All,
I am new to shell scripting. I am working on Solaris O/S, bash script and sybase programming.
I want to loop through multiple values in an array and for each value, I
want to select a row from the database.
following is the code written for it.
output="loop.csv" ... (8 Replies)
i want to select a variable created and use it in a if statement, but not getting the desired results
LINE='device for 0101a01: lpd://172.25.41.111:515'
prt=`echo $LINE | awk '{print $3 }' | cut -c 1-7`
echo $prt
My if statement to select just what i want..
IFS=$":"
while read prt... (11 Replies)
I am trying to assign an select statement into a variable. Can someone hel me with this.
example :
a='select * from dual'
echo $a should give me select * from dual
But this is not working. I trying with \ before * and quotes too. (1 Reply)
Hi there
I have a database on a remote box and i have been using shell script to insert data into it for example, i could have a script that did this
SN=123456
n=server1
m=x4140
sql="UPDATE main SET hostname='$n',model='$m' WHERE serial='$SN';"
echo $sql |/usr/sfw/bin/mysql -h... (4 Replies)
If I recall, when I used informix I could do a sql statement like:
SELECT Value from Table WHERE ID in (100,200,300);
How do I do this in Oracle? I believe I am using Oracle 10 if that matters.
Thanks. (1 Reply)
Hi,
I have a UNIX script which calls SQL Select statement:
Now i want to use the output of that select statement within my UNIX script so as to call different shell script depending upon the output of the select statement.
Can anyone help me in this regard.
TIA
Akhil Goel (4 Replies)
Hello
I would like to perform a select from a oracle table and return those values to my shell script
For example:
site=head -1 $infile | cut -c1-15 | awk '{printf "s%", $0}
sqlplus -s /nolog |& #Open pipe to sql
select col1, col2, col3, col4
from oracle_table
where col5 =... (6 Replies)