Pls Help: I want to include the date stamp in Subject of mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sanket80
    New Member
    • Nov 2006
    • 19

    Pls Help: I want to include the date stamp in Subject of mail

    Hi,

    I am running an UNIX Shell Script and it sends an output to specific mail id's
    The mail has a subject like below

    cat /path/filename | mailx -s "Here is the List" $MAIL_LIST

    Now this command sends the output along with Subject "Here is the List".
    My requirement is to populate the date stamp in the subject as well so that the user can know the date when the script was run.

    Can somebody pls help with the exact command.
    Thanks
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    You can use the `date` command to insert the timestamp into subject line:

    Code:
    cat  /path/filename | mailx -s "Here is the List `date`" $MAIL_LIST
    If you want to change the default format of the date command you can try something like this:

    Code:
    cat /path/filename | mailx -s "Here is the List date '+%Y-%m-%d %H:%M:%S'" $MAIL_LIST
    Note the back-ticks around the command, they are used to tell the shell to execute this command.
    Try "man date" at the UNIX prompt for more information.

    Comment

    • Sanket80
      New Member
      • Nov 2006
      • 19

      #3
      Thanks...The script is worling fine....

      Originally posted by michaelb
      You can use the `date` command to insert the timestamp into subject line:

      Code:
      cat  /path/filename | mailx -s "Here is the List `date`" $MAIL_LIST
      If you want to change the default format of the date command you can try something like this:

      Code:
      cat /path/filename | mailx -s "Here is the List date '+%Y-%m-%d %H:%M:%S'" $MAIL_LIST
      Note the back-ticks around the command, they are used to tell the shell to execute this command.
      Try "man date" at the UNIX prompt for more information.

      Comment

      • kirukiran
        New Member
        • Mar 2007
        • 1

        #4
        I included date in the follwing way it was not working please help me out
        * * * * * mailx -s "hi kiran - 'date'" [email removed] < create.out
        Last edited by MMcCarthy; Mar 11 '07, 12:43 AM. Reason: email removed - against site rules

        Comment

        Working...