Hi.
I am new to scripting and could really do with some advice on the best way to put a script together. Here is the scenario I am working to;
- i will get files via ftp to a tmp directory on the server
- all files will have a unique file name but with the same extension (.USM)
- for each file I need to run an application process that creates a new file by prefixing each file with 'mt' and appending '_file_01
- therefore from 1234.USM a new file name mt1234_file_01 will be created.
- a second process will then take mt1234_file_01 and make mt1234_file_02
- once the application processes have been created I will then need to move all the files to a new directory so that the FTP side of the script can run the next day and only new files are processed again.
The bit I am stuck on is defining the three types of files so that I can run a foreach command processing that set of files.
I have something if there is just one set of files which is like this;
PHP Code:
while (1 == 1)
if ( $status == 0 ) then
set MARC_FILES = (*.USM)
else
set MARC_FILES = " "
endif
foreach F ($MARC_FILES)
if ( "$F" != "*.USM" ) then
# -- application script that takes a file and makes a new one
csh -f $proc/p_file_01 TST01,$F,mt$F_file01,
set MARCLOADERRORS=0
echo " " > $DATA_DIR/marcload_email_txt.dat
endif
end
What I need some help with is the logic in doing a foreach of the 1st set of newly created files and then the 2nd set of newly created files.
$F is set in the script above.
$F1 should me something like mt$F_file_01 ($F needs to lose the .USM extension)
$F2 should then be mt$F_file_02 (again where $F needs to lose the .USM extension)
help....
any pointers would be great as I am not sure where the best place is to start.
thanks,
Mark
---------- Post updated at 05:00 PM ---------- Previous update was at 04:59 PM ----------
forgot to mention. this is using .csh
the application scripts are using .csh so i wanted to keep this additional script in the same programming language.