Sponsored Content
Top Forums Shell Programming and Scripting Trigger email from script if the Special Character replacement is successfull Post 302943284 by nanduedi on Thursday 7th of May 2015 04:43:19 AM
Old 05-07-2015
Trigger email from script if the Special Character replacement is successfull

Hello Gurus,

I have a script developed...

Code:
#!/bin/bash
#---------------------------------------------------------------------
# This pScript will remove/replace the special characters fromfiles
#--------------------------------------------------------------------- 
trxdate="`date +%Y%m%d_%H%M%S`"
cd /mnt/G/Inbound/Pre-Prod/GEM/From_O/Scriptprocess
INBOUND=/mnt/G/Inbound/Pre-Prod/GEM/From_O/Scriptprocess
INBOUND2=/mnt/G/Inbound/Pre-Prod/GEM/From_O


CNTS=`ls $INBOUND/ECEPYO.dat | wc -l`
echo "$CNTS"
if (( CNTS == 0 ))
then
echo "file."
else
while [ ${CNTS} -ne 0 ]
do
CURRENTFILE=`ls ECEPYO.dat | head -1` 
echo "$CURRENTFILE"

#	remove/replace the special char
sed -e 's/'/ /g' -e 's/\\/ /g' -e 's/é/ /g' -e 's/Ã//g' -e 's/-/ /g' -e 's/-/-/g' -e 's/Â//g' -e 's/`/ /g' $CURRENTFILE >> $CURRENTFILE.tmp 

#copying file to folder	
cp -p $INBOUND/$CURRENTFILE.tmp $INBOUND2/$CURRENTFILE
#removing the files	
rm $CURRENTFILE
rm $CURRENTFILE.tmp
CNTS=`ls $INBOUND/ECEPYO.dat | wc -l`
echo "$CNTS"
done
fi
exit 0

Here my question is , I have used sed commmand to replace the special characters found in the file, so I want to trigger email (in the email I want to have which special character is replaced) if any of the listed special characters replaced to some email id like : xyz@gmail.com. Also all files will not have special characters , so some may have and some may not have.

Can anyone please help me here.

Thanks
Nandu

Moderator's Comments:
Mod Comment Start using code tags, thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Special Character Check in Shell script

Hi, I'm currently working on a project that requires parsing xml file. One of the field in the xml is shown below (don't remember exactly): <variable="ITEM">12345678</variable> I coded my script keeping in mind that the value denoted in bold will always be a number. After getting just the... (1 Reply)
Discussion started by: mradul_kaushik
1 Replies

2. Shell Programming and Scripting

Character replacement

Hi, I am working on a command that replaces some occurrences of quotation marks in file. The quotation mark cannot be the first or the last character in line and cannot be preceded or followed by a comma. I am not an expert in regular expressions, but I managed to create the following... (2 Replies)
Discussion started by: piooooter
2 Replies

3. Shell Programming and Scripting

Sed-Special character replacement

Hi I want to replace ./testsed.ksh with testsed.ksh ./ is to be removed scriptnm=`sed -e 's/\.///' $0 does not work Please help (3 Replies)
Discussion started by: usshell
3 Replies

4. Shell Programming and Scripting

Script not successfull in cron

Hi, I have a script to FTP the files to other unit. Manually this script is running fine & files are getting transferred. But running the same script using crontab does not transfer files, although the cron log shows that the file was executed. PLz suggest (2 Replies)
Discussion started by: sandeep_kmehra
2 Replies

5. Shell Programming and Scripting

Perl Script Syntax to Extract Everything After Special Character

Hi, I am writing a Perl script that reads in many lines, if a line meets the criteria I want to edit, it. For example, the script will return the following example line... test=abc123 All I want to do is strip off the "test=" and just be left with the abc123. In my script I can easily... (3 Replies)
Discussion started by: edrichard
3 Replies

6. UNIX for Dummies Questions & Answers

banner character replacement

Can we able to replace the character # in banner command with some other characters. Can we able to blink the character in Kornshell (1 Reply)
Discussion started by: sivakumar.rj
1 Replies

7. Shell Programming and Scripting

Use arrow touch in a script shell without special character

Hello, I have a problem when i execute the script underneath. If i tape azerty 123 and i use the arrow touch, in the file /tmp/test i have the caracter #!/usr/bin/ksh clear echo "Taper l adresse IP de la partition a creer :" tput cup 1 48 read Adress echo $Adress echo "${Adress}" >>... (0 Replies)
Discussion started by: khalidou13
0 Replies

8. Shell Programming and Scripting

calling another script if it's contains SUCCESSFULL how?

Hi all, i'm a newbie here, I'm just wondering how can i call my second script if it's contain successfull. script1.sh how can i call my 2nd script if he contain SUCCESSFULL script2.sh SUCCESSFULL please advise, Thanks, (10 Replies)
Discussion started by: nikki1200
10 Replies

9. Shell Programming and Scripting

Shell script question in special character

when I execute the unix commands its works normally in the 1st part. When I the tried the same in shell scripting the directory is not displayed in 2nd part example. please let me know what needs to be done. Unix : client=~zsvdbs echo $client /shome/zsvhome/zsvdbs Using... (3 Replies)
Discussion started by: keerthi2016
3 Replies

10. Shell Programming and Scripting

Special character replacement

Hi Guys, I have a file which needs to be replaced with tab delimited AA§Orgin Name§Mapping based on prod_usa§§§§ BB§Date§2019-08-11 23:30:01§§§§ I am trying below code sed 's// /g' test.txt Expected AA|Orgin Name|Mapping based on prod_usa||| BB|Date|2019-08-11 23:30:01|||| (6 Replies)
Discussion started by: rohit_shinez
6 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 11:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy