The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple functions amitrajvarma Shell Programming and Scripting 1 11-27-2007 11:21 AM
Use of functions amitrajvarma Shell Programming and Scripting 1 11-23-2007 06:52 AM
ksh functions scriptingmani Shell Programming and Scripting 3 07-06-2007 07:15 AM
functions in Raom Shell Programming and Scripting 6 07-21-2006 03:06 AM
FTP functions hzambra High Level Programming 3 05-03-2002 01:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2006
sendhilmani sendhilmani is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 12
Regarding functions

Hi,

I have a function or script like this.

show()
{
echo "Hi"
} | tee -a log
show

This creates a logfile and prints Hi in it. Now when I try to do the same for sql like this:

show()
{
sqlplus -s scott/tiger<<!
select * from details;
!
} | tee -a log
show
Then it gives me a error telling me that :show not found.

What am I doing worng here. Please put some light on this.

Thanks in advance
  #2 (permalink)  
Old 03-24-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
Hi,
Try this..if u want to remove sqlplus option remove it this will give u data only
or u can use EXIT; in ur script that will bring control back to ur script from sqlplus

show()
{
x=`sqlplus -s scott/tiger<<!
set echo off
set serveroutput on
set heading off
set feedback off
select * from details;
EXIT;
!`
echo $x>>log
}
#echo "before "
show

Last edited by Dhruva; 03-24-2006 at 02:24 AM..
  #3 (permalink)  
Old 03-24-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally Posted by sendhilmani
show()
{
echo "Hi"
} | tee -a log
show
This creates a logfile and prints Hi in it.
I can't recreate that result. What shell are you using?

show() { echo "Hi" ; }
will define a function but does not run it. No output occurs.

show() { echo "Hi" ; } | tee -a log
The pipeline forces creation of a subshell. The subshell defines a function then exits producing no output. The empty output is piped to tee. With the -a option, tee appends nothing to the file. Maybe the file had Hi from a previous run?. The pipeline exits. Now when the parent shell next encounters "show", it will have no idea what that is supposed to be.

show() { echo "Hi" ; }
show | tee -a log
is maybe what you are trying to do.

Or
show () { echo "Hi" | tee -a log ; }
show
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0