Web lists-archives.com

Re: Adding Date & Time to a script's output log




Le tridi 13 prairial, an CCXXV, SUZANNE COBB a écrit :
> I try to capture the date and time into a variable named 'dt':
> 
> dt= $(date '+%d/%m/%Y %H:%M:%S');
> 
> [please see there is a space between = and $, and between Y and %]

Well, fix it! This line executes the output of date as a command with
the dt environment variable set to an empty string. Variable
affectations do not have spaces around the equal.

Also, for scripting, you will want %Y-%m-%d, because it offers a lexical
order. And for maximum reliability, include the timezone or set it to
UTC. I strongly suggest you just use the ISO date format.

> echo "%dt" "Changed ${DYN_DOMAIN} from ${registeredIp} to ${externalIp}" >> /var/log/updated-ddns.log
        ^
Your detox from windows batch scripting was only partially successful.

Regards,

-- 
  Nicolas George

Attachment: signature.asc
Description: Digital signature