With TIMESTAMP=$(date "+%Y%m%d%H%M%S") I doubt that any files are matched when "sysdate is the date of that day".
Your $log_file will be overwritten with every new redirection.
After sending $mail_body, you spend quite some effort to create another one never to be used.
could be replaced by
I don't see any way to guess at what unspecified magic will translate:
And, you have given us no indication of what format is used to display your systemdate... could it be: DayOfWeek, MonthNameDayOfMonth, Year; YYYYMMDD; MM-DD-YYYY; or something very complicated like MM/DD/YYYY (which is a pathname, not a filename)? Of course, if you use the 1st form of systemdate above your (unneeded) awk script won't work. And, with parentheses in your file names (and, especially if you include <space>s in your file names), you absolutely have to quote all expansions of the variable(s) that contain those file names.
All of the uses of cat and awk in your script should be removed to make your script more efficient. And expansions of all of your variables should be quoted. But, without a clear definition of the mapping of the filenames in /scripts/data/file_list.ind to the filenames you need to process, there isn't much we can do to help you fix your code.
You haven't said what operating system or shell you're using. From your definition of the variable _ID, I would assume you're using a Solaris/SunOS system and that you are not using /bin/sh as your shell (since you're using the $(command) form of command substitution). If you're using a Solaris 10 system and ksh (which on Solaris 10 is a 1988 version of the Korn shell) as your shell, the variable substitutions suggested by Chubler_XL in post #2 won't work. Any time you post a shell script and ask for help modifying it, please tell us what operating system (including the version) and shell you're using so we can make suggestions that will work in your environment.
Thank you for your reply.i did take your suggestion removed Cat command and did below modifications and its working now file_list.ind file like this:
Then in you script do this:
It's working fine for
But not for
I did add else if condition for bz2 file it does not seem to work .i just wanna trigger alert if both of these doesn't exist or any one from both name should be printed in mail I am sending.
---------- Post updated at 12:49 PM ---------- Previous update was at 12:34 PM ----------
Quote:
Originally Posted by Don Cragun
I don't see any way to guess at what unspecified magic will translate:
And, you have given us no indication of what format is used to display your systemdate... could it be: DayOfWeek, MonthNameDayOfMonth, Year; YYYYMMDD; MM-DD-YYYY; or something very complicated like MM/DD/YYYY (which is a pathname, not a filename)? Of course, if you use the 1st form of systemdate above your (unneeded) awk script won't work. And, with parentheses in your file names (and, especially if you include <space>s in your file names), you absolutely have to quote all expansions of the variable(s) that contain those file names.
All of the uses of cat and awk in your script should be removed to make your script more efficient. And expansions of all of your variables should be quoted. But, without a clear definition of the mapping of the filenames in /scripts/data/file_list.ind to the filenames you need to process, there isn't much we can do to help you fix your code.
You haven't said what operating system or shell you're using. From your definition of the variable _ID, I would assume you're using a Solaris/SunOS system and that you are not using /bin/sh as your shell (since you're using the $(command) form of command substitution). If you're using a Solaris 10 system and ksh (which on Solaris 10 is a 1988 version of the Korn shell) as your shell, the variable substitutions suggested by Chubler_XL in post #2 won't work. Any time you post a shell script and ask for help modifying it, please tell us what operating system (including the version) and shell you're using so we can make suggestions that will work in your environment.
Thank you for your reply.
I am just new to shell script trying my best to make things work .i will try to answer your questions.Yes I did remove cat and awk My requirement is simple I will be receiving files daily in directory /apps/data and format of files will be SOME_TEXT_SYSDATE(YYYYMMDD)_number(0-9)_of_mly.dat and one more file SOME_TEXT_SYSDATE(YYYYMMDD)_number(0-9)_of_mly.bz2 .Number in file name is random it can be anything.I need to generate alert with missing file name if single or both files are missing.I am using Linux OS.
---------- Post updated at 12:57 PM ---------- Previous update was at 12:49 PM ----------
Quote:
Originally Posted by Chubler_XL
Try formatting your file_list.ind file like this:
Then in you script do this:
There is change in format of file SOME_TEXT_SYSDATE(YYYYMMDD)_number(0-9)_of_mly.bz2 we have random number between (0-9) in file name.
I'd propose you post some representative samples from real data / structures and detailed error messages so we can stop wild guesses and start analysing and eventually solving the problem. You may want to run the script with the -x (xtrace) option set so everybody can see what is going on.
Thank you for your reply.i did take your suggestion removed Cat command and did below modifications and its working now file_list.ind file like this:
Then in you script do this:
It's working fine for
But not for
I did add else if condition for bz2 file it does not seem to work .i just wanna trigger alert if both of these doesn't exist or any one from both name should be printed in mail I am sending.
... ... ...
Look at the text marked in red from your post above. Note that the names you are using are inconsistent. If you are looking for a filename with an underscore between claim and today's date, you won't find it using a pattern that does not have an underscore in that position. (Close may count in horseshoes; but not in programming. )
In the below bash I am trying to ensure that all folders (represented by $folders) in a given directory are created. In the file f1 the trimmed folder will be there somewhere (will be multiple trimmed folders).
When that trimmed folder is found (represented by $S5) the the contents of $2 printed... (19 Replies)
The contents of my service file srvtemplate-data-i4-s1.conf is
Description=test service for users
After=network.target local-fs.target
Type=forking
RemainAfterExit=no
PIDFile=/data/i4/srvt.pid
LimitCORE=infinity
EnvironmentFile=%I
.
.
.
WantedBy=multi-user.target (0 Replies)
Hi,
i am using rhel6.4, i lost my directory under /home .is there any way to find the reason how that directory deleted and how to recover deleted folder. (2 Replies)
Hi,
Archive backup log is /oracle_backup/logs .
Since yesterday /logs directory is missing.How to find What has changed since the last time it has worked?
OS -- Linux 2.6 x86_64
Regards,
Maddy (4 Replies)
Hi All,
Below is my requirement.
I want to display the missing files in the directory. Below is my example
From SFTP we are copying 10 files every day. if any files missed on that day need to send a notification with missing files
Test1.dat
20121107_00_file.csv
20121107_01_file.csv... (8 Replies)
My whatis file is missing from my /usr/share/lib directory. I know I can recreate it by using catman -w command.
My question is, why do all of my other servers have it and this one doesn't. Maybe due to a recent move of old to new servers and it just wasn't copied over. Unlikely, 'cause all... (0 Replies)
Hey all,
I'm attempting to migrate a zone from one system to another, but I noticed that on the new system ssl BASEDIR was missing. I was wondering if creating the directory path for this would fix the issue when I migrate files over.
SSL is installed on the new system but does not show a... (1 Reply)
Hi
If there is a file upload done from a remote server
and if the file remains without being extracted for more than an hour,
I need to identify the files and create an alert message to the
users in the other end.
please help me writing a shell script for it.
Regards
Yazhini (2 Replies)