Append date to an executing script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append date to an executing script
# 1  
Old 08-16-2018
Append date to an executing script

This works except the date being sent to this script.

Is it because I am trying to write to an executing script?

Is there a better way?

Code:
date '+%m-%d-%Y_%I:%M-%p'>> Send_Email.sh
CONTENT="Backup to Maxtor Drive has occured."
echo "Sending email."
/usr/sbin/ssmtp -t << EOF
To: a7@yahoo.com
From: a7@yahoo.com
Subject: Backups to Maxtor Drive


$CONTENT

EOF

------ Post updated at 04:20 PM ------

Code:
#Example of a command substitution to put the date into a variable and put that variable in the body of the mail before or after $CONTENT.
NOW=$(date +%m-%d-%Y_%I:%M%p)
#Date_Of_Backup=date +%m-%d-%Y_%I:%M%p
CONTENT="Backup to Maxtor Drive performed on $NOW ."
echo "Sending email."
/usr/sbin/ssmtp -t << EOF
To: a7@yahoo.com
From: a7@yahoo.com
Subject: Backups to Maxtor Drive 

$CONTENT

EOF

# 2  
Old 08-16-2018
There is an error code for this: ETXTBSY (Linux name) which means you are trying to write to an executable file of whatever type while it is busy running.

I would guess that is what is happening.

Note that the C standard requires only three codes (macros actually) be defined:
EDOM
EILSEQ
ERANGE

Your system may have a different name. Or may enforce the error a different way. Read the files /usr/include/errno.h and /usr/include/sys/errno.h They will list all of the available error "conditions" for your system.

Last edited by jim mcnamara; 08-16-2018 at 07:19 PM..
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append date to sql*plus spool (log) file in shell script

SQL*Plus version : 11.2.0.4 OS : Oracle Linux 6.5 SQL*Plus is a client application to connect to oracle database. The log file for this tool is generated via spool command as shown below. I am trying to append date ( $dateString ) to spool file as shown below. $ cat test2.sh #!/bin/bash... (4 Replies)
Discussion started by: kraljic
4 Replies

2. Shell Programming and Scripting

Error executing date script

Hi, Seen below is a simple date script. #! /bin/ksh VL = `date +%m/%d` VL1 = `TZ=GMT+24 date +%m/%d` VL2 = `TZ=GMT+48 date +%m/%d` VL3 = `TZ=GMT+72 date +%m/%d` VL4 = `TZ=GMT+96 date +%m/%d` VL5 = `TZ=GMT+120 date +%m/%d` echo $VL echo $VL1 echo $VL2 echo $VL3 echo $VL4 echo... (2 Replies)
Discussion started by: jayadanabalan
2 Replies

3. Shell Programming and Scripting

Perl:Script to append date and time stamp

Help with Perl script : I have a web.xml file with a line <display-name>some_text_here</display-name> Need to append the current date and time stamp to the string and save the XML file Something like <display-name>some_text_here._01_23_2014_03_56_33</display-name> -->Finally want... (5 Replies)
Discussion started by: gaurav99
5 Replies

4. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

5. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

6. Programming

Date time problem while executing perl script.

Hi All, This Monday 15th March 2010, i have faced a weired issue with my Perl script execution, this script is scheduled to run at 1 minute past midnight on daily basis ( 00:01 EST ) generally for fetching previous business date , say if it is Monday it should give last Friday date, for Tuesday... (0 Replies)
Discussion started by: ravimishra
0 Replies

7. Shell Programming and Scripting

append date time stamp via ftp script

I have searched several thread and not found my solution, so I am posting a new qustion. I have a very simple script on an AIX server that FTPs 2 files to a MS FTP server. These 2 files are created on the AIX server every hour, with a static name. I need to FTP the files to the MS server, but... (1 Reply)
Discussion started by: sknisely
1 Replies

8. Shell Programming and Scripting

append date to file

Hi I need to append date to filename.Wrote script to get the date from table ,take this date filed and append to my i/p file when call the below script.Any help should be appreciated . Exampel If call the below script a4.sh filename o/p should be filename.2008-02-29 .... (6 Replies)
Discussion started by: mohan705
6 Replies

9. Shell Programming and Scripting

Need a script to Append date to generated .txt file

Hi, Can anyone plz share their experience with - Building shell script to append the file with date in following format- Filename_MMDDYYYY.txt Thanks in advance (2 Replies)
Discussion started by: prince_of_focus
2 Replies

10. UNIX for Dummies Questions & Answers

Append date to filename

What is the easiest way to append the date (year, month, day) to a filename? (5 Replies)
Discussion started by: hshapiro
5 Replies
Login or Register to Ask a Question