Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script to send data
#1
Hi All,

I am newbie to Unix and Shell script and Python. Can you please help me to write a Python script.

Below is my requirement.

1.Send in email every 15 minutes from 12 to 3:30 PM. It has to create a backup files from 12- 3:30

E-mail should only be sent ONLY when below Query have data return else need to raise an exception " there is no data"

Query : SELECT * from EMP where DEPT = 87;

2. Email format:
To: xyz
From: abc
Email Subject:
Email content: <data return from below query>

Thanks.

I have written a code in UNIX. Anyways that code is not working. Below is my code.Please look into the code and hemp me to write it in both Shell and Python.
</code>
</code>
FILE="EMP_DETAILS.txt"
#FILE="EMP_DETAILS.$(date +%F_%R).txt"
#touch $FILE

echo $ORACLE_HOME/bin/sqlplus
echo "======== START ============="

#$ORACLE_HOME/bin/sqlplus -s scott/tiger@XE <<EOF
RESULT=`$ORACLE_HOME/bin/sqlplus -silent ${DB_USER}/${DB_DECRYPTED_PASSWORD}@${DB_CONNECTION_STRING} <<ENDA

set pagesize 0 feedback off verify off heading off echo off
column last_business_date format date
SELECT * from EMP where DEPT = 87;

exit;
ENDA`

echo $RESULT > $FILE
#sed -i 's/#^/\n/g' $FILE
sed '/#^/G' $FILE
echo "======== END ============="


## READ AND WRITE THE FILE AND TOOK THE BACKUP
#
#FILE1="EMP_DETAILS.$(date +%F_%R).txt"
#{
# while IFS= read -r line
#do
# shnfix "$line"
# done < "$FILE1"
#} > "emp.backup.$(date +%F_%R).txt"

##this will fetch the number of lines in the file
#wc -l $FILE1
#if [wc -gt 0]; then
mail -s "!!! WARNING File" << $EMP_DETAILS.txt
echo "The IDL processing has been completed for Business date $BUSINESS_DATE." | mail -s "IDL Processing Status $env" "[email protected]" -- -r "robin@gmail";
#fi
</code>
Reply
#2
just full quote of OP
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  script to calculate data in csv-files ledgreve 0 1,093 May-19-2023, 07:24 AM
Last Post: ledgreve
  How to send data from a python application to an external application aditya_rajiv 1 2,173 Jul-26-2021, 06:00 AM
Last Post: ndc85430
  python script fails with a lot of data bluethundr 2 2,139 Nov-11-2019, 01:35 PM
Last Post: bluethundr
  Is this possible in Python? Auto-Send-to-printer on script run? pcsailor 8 16,864 Jul-19-2019, 09:33 AM
Last Post: perfringo
  waiting for the first of many pipes to send data Skaperen 7 3,982 May-05-2019, 10:57 PM
Last Post: Skaperen
  Data Validation script in python Tulsi 1 4,076 Jul-17-2018, 03:54 PM
Last Post: Tulsi
  Send and receive Files(data/images) betwenn a python app and another appl Akhou 2 3,934 May-02-2018, 08:20 AM
Last Post: Akhou
  sending data to second python script Cyberfly 1 3,152 Jan-29-2018, 10:09 AM
Last Post: Cyberfly

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020