Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Control not returning to UNIX when sqlplus is executed in while loop of shell script Post 303045806 by jim mcnamara on Monday 13th of April 2020 09:20:07 PM
Old 04-13-2020
You need code tags, your post is hard to read Smilie

Start with only the sql, run it from the sqlplus prompt.
Next wrap JUST the sql that ran above in a shell wrapper. Execute it. Use the parameter associated with the problem.

One thing I've seen that causes hangs is the sqlplus gets what it thinks is garbage, usually caused by trying to quote or escape something so the shell will not wreck it, and passing it through the shell script to sqlplus. sqlpus hangs because it is waiting for more input, like to complete the quote for example.

As a first guess consider this is your problem, especially since it is intermittent. Intermittent == parameter problems

It a is a wait on stdin for sqlplus, I believe.

10 More Discussions You Might Find Interesting

1. Programming

Returning Strings from C program to Unix shell script

Hi, Iam calling a C program from a Unix shell script. The (C) program reads encrypted username/password from a text file , decrypts and returns the decrypted string. Is there any way i can return the decrypted string to Unix shell program. My shell script uses the output of the program to... (11 Replies)
Discussion started by: satguyz
11 Replies

2. Shell Programming and Scripting

Unix shell script couldn't be executed. Pls help!

I have wrriten a script to call sql script to do some work in database. However, the script couldn't be executed. The only information was: ksh: ./updt_attrib.ksh cannot execute. Please help me to identify where the problem is. I post script here for your reference. Thanks a lot. #!/bin/ksh ... (8 Replies)
Discussion started by: duke0001
8 Replies

3. Programming

Returning Strings from C program to Unix shell script

Hi, I'm having a requirement where I need to call a C program from a shell script and return the value from the C program to shell script. I refered a thread in this forum. But using that command in the code, it is throwing an error clear_text_password=$(get_password) Error: bash:... (24 Replies)
Discussion started by: venkatesh_sasi
24 Replies

4. Shell Programming and Scripting

returning un executed string to shell prompt

Hi all, i'm pritty new to chell scripting I'm trying to find a way to return a value to shell without it executing. is there a special character that will encase a sting including the command to a shell without executing, so waiting for the user to press enter. say i wanted to return a value... (3 Replies)
Discussion started by: jvan
3 Replies

5. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

6. UNIX for Dummies Questions & Answers

calling a unix shell script from sqlplus

