The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
calling function inside awk jisha Shell Programming and Scripting 2 04-14-2008 08:44 AM
Calling other file function maldini Shell Programming and Scripting 3 08-19-2005 03:23 AM
calling c++ function from script Lebamb High Level Programming 3 06-24-2003 10:53 AM
c++ calling main() function norsk hedensk High Level Programming 3 01-22-2003 08:28 PM
calling a c function from shell seshagiri UNIX for Dummies Questions & Answers 4 12-06-2000 09:51 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 09-11-2006
ashika ashika is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 3
Calling a function

I have created a file generic.func and it has lots of functions. One of the functions is this:
Code:
Check_backup_size()
{
  dsmc q b $BACKUP_DIR/"*.Z" | awk '{print $1}'|sed 's/[^0-9]//g' > outputfile
  X=`awk '{sum += $1} END {print sum }' outputfile'`
  echo "$X"

  ls -ltr $BACKUP_DIR/"*.Z" | awk '{print $1}'|sed 's/[^0-9]//g' > outputfile
  S=`awk '{sum += $1} END {print sum }' outfile11'`
  echo "$S"
  if [ $X = $S ] ;
  then
    SUBJECT="Backup file size is same"
   echo Backup file size is same > /apps/oracle/dsmc.txt

  mailx -s "$SUBJECT"  test@yahoo.com< /apps/oracle/dsmc.txt
  else
    echo"Please call the DBA's"
  fi
}
Now i have to call this function so i created a file test.sh and it contains these commands:

. /apps/oracle/ashika/generic.func
call check_backup_size
BACKUP_DIR = /apps/oracle/ashika

When i run Check_backup_size separately it gives the right result but when i call it as a function in test.sh it doesn't work.Please help....

Ashika

Last edited by reborg; 09-12-2006 at 08:55 PM.. Reason: code tags
  #2 (permalink)  
Old 09-11-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
. /apps/oracle/ashika/generic.func
Check_backup_size
above code will work

Last edited by anbu23; 09-11-2006 at 06:51 PM..
  #3 (permalink)  
Old 09-11-2006
ashika ashika is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 3
It doesn't work!!!! What am i doing wrong???
  #4 (permalink)  
Old 09-12-2006
Balkrishna Balkrishna is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 5
Please remove the open and close round brackets from ur code after the function.
It should be like this
Check_backup_size
{
-----
#ur code
-----
}
  #5 (permalink)  
Old 09-12-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Use any one of the below syntax

Check_backup_size()
{
......
}

or

Function Check_backup_size
{
.......
}

If you still get error show us the error.
  #6 (permalink)  
Old 09-12-2006
reborg's Avatar
reborg reborg is online now Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,240
"it doesn't work" is not very helpful to anyone who tries to help.

What exactly happens?
In what way does it not work?
What error messages if any do you get?
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 06:12 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