Problem with function script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with function script.
# 1  
Old 04-18-2008
Problem with function script.

Need an extra set of eyes. Can't find function. Can someone help, please. Thanks


echo " Is this the correct list of tapes to eject (y/n)?"
read option
echo $option
case $option in
y|Y) TAPE_ROUTINE;;
n|N) exit
esac

##### Count the number of volumes to eject ########
#### When volume count is 40 go to EJECT_TO SILO ####
TAPE_ROUTINE ()
{
cat $EJECTED_TAPES; echo "ejected these tapes"
TAPE_CT=0
CAP_TOTAL=40
EJECT021=ejectupto40.log
cat /dev/null > $EJECT021

while read volume until EOF
do echo "volume ejected $volume"
TAPE_CT=`expr $TAPE_CT + 1`
echo $TAPE_CT

if [ $TAPE_CT < $CAP_TOTAL ] && [ ! EOF ]
then
cat $volume >> $EJECT021
else
echo "eject $TAPE_CT .. CAP is $CAP_TOTAL first cap"
EJECT_TO_SILO
fi
done < $EJECTED_TAPES
}

### Eject tapes to Cap with total count is 40 ####
EJECT_TO_SILO ()
{
# /opt/OMIdtelm/bin/eject_vol -t 3600 -c 0,2,1 -l $EJECT021 | tee $EJECT_LOG;
echo "ejected $volume to cap 0 2 1"; sleep 10
mv $EJECT021 ejected_next_group.txt
/dev/null > $EJECT021
$TAPE_CT =0
}
# 2  
Old 04-18-2008
You must define the function before using it.

Code:
#--------------------------------------
# L O C A L   F U N C T I O N S . . .
#--------------------------------------

### Eject tapes to Cap with total count is 40 ####
EJECT_TO_SILO ()
{
# /opt/OMIdtelm/bin/eject_vol -t 3600 -c 0,2,1 -l $EJECT021 | tee $EJECT_LOG;
echo "ejected $volume to cap 0 2 1"; sleep 10
mv $EJECT021 ejected_next_group.txt
/dev/null > $EJECT021
$TAPE_CT =0
} 

##### Count the number of volumes to eject ########
#### When volume count is 40 go to EJECT_TO SILO ####
TAPE_ROUTINE ()
{
cat $EJECTED_TAPES; echo "ejected these tapes"
TAPE_CT=0
CAP_TOTAL=40
EJECT021=ejectupto40.log
cat /dev/null > $EJECT021

while read volume until EOF
do echo "volume ejected $volume"
TAPE_CT=`expr $TAPE_CT + 1`
echo $TAPE_CT

if [ $TAPE_CT < $CAP_TOTAL ] && [ ! EOF ]
then
cat $volume >> $EJECT021
else
echo "eject $TAPE_CT .. CAP is $CAP_TOTAL first cap"
EJECT_TO_SILO 
fi
done < $EJECTED_TAPES
}


#--------------------------------------
# M A I N . . .
#--------------------------------------

echo " Is this the correct list of tapes to eject (y/n)?"
read option
echo $option
case $option in
y|Y) TAPE_ROUTINE;;
n|N) exit 
esac

Jean-Pierre.
# 3  
Old 04-18-2008
Thank-you all for your help.


#--------------------------------------
# L O C A L F U N C T I O N S . . .
#--------------------------------------

### Eject tapes to Cap with total count is 40 ####
EJECT_TO_SILO ()
{
# /opt/OMIdtelm/bin/eject_vol -t 3600 -c 0,2,1 -l $EJECT021 | tee $EJECT_LOG;
echo "ejected $volume to cap 0 2 1"; sleep 10
mv $EJECT021 ejected_next_group.txt
/dev/null > $EJECT021
$TAPE_CT =0
}

##### Count the number of volumes to eject ########
#### When volume count is 40 go to EJECT_TO SILO ####
TAPE_ROUTINE ()
{
cat $EJECTED_TAPES; echo "ejected these tapes"
TAPE_CT=0
CAP_TOTAL=40
EJECT021=ejectupto40.log
cat /dev/null > $EJECT021

while read volume until EOF
do
echo "volume ejected $volume"
TAPE_CT=`expr $TAPE_CT + 1`
echo $TAPE_CT
if [ $TAPE_CT != 40 ]
then
$volume | tee $EJECT021
else
echo "eject $TAPE_CT .. CAP is $CAP_TOTAL first cap"
EJECT_TO_SILO
fi
done < $EJECTED_TAPES
}


#--------------------------------------
# M A I N . . .
#--------------------------------------

echo " Is this the correct list of tapes to eject (y/n)?"
read option
case $option in
y|Y) TAPE_ROUTINE;;
n|N) exit

Last edited by gzs553; 04-18-2008 at 05:49 PM.. Reason: Found the problem
# 4  
Old 04-21-2008
Need an extra set of eyes to find TOTAL CT bug?

Almost there, but I can't seem to get my counters right. Anyone can please look and see what I am missing. Thanks

# This scripts ejects IP tapes from the STK9310 silo via ACSLS Commands from plebsb01.
# Scripter : Kathe Flanigan 1/31/07
#!/bin/ksh
set -x
rpt=/export/home/legato/tapemgr/rpts/offsite
dat=`date +"%m%d%y"`
rdat=`date +"%b%d%y_%H%M%S"`
EJECTED_TAPES="$rpt/ejected/eject_tapes_test.041608"
OFFSITE_RPT="$rpt/Offsite.rpt.041608"
EJECT_LOG=$rpt/ejected/ejected_tape.status.log.041608
TOT_TAPE_CT_EJECTED=0
TAPE_CT=0
CAP_TOTAL=40
EJECT40=ejectupto40.log
cat /dev/null > $EJECT040

