Sponsored Content
Top Forums Shell Programming and Scripting Nohup apending data each time i run script Post 302978948 by mirwasim on Saturday 6th of August 2016 03:07:29 PM
Old 08-06-2016
Dear Don,

Thanks for your time and i am sorry if i am not able to provide adequate information sometime.
below is my script, input file which is getting generated within a script and out file which is messed up, taking date and time twice also is taking output.
i dont know where it is saving the old information
Main script which i am running in nohup.
each time i am running it is appending information.
Code:
DATE_1=`date | awk '{print $2,$3,$4}'`
SCRIPT_NAME_1="ACCOUNT INQUIRY FOR MOBILE"

##i remove all the files in the begning of the script before it run

cd /location
> acc_inq_mob.csv

cd path


sh /path/jmeter -n -t path/jmeter.jmx -l log.jtl ## this script i am calling here and all the log which it create i am doing further scripting on that

nawk -F, '/false/ && match ($0, /http:\/\/[^\/]*\/[^\/]*/) {print $3, substr ($0, RSTART, RLENGTH)}' log.jtl > ERROR_FILE.log

nawk '!/ACCOUNT_ID/' /path/acc_inq_mob.csv   > path/acc_inq_mob.log

nawk '{gsub (/<[^>]*>/,_);sub (/\/[^\/]*$/, _, $1); print $1}' FS="[?;]" acc_inq_mob.log > acc_inq_output1.log
cut -d',' -f3 acc_inq_output1.log > acc_inq_output.log


DATE_END_1=`date | awk '{print $2,$3,$4}'`

echo "<html>" >> date.html
echo "<Body>" >> date.html
echo "<table border="1">" >> date.html
echo "<tr>" >> date.html
echo "<td colspan="0" bgcolor="#7FFFD4">" >> date.html
echo "START_DATE : " $DATE_1  >> date.html ## start time details
echo "</td>" >> date.html
echo "</tr>" >> date.html
echo "</table>" >> date.html
echo "</Body>" >> date.html
echo "</html>" >> date.html
echo "<br />"  >> date.html

echo "<html>" >> date_end.html
echo "<Body>" >> date_end.html
echo "<table border = "1">" >> date_end.html
echo "<tr>" >> date_end.html
echo "<td colspan="0" bgcolor="#7FFFD4">"  >> date_end.html
echo "END_DATE:      " $DATE_END_1  >> date_end.html ## END time details
echo "</td>" >> date_end.html
echo "</tr>" >> date_end.html
echo "</table>" >> date_end.html
echo "</Body>" >> date_end.html
echo "</html>" >> date_end.html
echo "<br />"  >> date_end.html
echo "<br />"  >> date_end.html

echo "<br />"  >> SUCCESS.html
echo "<html>" >> SUCCESS.html
echo "<Body>" >> SUCCESS.html
echo "<table border = "1">" >> SUCCESS.html
echo "<tr>" >> SUCCESS.html
echo "<td colspan="0" bgcolor="#008000">"  >> SUCCESS.html
echo "<b>" >> SUCCESS.html
echo "<font color = "#FFFFFF">" >> SUCCESS.html
echo "SUCCESS RESULT" >> SUCCESS.html ## PRINTS SUCCESS TAG
echo "</font>" >> SUCCESS.html
echo "</b>" >> SUCCESS.html
echo "</td>" >> SUCCESS.html
echo "</tr>" >> SUCCESS.html
echo "</table>" >> SUCCESS.html
echo "</Body>" >> SUCCESS.html
echo "</html>" >> SUCCESS.html
echo "<br />"  >> SUCCESS.html

echo "<br />"  >> ERROR.html
echo "<html>" >> ERROR.html
echo "<Body>" >> ERROR.html
echo "<table border = "1">" >> ERROR.html
echo "<tr>" >> ERROR.html
echo "<td colspan="0" bgcolor="#FF0000">" >> ERROR.html
echo "<b>" >> ERROR.html
echo "<font color = "#FFFFFF">" >> ERROR.html
echo "ERROR RESULT" >> ERROR.html ## PRINTS ERROR TAG
echo "</font>" >> ERROR.html
echo "</b>" >> ERROR.html
echo "</td>" >> ERROR.html
echo "</tr>" >> ERROR.html
echo "</table>" >> ERROR.html
echo "</Body>" >> ERROR.html 
echo "</html>" >> ERROR.html
echo "<br />"  >> ERROR.html


echo "<br />"  >> output.html
echo "<html>" >> output.html
echo "<Body>" >> output.html
nawk 'BEGIN{print "<table border="1">"} 
          {print "<tr>";
                  for(i=1;i<=NF;i++)print "<td>" $i"</td>";
                  print "</tr>"} END{print "</table>"}' acc_inq_output.log >> output.html ##URLs with ports which are euccessfully tested
echo "</Body>" >> output.html
echo "</html>" >> output.html
echo "<br />"  >> output.html


echo "<html>" >> ERROR_FILE.html
echo "<Body>" >> ERROR_FILE.html
nawk 'BEGIN{print "<table border="1">"}
       {print "<tr>";
       print "<TD>";
       for(i=1;i<NF;i++) printf("%s ",  $i);
       print "</TD>";
       print "<TD>" $NF "</TD>";
       print "</tr>"}
     END{print "</table>"}'  ERROR_FILE.log >> ERROR_FILE.html

echo "</Body>" >> ERROR_FILE.html
echo "</html>" >> ERROR_FILE.html

COUNT_ERROR_FILE=`wc -l ERROR_FILE.log  |sed 's/\|/ /'|awk '{print $1}'`

