Script to check file in two directories using two scripts and send the results via e-mail to the user
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:
strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename
file core.14945
if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.
To accomplish this, I have created a shell script that will do the ff.
- Variable storage (environment and directories)
- Go to the 1st directory
- Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.
- Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).
- Go to 2nd directory
- Repeat steps 3 and 4
- Email the results
Now, here's my problem:
- I want to log the results in a text file when core files doesn't exist.
(ex. ci_core_log_%sysdate%.txt)
some core files exist in a subdirectory within directory 1 or 2
(ex. folder name: core_*)
Tried to use this statement:
mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"
Result: it was sent to dvadmin@yahoo.com
,kn3jer@yahoo.com
, and -r@mwa00.localdomain
Expected result: dvadmin@yahoo.com
,kn3jer@yahoo.com
Tried to use this instead: mail -s "Core files exist in DV" kn3jer@yahoo.com
Result: it was sent to kn3jer@yahoo.com
but the sender is dvadmin@mwa00.localdomain
I just want it to be sent to kn3jer@yahoo.com
and the sender will be dvadmin@yahoo.com
.
Can you please help me address these issues I have? My code is pasted here!
Many thanks!
shell-script email
add a comment |Â
up vote
0
down vote
favorite
I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:
strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename
file core.14945
if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.
To accomplish this, I have created a shell script that will do the ff.
- Variable storage (environment and directories)
- Go to the 1st directory
- Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.
- Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).
- Go to 2nd directory
- Repeat steps 3 and 4
- Email the results
Now, here's my problem:
- I want to log the results in a text file when core files doesn't exist.
(ex. ci_core_log_%sysdate%.txt)
some core files exist in a subdirectory within directory 1 or 2
(ex. folder name: core_*)
Tried to use this statement:
mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"
Result: it was sent to dvadmin@yahoo.com
,kn3jer@yahoo.com
, and -r@mwa00.localdomain
Expected result: dvadmin@yahoo.com
,kn3jer@yahoo.com
Tried to use this instead: mail -s "Core files exist in DV" kn3jer@yahoo.com
Result: it was sent to kn3jer@yahoo.com
but the sender is dvadmin@mwa00.localdomain
I just want it to be sent to kn3jer@yahoo.com
and the sender will be dvadmin@yahoo.com
.
Can you please help me address these issues I have? My code is pasted here!
Many thanks!
shell-script email
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:
strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename
file core.14945
if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.
To accomplish this, I have created a shell script that will do the ff.
- Variable storage (environment and directories)
- Go to the 1st directory
- Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.
- Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).
- Go to 2nd directory
- Repeat steps 3 and 4
- Email the results
Now, here's my problem:
- I want to log the results in a text file when core files doesn't exist.
(ex. ci_core_log_%sysdate%.txt)
some core files exist in a subdirectory within directory 1 or 2
(ex. folder name: core_*)
Tried to use this statement:
mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"
Result: it was sent to dvadmin@yahoo.com
,kn3jer@yahoo.com
, and -r@mwa00.localdomain
Expected result: dvadmin@yahoo.com
,kn3jer@yahoo.com
Tried to use this instead: mail -s "Core files exist in DV" kn3jer@yahoo.com
Result: it was sent to kn3jer@yahoo.com
but the sender is dvadmin@mwa00.localdomain
I just want it to be sent to kn3jer@yahoo.com
and the sender will be dvadmin@yahoo.com
.
Can you please help me address these issues I have? My code is pasted here!
Many thanks!
shell-script email
I have a requirement that intends to check if core files are available in two directories and get its details using the ff. scripts:
strings core.14945 | grep "pmdtm(" #core.14945 is a sample filename
file core.14945
if no details, or blank will be returned on script 1, script 2 will be used. If core files do not exist in both directories, it will just log it on a text file. Otherwise, it will send an email to the users with the core file details.
To accomplish this, I have created a shell script that will do the ff.
- Variable storage (environment and directories)
- Go to the 1st directory
- Variable storage (count of core files, script 1, script 2): these were stored so it's easy for me to look at on the next statements.
- Nested IFs (check count, script 1, if blank is returned, script 2 will be used, if no core files found, a msg will be printed).
- Go to 2nd directory
- Repeat steps 3 and 4
- Email the results
Now, here's my problem:
- I want to log the results in a text file when core files doesn't exist.
(ex. ci_core_log_%sysdate%.txt)
some core files exist in a subdirectory within directory 1 or 2
(ex. folder name: core_*)
Tried to use this statement:
mail -s "Core files exist in DV" kn3jer@yahoo.com -r "dvadmin@yahoo.com"
Result: it was sent to dvadmin@yahoo.com
,kn3jer@yahoo.com
, and -r@mwa00.localdomain
Expected result: dvadmin@yahoo.com
,kn3jer@yahoo.com
Tried to use this instead: mail -s "Core files exist in DV" kn3jer@yahoo.com
Result: it was sent to kn3jer@yahoo.com
but the sender is dvadmin@mwa00.localdomain
I just want it to be sent to kn3jer@yahoo.com
and the sender will be dvadmin@yahoo.com
.
Can you please help me address these issues I have? My code is pasted here!
Many thanks!
shell-script email
edited Apr 18 at 15:23
Jeff Schaller
31.1k846105
31.1k846105
asked Apr 18 at 15:00
Jerome Sabareza
33
33
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438530%2fscript-to-check-file-in-two-directories-using-two-scripts-and-send-the-results-v%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password