#--------------------------------------
# L O C A L F U N C T I O N S . . .
#--------------------------------------

### Eject 40 tapes to Cap ####

EJECT_TO_SILO ()
{
echo "EJECT_TO_SILO _ List of tapes to be ejected to cap 0,2,1"; cat $EJECT40 ; sleep 2
TOT_TAPE_CT_EJECTED=`expr $TOT_TAPE_CT_EJECTED + $TAPE_CT`
# /opt/OMIdtelm/bin/eject_vol -t 3600 -c 0,2,1 -l $EJECTED_TAPES | tee $EJECT_LOG;
cat $EJECT40 >> TAPES_EJECTED.log
cat /dev/null >$EJECT40
echo "total tapes eject $TOT_TAPE_CT_EJECTED";sleep 1
TAPE_CT=0
}

##### Count the number of volumes to eject ########
#### When volume count is 40 go to EJECT_TO SILO ####


TAPE_ROUTINE ()
{
while read volume until EOF
do
echo " In tape routine volume ejected $volume"
echo $TAPE_CT
if [ $TAPE_CT != 40 ]
then
echo $volume >> $EJECT40
else
echo "eject $TAPE_CT .. CAP is FULL"; sleep 1
EJECT_TO_SILO
fi
TAPE_CT=`expr $TAPE_CT + 1`
done < $EJECTED_TAPES
EJECT_TO_SILO

#TOT_TAPE_CT_EJECTED=`expr $TAPE_CT + $TOT_TAPE_CT_EJECTED`
echo "Total tapes ejected: $TOT_TAPE_CT_EJECTED" >> TAPES_EJECTED.log
mv TAPES_EJECTED.log TOT_TAPES_EJECTED.rpt.$rdat
}


#--------------------------------------
# M A I N . . .
#--------------------------------------
cat $EJECTED_TAPES
echo "Total Tapes to eject is: "; cat $EJECTED_TAPES | wc -l

echo " Is this the correct list of tapes to eject (y/n)?"
read option
case $option in
y|Y) TAPE_ROUTINE;;
n|N) exit
esac

Last edited by gzs553; 04-21-2008 at 05:06 PM.. Reason: Extra eyes needed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

Bash script: problem with a function which use colors

Hello guys :) I've a some issue with a function which use the bash colors in my script. An example : #!/bin/bash set -x log_in(){ host="srv1" remote_files="log/" LOG_FILE="logfile" green='\033]; then color_in_red=("${red}"$2"${none}") echo -e... (2 Replies)
Discussion started by: Arnaudh78
2 Replies

3. Shell Programming and Scripting

Function problem

hey guys, im trying to learn bourne shell atm and I'm having some issues with functions. so heres my code: #!/bin/bash ##functions memory () { free -m } space () { df -h } ip () { (5 Replies)
Discussion started by: hawkfro12
5 Replies

4. Shell Programming and Scripting

Problem while Invoke Shell Script function from Java Program

Hi, I have create a Shell Script, with one function. I want to call the script file in Java Program. It working fine. but the problem is the function in the Shell Script is not executed. Please suggest me, Regards, Nanthagopal A (2 Replies)
Discussion started by: nanthagopal
2 Replies

5. Shell Programming and Scripting

Problem in passing date to external function from perl script.

my $sysdate = strftime('%Y-%m-%d', localtime ); biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals) In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
Discussion started by: Devesh5683
1 Replies

6. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

7. Shell Programming and Scripting

Calling Function Problem

Hi, I had a scripts which calls two function. One function will call another function, script is working fine but the second function is not calling the first function. Below is the script #!/usr/bin/ksh fun1() { echo $DATETIME >> Test1.ksh return 0 } fun2() { typeset DATETIME=`date... (5 Replies)
Discussion started by: somu_june
5 Replies

8. Shell Programming and Scripting

Problem with function in a script

Hi All, What is the problem with the following script: function mmdd { dd=$2 case $1 in "Jan") mm=01;; "Feb") mm=02;; "Mar") mm=03;; "Apr") mm=04;; "May") mm=05;; "Jun") mm=06;; "Jul") mm=07;; "Aug") mm=08;; "Sep") mm=09;; "Oct") mm=10;; "Nov") mm=11;; "Dec") mm=12;; *)... (3 Replies)
Discussion started by: Hiso
3 Replies

9. Shell Programming and Scripting

Problem with a function in a shell script

Hi, I am trying to write a function in the shell script . This function accepts two parameters. It is as following: set_cache(i_SEQ_NAME,I_cache_size) { _sqlplus "BEGIN alter_seq_cache(i_SEQ_NAME, I_cache_size); END;" } _sqlplus is another function and has been working working.... (3 Replies)
Discussion started by: neeto
3 Replies

10. Shell Programming and Scripting

problem, with if condition in function

Hi All, I have a function which reads parameter and gets the value from config file. The entry in the file can be either of two Name=value or Name=value so if the variant is not present it should return me the generic value ie Name without variant. I am first searching for variant in... (4 Replies)
Discussion started by: gurukottur
4 Replies
Login or Register to Ask a Question