FROM="server"
SUBJECT="SANITY TEST RESULT FOR $SCRIPT_NAME_1"
ATTACH1="/path/ERROR_FILE.html"
ATTACH2="/path/date.html"
ATTACH3="/path/date_end.html"
ATTACH4="/path/SUCCESS.html"
ATTACH5="/path/ERROR.html"
ATTACH6="/path/output.html"
ATTACH_NAME1=${ATTACH1##*/}
MAILTO="email@gmail.com"
##CC="email@gmail.com"


if [  $COUNT_ERROR_FILE -eq 0 ]
then
(
 echo "From: $FROM"
 echo "To: $MAILTO"
 echo "CC: $CC"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat "$ATTACH2" 
 echo
 cat "$ATTACH3"
 echo
 cat "$ATTACH4"
 echo
  cat "$ATTACH6"
 echo
) | /usr/sbin/sendmail $MAILTO $CC
exit
else
(
 echo "From: $FROM"
 echo "Cc: $CC"
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo
 cat "$ATTACH2" 
 echo
 cat "$ATTACH3"
 echo
 echo 
 cat "$ATTACH5"
 echo 
 cat "$ATTACH1"
 echo
 cat "$ATTACH4"
 echo
 cat "$ATTACH6"
 echo
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'${ATTACH_NAME1}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH_NAME1}'"'
 echo
 uuencode $ATTACH1 $ATTACH1
 echo
) | /usr/sbin/sendmail $MAILTO $CC
fi

output it is giving statrt time . it have created more that 2 also

Code:
<html>
<Body>
<table border=1>
<tr>
<td colspan=0 bgcolor=#7FFFD4>
START_DATE :  Aug 6 22:34:22
</td>
</tr>
</table>
</Body>
</html>
<br />
<html>
<Body>
<table border=1>
<tr>
<td colspan=0 bgcolor=#7FFFD4>
START_DATE :  Aug 6 22:35:12
</td>
</tr>
</table>
</Body>
</html>
<br />

output end time
Code:
<html>
<Body>
<table border = 1>
<tr>
<td colspan=0 bgcolor=#7FFFD4>
END_DATE:       Aug 6 22:34:35
</td>
</tr>
</table>
</Body>
</html>
<br />
<br />
<html>
<Body>
<table border = 1>
<tr>
<td colspan=0 bgcolor=#7FFFD4>
END_DATE:       Aug 6 22:35:23
</td>
</tr>
</table>
</Body>
</html>
<br />
<br />

it is also giving data output repeatedly

my input file
Code:
cc_inq_mob.csv

Code:
1,1,http://abc:123/defd/FixedAccInquiryAction.do?accountId=123456&fromCMS=null&operation=3&searchPage=SOHACCOUNTIDINQ
1,1,http://abc:345/defh/FixedAccInquiryAction.do?accountId=123456&fromCMS=null&operation=3&searchPage=SOHACCOUNTIDINQ

please advise
sorry for the trouble
Nohup apending data each time i run script-capturejpg

Last edited by mirwasim; 08-06-2016 at 04:10 PM.. Reason: insert image
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run script at same time

Hi My five script run throgh crontab at same time at 6 clock. Due to problem in the data load .Now I want to check time of load finish run these jobs. I create a script which check the load finish time but I have no idea how I run these JObs. This is very urget to me. Please reply me as soon... (3 Replies)
Discussion started by: Jamil Qadir
3 Replies

2. Shell Programming and Scripting

run script for given time

Hi! I need to run my script for a specific number of time, as specified by the user: For instance, if the user specified 10, my script should run for until 10 seconds expire. How do I do this? (0 Replies)
Discussion started by: looza
0 Replies

3. Shell Programming and Scripting

last run time of any script

how to find when last time a scrit has ran? (7 Replies)
Discussion started by: RahulJoshi
7 Replies

4. Shell Programming and Scripting

Run Script With nohup Command On A Different Server

Hi, I want to run a particular script present in a different server. At the moment I am trying to run it like this: (sleep 3; echo $USERID; sleep 1; echo $PASSWORD ; sleep 1 ; sleep 1 ; echo "nohup perl myscript.pl $* &")| telnet "$server" But the problem is that once the script has... (6 Replies)
Discussion started by: King Nothing
6 Replies

5. UNIX for Dummies Questions & Answers

Run process with nohup every certain time

Hi, I need execute a script every 30 minutes. As might be done without using cron Thx. (6 Replies)
Discussion started by: pepeli30
6 Replies

6. Shell Programming and Scripting

run shell script under nohup directly [solved]

Hi, i am not able to run the loop in nohup directly. nohup 'for i in $(seq 10); do echo $i;./mscript.sh $i; done' can some one help me how to run this directly in nohup? ---------- Post updated 03-15-12 at 12:20 AM ---------- Previous update was 03-14-12 at 11:59 PM ---------- From... (0 Replies)
Discussion started by: johninweb
0 Replies

7. Shell Programming and Scripting

Time taken to run a SQL script

Hello I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries (2 Replies)
Discussion started by: vat1kor
2 Replies

8. Shell Programming and Scripting

Run a task in a script at a particular time

I have an ETL process that triggers a shell script. This script picks the files created by the ETL process and does an SFTP. These are huge files. Due to infrastructure limitations, we need to trigger the actual SFTP part only during the 2nd, 16th, 31st and 46th minute of an hour. Please let me... (2 Replies)
Discussion started by: vskr72
2 Replies

9. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

10. UNIX for Beginners Questions & Answers

Shell Script to run in given time

Hi All, Would like to write a Script which will run between 11am to 3 pm and send the results to output.txt. Please suggest. (2 Replies)
Discussion started by: vasuvv
2 Replies
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy