close journal file read-only [message #79034] |
Mon, 23 January 2012 12:57  |
Bringfried Stecklum
Messages: 75 Registered: January 1996
|
Member |
|
|
I guess many of us log their IDL session to keep track of the work. My question
is whether it is possible to close the log file and make it read-only from
within IDL? The journal command lacks a corresponding option. I just want to
avoid that the file is being deleted/changed later on by accident.
If this cannot be done by IDL itself, I have to come up with a cronjob that
checks the log folder for closed files which are still writable, and changes
their attribute.
Regards, Bringfried
|
|
|
|
|
|
|
Re: close journal file read-only [message #79130 is a reply to message #79034] |
Wed, 01 February 2012 05:20   |
bstecklu
Messages: 14 Registered: February 2012
|
Junior Member |
|
|
On Jan 23, 9:57 pm, Bringfried Stecklum <steck...@tls-tautenburg.de>
wrote:
> I guess many of us log their IDL session to keep track of the work. My question
> is whether it is possible to close the log file and make itread-onlyfrom
> within IDL? Thejournalcommand lacks a corresponding option. I just want to
> avoid that the file is being deleted/changed later on by accident.
>
> If this cannot be done by IDL itself, I have to come up with a cronjob that
> checks the log folder for closed files which are still writable, and changes
> their attribute.
>
> Regards, Bringfried
Well, although the interest in the question was not particularly
overwhelming,
below is my IDL exit procedure which answers the question
; close journal, make it read-only, and exit
pro myexit
; get file name for journal unit
help,/files,!journal,out=out
; omit IDL string treatment
spawn,'echo '+out[1]+"| awk '{printf $8}'",file
ans="N"
read,"Really close journal and exit? y/N ",ans
if (ans eq "y") or (ans eq "Y") then begin
journal
file_chmod,file,a_write=0
exit
end
end
|
|
|
Re: close journal file read-only [message #79201 is a reply to message #79112] |
Fri, 03 February 2012 01:04  |
bstecklu
Messages: 14 Registered: February 2012
|
Junior Member |
|
|
David Fanning wrote:
> Heinz Stege writes:
>
>> My experience with an exit-replacement was, that it is hard to change
>> one's habit of typing "exit" to finish the session. I bet, you will
>> type "exit" instead of "myexit" several times...
>
> Yes, the Useability Index score might go up if you
> just choose a good filename to begin with:
>
> Journal, 'j'+ timestamp() + '.log'
>
> Then you could batch process all your log files to
> read-only status any time you thought it might be
> a good idea.
>
> Cheers,
>
> David
>
I am using this filename scheme anyway. I agree that changing the habit from
"exit" to "myexit" might not be that easy. Another possibility is to wrap the
IDL command with a bash script that changes the logfile to read-only after the
session was closed. This would also work if IDL crashed or was killed.
cheers, Bringfried
|
|
|