I want to execute a shell script from sqlplus prompt and get its output back to sqlplus. Is this possible? if yes just give me an example for doing that. (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

7. UNIX for Dummies Questions & Answers

How to send keyboard inputs toa UNIX command executed from a shell script?

I have a unix command that prompts for 'y'. How do I run this from my shell script? (4 Replies)
Discussion started by: Sree10
4 Replies

8. Shell Programming and Scripting

Control from UNIX script is not returning to the Parent program

Hi All, My program flow is as below Windows batch -- > Cygwin batch --> zsh script There are multiple Cygwin batch scripts that are called from Windows batch file . But when i am executing the first cygwin batch script the control goes to the zsh file and executes and stoping from... (1 Reply)
Discussion started by: Hypesslearner
1 Replies

9. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have a UNIX script which will prepare anonymous oracle pl/sql block in a temporary file in run time and passes this file to sqlplus as given below. cat > $v_Input_File 2>>$v_Log << EOF BEGIN EXECUTE IMMEDIATE 'ALTER SESSION FORCE PARALLEL DML PARALLEL 16'; EXECUTE... (1 Reply)
Discussion started by: vikas_trl
1 Replies

10. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have exactly same issue @vikas_trl had in following link: https://www.unix.com/shell-programming-and-scripting/259854-control-not-returning-sqlplus-calling-unix-shell-script.html I wonder if he or somebody else could find the issue's cause or the solution. Any help would... (4 Replies)
Discussion started by: RicardoQ
4 Replies
AUTOEXPECT(1)						      General Commands Manual						     AUTOEXPECT(1)

autoexpect - generate an Expect script from watching a session SYNOPSIS
autoexpect [ args ] [ program args... ] INTRODUCTION
autoexpect watches you interacting with another program and creates an Expect script that reproduces your interactions. For straightline scripts, autoexpect saves substantial time over writing scripts by hand. Even if you are an Expect expert, you will find it convenient to use autoexpect to automate the more mindless parts of interactions. It is much easier to cut/paste hunks of autoexpect scripts together than to write them from scratch. And if you are a beginner, you may be able to get away with learning nothing more about Expect than how to call autoexpect. The simplest way to use autoexpect is to call it from the command line with no arguments. For example: % autoexpect By default, autoexpect spawns a shell for you. Given a program name and arguments, autoexpect spawns that program. For example: % autoexpect ftp ftp.cme.nist.gov Once your spawned program is running, interact normally. When you have exited the shell (or program that you specified), autoexpect will create a new script for you. By default, autoexpect writes the new script to "script.exp". You can override this with the -f flag fol- lowed by a new script name. The following example runs "ftp ftp.cme.nist.gov" and stores the resulting Expect script in the file "nist". % autoexpect -f nist ftp ftp.cme.nist.gov It is important to understand that autoexpect does not guarantee a working script because it necessarily has to guess about certain things - and occasionally it guesses wrong. However, it is usually very easy to identify and fix these problems. The typical problems are: o Timing. A surprisingly large number of programs (rn, ksh, zsh, telnet, etc.) and devices (e.g., modems) ignore keystrokes that arrive "too quickly" after prompts. If you find your new script hanging up at one spot, try adding a short sleep just before the previous send. You can force this behavior throughout by overriding the variable "force_conservative" near the beginning of the generated script. This "conservative" mode makes autoexpect automatically pause briefly (one tenth of a second) before sending each char- acter. This pacifies every program I know of. This conservative mode is useful if you just want to quickly reassure yourself that the problem is a timing one (or if you really don't care about how fast the script runs). This same mode can be forced before script generation by using the -c flag. Fortunately, these timing spots are rare. For example, telnet ignores characters only after entering its escape sequence. Modems only ignore characters immediately after connecting to them for the first time. A few programs exhibit this behavior all the time but typically have a switch to disable it. For example, rn's -T flag disables this behavior. The following example starts autoexpect in conservative mode. autoexpect -c The -C flag defines a key to toggle conservative mode. The following example starts autoexpect (in non-conservative mode) with ^L as the toggle. (Note that the ^L is entered literally - i.e., enter a real control-L). autoexpect -C ^L The following example starts autoexpect in conservative mode with ^L as the toggle. autoexpect -c -C ^L o Echoing. Many program echo characters. For example, if you type "more" to a shell, what autoexpect actually sees is: you typed 'm', computer typed 'm', you typed 'o', computer typed 'o', you typed 'r', computer typed 'r', ... Without specific knowledge of the program, it is impossible to know if you are waiting to see each character echoed before typ- ing the next. If autoexpect sees characters being echoed, it assumes that it can send them all as a group rather than inter- leaving them the way they originally appeared. This makes the script more pleasant to read. However, it could conceivably be incorrect if you really had to wait to see each character echoed. o Change. Autoexpect records every character from the interaction in the script. This is desirable because it gives you the ability to make judgements about what is important and what can be replaced with a pattern match. On the other hand, if you use commands whose output differs from run to run, the generated scripts are not going to be correct. For example, the "date" command always produces different output. So using the date command while running autoexpect is a sure way to produce a script that will require editing in order for it to work. The -p flag puts autoexpect into "prompt mode". In this mode, autoexpect will only look for the the last line of program output - which is usually the prompt. This handles the date problem (see above) and most others. The following example starts autoexpect in prompt mode. autoexpect -p The -P flag defines a key to toggle prompt mode. The following example starts autoexpect (in non-prompt mode) with ^P as the toggle. Note that the ^P is entered literally - i.e., enter a real control-P. autoexpect -P ^P The following example starts autoexpect in prompt mode with ^P as the toggle. autoexpect -p -P ^P OTHER FLAGS
The -quiet flag disables informational messages produced by autoexpect. The -Q flag names a quote character which can be used to enter characters that autoexpect would otherwise consume because they are used as toggles. The following example shows a number of flags with quote used to provide a way of entering the toggles literally. autoexpect -P ^P -C ^L -Q ^Q STYLE
I don't know if there is a "style" for Expect programs but autoexpect should definitely not be held up as any model of style. For example, autoexpect uses features of Expect that are intended specifically for computer-generated scripting. So don't try to faithfully write scripts that appear as if they were generated by autoexpect. This is not useful. On the other hand, autoexpect scripts do show some worthwhile things. For example, you can see how any string must be quoted in order to use it in a Tcl script simply by running the strings through autoexpect. SEE ALSO
"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" by Don Libes, O'Reilly and Associates, January 1995. AUTHOR
Don Libes, National Institute of Standards and Technology expect and autoexpect are in the public domain. NIST and I would appreciate credit if these programs or parts of them are used. 30 June 1995 AUTOEXPECT(1)

Featured Tech Videos

All times are GMT -4. The time now is 02:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy