Sponsored Content
Top Forums Shell Programming and Scripting Alert for missing file in directory Post 302992174 by Don Cragun on Wednesday 22nd of February 2017 09:56:48 AM
Old 02-22-2017
I don't see any way to guess at what unspecified magic will translate:
Code:
Name in /scripts/data/file_list.ind	Actual name to use
===================================	==========================================================
file.txt				file_claim_(systemdate)_mly.dat
file2.txt				file_claim(systemdate)_mly.bz2
and so on				file_claimSomeStringMaybe(systemdate)_mly.AbsolutelyNoIdea
...					???

And, you have given us no indication of what format is used to display your systemdate... could it be: DayOfWeek, MonthName DayOfMonth, 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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If any file resides for more than an hour in this directory then to raise an alert

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)
Discussion started by: yazhini.t
2 Replies

2. Solaris

Missing Base Directory

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)
Discussion started by: em23
1 Replies

3. Shell Programming and Scripting

Script to send an alert if a file is present in a directory for 10 min

hi, A script which look into a directory and send an alert via a mail. If there is any file exisiting in a directory for more then 10 min. (5 Replies)
Discussion started by: madfox
5 Replies

4. UNIX for Advanced & Expert Users

Solved: Missing whatis file from my /usr/shar/lib directory...

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)
Discussion started by: zixzix01
0 Replies

5. Shell Programming and Scripting

Help need to find out the missing files in the directory

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)
Discussion started by: bbc17484
8 Replies

6. Red Hat

Directory missing

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)
Discussion started by: Maddy123
4 Replies

7. UNIX for Dummies Questions & Answers

Directory missing .how to find the cause .

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)
Discussion started by: sayhirams
2 Replies

8. Shell Programming and Scripting

CLI script for emailing alert if files missing in dir

thread removed (4 Replies)
Discussion started by: billabongjimmy
4 Replies

9. Shell Programming and Scripting

Systemd errors of missing file “No such file or directory” inspite of file being present

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)
Discussion started by: rupeshkp728
0 Replies

10. Shell Programming and Scripting

Bash to check directory and create missing folder from file

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)
Discussion started by: cmccabe
19 Replies
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 11:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy