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 for any of up to 9 files that might be in it and run a specific process for each file found.
Here's what I have, but it hangs at the cat line. Seems like it should be pretty simple, but there's just something that I'm not understanding. The IF statement I'm using works because I have it in another script that works, it's just long so I abbreviated.
#!/bin/ksh
ls -l /home/inform/LeanLogistic >$LIST_OF_FILES
cat $LIST_OF_FILES|while read LINE
do
filename=`echo $LINE|awk '{print $9}'`
if [ "$filename" = "CX_ORDER_LOAD_SHIPMENTexport.csv" ];
then ...
elif [ "$filename" = "CX_CHARGEexport.csv" ];
then ...
elif [ "$filename" = "CX_LOAD_HISTORYexport.csv" ];
then ...
# goes on to check for the other 6 files, you get the picture
fi ...
done
a) can you edit and/or remember when posting code to use the codetag's? Highlight the code and then select the # icon - this will keep the line formatting.
b) do you know if anything exists in $LIST..
c) add some well-placed echo commands to show variables at steps as this will confirm data and also allow tracking of program progress
d) not sure of the purpose of the ; at end of the if ... line as your then appears to be on the next programming line
e) I often use the format
as I find it easier to read; although your choice might be ok
Thanks for the help. Sorry about the code tags Joey, I didn't know they existed, but I'll use them from now on.
Franklin, I used your method in a test script against a test directory that has all the files in it and it lists the files, but then goes into an endless loop. Obviously I'm still missing something. Any help will be appreciated.
Here's the code:
Here's the output it produces. I have to stop it or it will continue to loop.
CX_CHARGEexport.csv
did do
CX_CHARGE file.
did if
CX_DEDICATED_EQUIPMENTexport.csv
did do
CX_DEDICATED_EQUIPMENT file.
did if
CX_LOAD_HISTORYexport.csv
did do
CX_LOAD_HISTORY file.
did if
CX_LOAD_NOTEexport.csv
did do
CX_LOAD_NOTE file.
did if
CX_ORDER_LOAD_SHIPMENTexport.csv
did do
CX_ORDER_LOAD_SHIPMENT file.
did if
CX_PRODUCT_INFOexport.csv
did do
CX_PRODUCT_INFO file.
did if
CX_RATE_CHANGE_REQUESTexport.csv
did do
CX_RATE_CHANGE_REQUEST file.
did if
CX_SERVICE_FAILUREexport.csv
did do
CX_SERVICE_FAILURE file.
did if
CX_SERVICE_REQUESTexport.csv
did do
CX_SERVICE_REQUEST file.
did if
I need a bit of explanation:
LogFile=${LOGS_DIR}/${1}_$$
I know:
- LOGS_DIR is an environment variable
- $$ is the PID
... but what is ${1} ?? Is it another method to access a command line variable, or the job name?
Thanks!
Jon (3 Replies)
Hello All,
First and foremost, if I have posted this question in the wrong forum/section, I apologize.
Okay so here is my dilemma. I have written a BASH script that automatically restarts a tomcat on a given server. That part was simple enough. However, now I would like to not only restart... (14 Replies)
Hello,
I like to begin with :wall:.. literally... It has been 4 days and I have no idea how to fix it.
Environment - AIX 5.3
I wrote a script to call on ssh to log into another box via PKA to do something else.
If I run the script on the terminal, it works 100%. If the SAP customised... (11 Replies)
Ok,
I stole some code from a program that takess a hash of a password from PasswdMD5 and replaces it in the /etc/shadown file on a linux system. I run his program and it's fine. Well I took the same code and put it in another program that won't ask for prompgx and such and this code won't work:... (2 Replies)
I have a CSV file that I am trying to parse with awk in a table. I think I am going about this the wrong way. I can't get the awk arrays to output with a tab between them in one line. They print out vertically and I need them to print out horizontally. WHAT AM I DOING WRONG?? I want to know if... (21 Replies)
Hi All, I'm fairly new to Regular Expressions, and have made some decent progress, but this one has me scratching my head. I'm trying to match the class name in my scripts as shown in the examples below. Any ideas?
Thanks!
-Mark
:: Looking for a regex to match the red text ::
import... (7 Replies)
Have been asked to remove all images from being logged to the access_log ... where am I going wrong?<VirtualHost 123.456.789.99>
ServerName www.somedomain.com.au
DocumentRoot /agents/tts
Redirect /wap http://somewap.com.au/traveler
LogFormat "%v %h %l %u %t \"%r\" %>s %b" comonvhost... (2 Replies)