{"id":306,"date":"2009-02-13T11:46:34","date_gmt":"2009-02-13T10:46:34","guid":{"rendered":"http:\/\/marcoratto.co.uk\/blog\/?p=306"},"modified":"2009-02-13T11:46:34","modified_gmt":"2009-02-13T10:46:34","slug":"scripting-leggere-la-data-odierna","status":"publish","type":"post","link":"https:\/\/marcoratto.it\/blog\/programming\/vbscript\/scripting-leggere-la-data-odierna\/","title":{"rendered":"Scripting: Leggere la data odierna"},"content":{"rendered":"<p>Mentre stavo preparando degli script di amministrazione per Windows e per Linux, mi sono imbattuto nel seguente problema:<\/p>\n<p>Come faccio a leggere il giorno della settimana (1-7=Luned\u00ec-Domenica) ? Questo perch\u00e8 volevo creare un file di log a rotazione settimanale del tipo <em>&#8220;nomefile_[1-7].log&#8221;<\/em>.<\/p>\n<p>Su Unix\/Linux mi sono trovato a scrivere nella shell i seguenti comandi:<\/p>\n<p><strong>DayOfWeekNum=`date +%w`<\/strong><\/p>\n<p><strong>LOG_FILE=\/var\/log\/updateTime_${DayOfWeekNum}.log<\/strong><\/p>\n<p>In Windows mi sono imbattuto in un problema quasi impossibile, il <em>&#8220;porkaround&#8221;<\/em> (leggi come schifoso <em>&#8220;workaround&#8221;<\/em>) a cui mi sono dovuto adeguare \u00e8 il seguente:<\/p>\n<p><strong>@echo off<br \/>\nREM Create a temporary VBS script<br \/>\nset vbsfile=c:tempupdateTime.vbs<br \/>\necho currentDate = Now&gt;%vbsfile%<br \/>\necho WeekDayNumber = Weekday(currentDate)&gt;&gt;%vbsfile%<br \/>\necho Wscript.Echo WeekDayNumber&gt;&gt;%vbsfile%<\/p>\n<p>REM Store output of vbs script in variables<br \/>\nfor \/f %%A in (&#8216;cscript \/\/nologo %vbsfile%&#8217; ) do (<br \/>\nset DayOfWeekNum=%%A<br \/>\n)<br \/>\ndel \/s\/q %vbsfile%<br \/>\n<\/strong><br \/>\n<strong>set LOG_FILE=c:logupdateTime_%DayOfWeekNum%.log<br \/>\n<\/strong><\/p>\n<p>Bello vero ?<\/p>\n<p>Meno male che esiste Linux!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mentre stavo preparando degli script di amministrazione per Windows e per Linux, mi sono imbattuto nel seguente problema: Come faccio a leggere il giorno della settimana (1-7=Luned\u00ec-Domenica) ? Questo perch\u00e8 volevo creare un file di log a rotazione settimanale del tipo &#8220;nomefile_[1-7].log&#8221;. Su Unix\/Linux mi sono trovato a scrivere nella shell i seguenti comandi: DayOfWeekNum=`date [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100,115,74,82],"tags":[],"class_list":["post-306","post","type-post","status-publish","format-standard","hentry","category-c-shell","category-linux","category-vbscript","category-windows"],"_links":{"self":[{"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/posts\/306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/comments?post=306"}],"version-history":[{"count":0,"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/posts\/306\/revisions"}],"wp:attachment":[{"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/media?parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/categories?post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marcoratto.it\/blog\/wp-json\/wp\/v2\/tags?post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}