Sponsored Content
Full Discussion: Else Loop Exiting Early
Top Forums Shell Programming and Scripting Else Loop Exiting Early Post 302177217 by GregWold on Thursday 20th of March 2008 10:28:39 AM
Old 03-20-2008
Question Else Loop Exiting Early

All,

I'm having a problem w/this function. Specifically, I want to call another function (get_stats) when the process in the else completes (the initial if and the elsif seem to work fine). But what's happening is the get_stats function call is running after the else runs only once, NOT when it completes. I need the else condtion to run until the process completes, THEN call get_stats. Thanks in advance!

check_ul_process()
{
PROGRAM=8675309
LONG_SLEEP=5
SLEEP_TIME=1
UL_PROCESS=$(ps -eaf | grep $PROGRAM | grep -v grep | wc -l)

# if 8675309 isn't running
# and it's not being run by cron,
# re-check

if [ $UL_PROCESS -eq 0 ]
then
while [ $LONG_SLEEP -gt 0 ]
do
if test $STARTED_BY_CRON = "False"
then
echo "\rTime to next check - $LONG_SLEEP\c"
fi
let LONG_SLEEP=LONG_SLEEP-1
sleep $SLEEP_TIME
done

LONG_SLEEP=5
check_ul_process
elsif [ $UL_PROCESS -eq 0 -a $UL_FILE_TYPE = TEMP ]

# if a ul_temp file exists
# and 8675309 is not running,
# log error and exit.

echo $(expr substr $(hostname) 5 2 | tr 'a-z' 'A-Z') "::" $(date +'%D %T') ":: Exiting. A .ul_temp file exists, but the upload process isn't running." >> /ops/log/ulgen_report.log #~/test_report.log
exit
else

# if 8675309 is running
# and it's not being run by cron,
# check it until it completes

while [ $LONG_SLEEP -gt 0 ]
do
if test $STARTED_BY_CRON = "False"
then
echo "\rTime to next check - $LONG_SLEEP\c"
fi
let LONG_SLEEP=LONG_SLEEP-1
sleep $SLEEP_TIME
done

LONG_SLEEP=5
get_stats
exit
fi
}
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash: Exiting while true loop when terminal is not the focus window

I am running an Ubuntu Gutsy laptop with Advanced Compiz fusion options enabled. I am using xdotool to simulate keyboard input in order to rotate through multiple desktops. I am looking for a way to kill a while true loop when the Enter key (or Control+C if it is easier) is pushed when the... (2 Replies)
Discussion started by: acclaypool
2 Replies

2. Shell Programming and Scripting

exiting from a loop

I wonder if someone could help me here. I am trying to find a way of exiting from a loop but not exiting me from the script for example #!/bin/ksh # ************* FUNCTIONS ****************** function1() { #ping test ping $1 2 > /dev/null if ; then ... (13 Replies)
Discussion started by: hcclnoodles
13 Replies

3. UNIX Benchmarks

Early PowerMac G5

Hardware Overview: Model Name: Power Mac G5 Model Identifier: PowerMac7,2 Processor Name: PowerPC 970 (2.2) Processor Speed: 1.8 GHz Number Of CPUs: 2 L2 Cache (per CPU): 512 KB Memory: 1.5 GB Bus Speed: 900 MHz Boot ROM Version:... (0 Replies)
Discussion started by: tnorth
0 Replies

4. UNIX for Advanced & Expert Users

"while read ..." loop exiting after reading only one record

Greeting, The following script completes after reading only one record from the input file that contains many records. I commented out the "ssh" and get what I expect, an echo of all the records in the input.txt file. Is ssh killing the file handle? On the box "uname -a" gives "SunOS... (2 Replies)
Discussion started by: twk
2 Replies

5. Shell Programming and Scripting

Problem in exiting a loop

Hi my code looks like: if test $STEP -le 10 then . . ls -1d AM*-OUT|while read MYDIR do cd $MYDIR ls |tail -n1| while read MYFILE do . . if test -s $MYFILE then sqlldr .... rc=$? if test $rc -ne 0 (3 Replies)
Discussion started by: anijan
3 Replies

6. Shell Programming and Scripting

Loop Forever Script Strangely Exiting

Hi, I have a really simple script which I want to run forever, inside the loop it runs a C application which if it exits should restart. #!/bin/sh while true do ./SCF scf.conf >> scf.log sleep 2 done For some reason the SCF C application coredumps and the script is exiting.... (3 Replies)
Discussion started by: marvinwright
3 Replies

7. Shell Programming and Scripting

Problem exiting a WHILE loop in ksh

Hi I am having a problem exiting a WHILE loop. I am on a Sun server using ksh. I am running a Veritas Cluster Software (High Availablity) command to obtain a group status and grepping the command output for status "G" which means that the filesystem is frozen and therefore not available to... (3 Replies)
Discussion started by: bigbuk
3 Replies

8. Shell Programming and Scripting

While Loop Exiting

We are trying to design a flow so that an ETL job shouldn't start until the previous job completes. The script we have written is while ; do sleep 2; done The loop however exits even when the process is actually running. Why could this be happening? (12 Replies)
Discussion started by: jerome_rajan
12 Replies

9. Shell Programming and Scripting

For loop exiting

Hi , I am processing some files using below shell script the problem for loop exit after processing some files even though it exist.After modifying file.txt and rerunning the script and its running .Any Advise for i in `cat /xx/file.txt |tr -s "," '\n' ` ; do echo $i... (3 Replies)
Discussion started by: mohan705
3 Replies
tapset::networking(3stap)												 tapset::networking(3stap)

NAME
tapset::networking - systemtap networking tapset DESCRIPTION
This family of probe points is used to probe the activities of the network device. netdev.receive Data received from network device. See probe::netdev.receive(3stap) for details. netdev.transmit Network device transmitting buffer See probe::netdev.transmit(3stap) for details. netdev.change_mtu Called when the netdev MTU is changed See probe::netdev.change_mtu(3stap) for details. netdev.open Called when the device is opened See probe::netdev.open(3stap) for details. netdev.close Called when the device is closed See probe::netdev.close(3stap) for details. netdev.hard_transmit Called when the devices is going to TX (hard) See probe::netdev.hard_transmit(3stap) for details. netdev.rx Called when the device is going to receive a packet See probe::netdev.rx(3stap) for details. netdev.change_rx_flag Called when the device RX flag will be changed See probe::netdev.change_rx_flag(3stap) for details. netdev.set_promiscuity Called when the device enters/leaves promiscuity See probe::netdev.set_promiscuity(3stap) for details. netdev.ioctl Called when the device suffers an IOCTL See probe::netdev.ioctl(3stap) for details. netdev.register Called when the device is registered See probe::netdev.register(3stap) for details. netdev.unregister Called when the device is being unregistered See probe::netdev.unregister(3stap) for details. netdev.get_stats Called when someone asks the device statistics See probe::netdev.get_stats(3stap) for details. netdev.change_mac Called when the netdev_name has the MAC changed See probe::netdev.change_mac(3stap) for details. SEE ALSO
probe::netdev.receive(3stap), probe::netdev.transmit(3stap), probe::netdev.change_mtu(3stap), probe::netdev.open(3stap), probe::netdev.close(3stap), probe::netdev.hard_transmit(3stap), probe::netdev.rx(3stap), probe::netdev.change_rx_flag(3stap), probe::netdev.set_promiscuity(3stap), probe::netdev.ioctl(3stap), probe::netdev.register(3stap), probe::netdev.unregister(3stap), probe::netdev.get_stats(3stap), probe::netdev.change_mac(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::networking(3stap)
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy