The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Asking about shell script input output redirection trivektor Shell Programming and Scripting 1 10-17-2006 10:13 PM
input redirection question luistid Shell Programming and Scripting 0 08-22-2006 04:28 AM
standard input Jariya Shell Programming and Scripting 1 06-06-2006 08:49 AM
Standard output and redirection jerardfjay Shell Programming and Scripting 2 06-27-2005 08:03 AM
Input Redirection majeed73 UNIX for Dummies Questions & Answers 6 07-08-2002 12:57 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-31-2006
Registered User
 

Join Date: Mar 2006
Posts: 77
Stumble this Post!
permanent redirection of standard input

while running a user inter-active program
how can we get the commands from a
file instead of the user?

is there anyway to permanently redirect content
of a file to standard input?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-31-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
Stumble this Post!
You can do :
Code:
my_program < input_file
If you want the redirectition permanent within your script:
Code:
exec 1<input_file

Jean-Pierre
Reply With Quote
  #3 (permalink)  
Old 10-31-2006
Registered User
 

Join Date: Mar 2006
Posts: 77
Stumble this Post!
thanks for your reply but it didnt solve my problem.
let me explain via example:

i am running sqlplus, then in the sql prompt i am running some queries.

sqlplus user/pasw@DATABASE
SQL> select * from my_table1;
SQL>

but what i want to do is to feed these query statements to sqlplus
from a file.
an example file content can be like this:
select * from my_table1;
select * from my_table2;
select * from my_table3;
Reply With Quote
  #4 (permalink)  
Old 10-31-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,794
Stumble this Post!
Code:
qry=`cat somefile`
sqlplus -s user/passwd@mydb<<EOF
spool myfile.lis
$qry
exit;
EOF
Reply With Quote
  #5 (permalink)  
Old 10-31-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
Stumble this Post!
Two solutions to use with a file containing sql code.
First :
Code:
sqlplus user/pasw@DATABASE < sql_file
Second using sqlplus specific syntax :
Code:
sqlplus user/pasw@DATABASE @sql_file
Jean-Pierre.
Reply With Quote
  #6 (permalink)  
Old 10-31-2006
Registered User
 

Join Date: Mar 2006
Posts: 77
Stumble this Post!
what is spool?
i dont think that my OS supports a command named spool.
can u explain about it?
Reply With Quote
  #7 (permalink)  
Old 11-01-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,323
Stumble this Post!
'spool' is an sql command. Any commands that lie between <<EOF and EOF are not interpreted by shell, but sent in to the sqlplus command for which the input is redirected.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0