Hi,
I'm pretty new to UNIX shell scripting and need some help. We have an Informatica interface that dumps any files that have errors into a directory. I need to check that directory periodically for any of up to 9 files that might be in it and run a specific process for each file found. The directory could (and hopefully would be) empty.
I've gotten some help from some of the folks here and have worked out some of the initial problems, but it goes into an endless loop and I have to stop it. I'm missing something.
Any help would be greatly appreciated.
Here is the test code without the actual processes:
Below is the output it produces when all 9 files are in the directory. It loops through and reads all the files, but then just keeps looping.
CX_CHARGEexport.csv
did do statement
CX_CHARGE file.
did if statement
CX_DEDICATED_EQUIPMENTexport.csv
did do statement
CX_DEDICATED_EQUIPMENT file.
did if statement
CX_LOAD_HISTORYexport.csv
did do statement
CX_LOAD_HISTORY file.
did if statement
CX_LOAD_NOTEexport.csv
did do statement
CX_LOAD_NOTE file.
did if statement
CX_ORDER_LOAD_SHIPMENTexport.csv
did do statement
CX_ORDER_LOAD_SHIPMENT file.
did if statement
CX_PRODUCT_INFOexport.csv
did do statement
CX_PRODUCT_INFO file.
did if statement
CX_RATE_CHANGE_REQUESTexport.csv
did do statement
CX_RATE_CHANGE_REQUEST file.
did if statement
CX_SERVICE_FAILUREexport.csv
did do statement
CX_SERVICE_FAILURE file.
did if statement
CX_SERVICE_REQUESTexport.csv
did do statement
CX_SERVICE_REQUEST file.
did if statement
Your
will read through all files in that directory folder. So, if that commands retrieves more than nine filenames, you will get more than nine results.
Perhaps try
to limit the number of found files.
The echo $filename before the do statement causes the while to examine the exit code of the echo, which is always true. You presumably want to move it after the do
Hi era,
Just wanted to thank you for the help on the Endless Loop problem I posted a week or so ago. Your solution:
"The echo $filename before the do statement causes the while to examine the exit code of the echo, which is always true. You presumably want to move it after the do"
I was practicing writing simple loops as I am a new bash user and I created this script, which turned out to be an endless loop where the echo output does not stop and I do not see where my mistake is.
#!/bin/bash
echo 'enter a number from 1 to 100'
read number
while
do
... (2 Replies)
Hi,
AM very new to shell scripting and try to run a simple do while loop statement, but it ends up running endlessly. please can anyone assist, dunno what am doing wrong, any useful suggestions will be welcomed.
#!/bin/ksh
### To check a running process instance
#################... (5 Replies)
Hi All,
I've written a script to read 2 files and compare the contents using while loop but somehow when $line is not found in test2, the script will continue looping.
Below is my code, pls advise what could went wrong
TIA
Nick
for line in test1.txt | while read line
do
grep -i... (4 Replies)
First time post. I did a search so I didn’t see this specific issue. It seems to be a head scratcher for me.
I have an hourly job that on rare occasions, gets into an endless loop.
I’ve tried different scenarios but the current version does basically the following.
Find all the *.arc files and... (18 Replies)
When finding a string in files within a directory, one can use this:
grep -r "searchstring" dir/subdir/ > listofoccurrences.txt
For brevity sake one can enter the intended directory and use this:
grep -r "searchstring" . > listofoccurrences.txt
which as I found out leads to an endless loop,... (2 Replies)
Hi,
PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime.
I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file.
However, I'd like to make sure... (2 Replies)
I have about 5000 columns of data that i need to convert all of it into pecentages. for shorter colums i have been using this code:
{print $1/($1+$2)*100,$2/($1+$2),$3/($3+$4)*100 .....}
but this is a teadious process... is there anyway to do it without having to write all of them out?
sample... (20 Replies)
Hi
I've set up a remote IP-addressed printer using lpadmin on a hp-ux server. It is - as far as I can tell - identical to another printer on the system of the same model type. The default printer works fine with the lp command; the new printer sends endless copies and the job has to be cancelled... (2 Replies)
I need a quick script that will serve as a sort of "real time monitor" for watching some log files. I am using Bourne shell in HP-UX 10.20. I have basically created a script that never ends, unless of course I manually terminate it. Here's the script (it's called qhistory):
clear
echo "REAL... (3 Replies)