Command to save command history

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Command to save command history

Ian McCallion
Is there an Octave command to save the command history?.History is
saved when Octave terminates normally, but all history accumulated
since the last startup is lost if Octave crashes or is killed.

The reason for asking is that Octave 5.2.0 on windows crashes
frequently, especially when using plotting. During development it is
easily possible to request plots that go into a loop and hang. Ctrl-C
is ineffective at that point and the only solution is to use the task
manager to kill Octave and restart it.

I can put up with having to restart Octave occasionally, but it is a
real pain to lose the history and have to reopen all the files that
were open in the editor.

A command to save history (and list of open files) would save a lot of
frustration.

Cheers... Ian


Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

marco atzeri-2
On Mon, Jul 27, 2020 at 12:59 PM Ian McCallion wrote:

>
> Is there an Octave command to save the command history?.History is
> saved when Octave terminates normally, but all history accumulated
> since the last startup is lost if Octave crashes or is killed.
>
> The reason for asking is that Octave 5.2.0 on windows crashes
> frequently, especially when using plotting. During development it is
> easily possible to request plots that go into a loop and hang. Ctrl-C
> is ineffective at that point and the only solution is to use the task
> manager to kill Octave and restart it.
>
> I can put up with having to restart Octave occasionally, but it is a
> real pain to lose the history and have to reopen all the files that
> were open in the editor.
>
> A command to save history (and list of open files) would save a lot of
> frustration.
>
> Cheers... Ian
>
Hi Ian,
you can use diary
https://octave.org/doc/v5.2.0/Diary-and-Echo-Commands.html#Diary-and-Echo-Commands


Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

mmuetzel
In reply to this post by Ian McCallion
Am 27. Juli 2020 um 12:59 Uhr schrieb "Ian McCallion":

> Is there an Octave command to save the command history?.History is
> saved when Octave terminates normally, but all history accumulated
> since the last startup is lost if Octave crashes or is killed.
>
> The reason for asking is that Octave 5.2.0 on windows crashes
> frequently, especially when using plotting. During development it is
> easily possible to request plots that go into a loop and hang. Ctrl-C
> is ineffective at that point and the only solution is to use the task
> manager to kill Octave and restart it.
>
> I can put up with having to restart Octave occasionally, but it is a
> real pain to lose the history and have to reopen all the files that
> were open in the editor.
>
> A command to save history (and list of open files) would save a lot of
> frustration.
>
> Cheers... Ian
>

doc history

-w file
Write the current history to the file file. If the name is omitted, use the default history file (normally ~/.octave_hist).

HTH,
Markus



Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

Ian McCallion
In reply to this post by marco atzeri-2
On Monday, 27 July 2020, marco atzeri <[hidden email]> wrote:
On Mon, Jul 27, 2020 at 12:59 PM Ian McCallion wrote:
>
> Is there an Octave command to save the command history?.History is
> saved when Octave terminates normally, but all history accumulated
> since the last startup is lost if Octave crashes or is killed.
>
> The reason for asking is that Octave 5.2.0 on windows crashes
> frequently, especially when using plotting. During development it is
> easily possible to request plots that go into a loop and hang. Ctrl-C
> is ineffective at that point and the only solution is to use the task
> manager to kill Octave and restart it.
>
> I can put up with having to restart Octave occasionally, but it is a
> real pain to lose the history and have to reopen all the files that
> were open in the editor.
>
> A command to save history (and list of open files) would save a lot of
> frustration.
>
> Cheers... Ian
>
Hi Ian,
you can use diary
https://octave.org/doc/v5.2.0/Diary-and-Echo-Commands.html#Diary-and-Echo-Commands

I didn't make it clear, but I want to be able to recall the commands using up and down arrow so diary does not do it for me.

In truth I can't see any reason why command history and open file are not kept up-to-date at the end of every command.

Cheers... Ian


Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

Somtochukwu Anene
In reply to this post by Ian McCallion
Please, I would like to unsubscribe from getting mails

Best regards,
Somtochukwu Anene

On Mon, 27 Jul 2020, 11:59 Ian McCallion, <[hidden email]> wrote:
Is there an Octave command to save the command history?.History is
saved when Octave terminates normally, but all history accumulated
since the last startup is lost if Octave crashes or is killed.

The reason for asking is that Octave 5.2.0 on windows crashes
frequently, especially when using plotting. During development it is
easily possible to request plots that go into a loop and hang. Ctrl-C
is ineffective at that point and the only solution is to use the task
manager to kill Octave and restart it.

I can put up with having to restart Octave occasionally, but it is a
real pain to lose the history and have to reopen all the files that
were open in the editor.

A command to save history (and list of open files) would save a lot of
frustration.

Cheers... Ian




Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

nrjank
Administrator
In reply to this post by Ian McCallion
I didn't make it clear, but I want to be able to recall the commands using up and down arrow so diary does not do it for me.

In truth I can't see any reason why command history and open file are not kept up-to-date at the end of every command.

ok, so history is only recorded to file at the end of the Octave session and a crash precludes this information being saved?  I agree that it would be useful if it was saved more frequently.  not sure what the overhead involved in that change would be, but it could definitely be made a wish-list request on the bug tracker:  bugs.octave.org.  


Reply | Threaded
Open this post in threaded view
|

frequent windows crashes, especially with plotting?

nrjank
Administrator
In reply to this post by Ian McCallion
The reason for asking is that Octave 5.2.0 on windows crashes
frequently, especially when using plotting. During development it is
easily possible to request plots that go into a loop and hang. Ctrl-C
is ineffective at that point and the only solution is to use the task
manager to kill Octave and restart it.


This is actually a separate important issue.  I've been running Octave on Windows and very rarely suffer crashes like you describe.  I've edited the subject line to start a separate thread on the discussion. Could you provide feedback on the following:

- Can you summarize what you're doing that results in frequent crashes? Is it repeatable? 

- Are you ever getting an actual 'crash' that exits without your intervention, or is it always a program 'hang' where everything becomes unresponsive? 

- We've previously seen issues where windows plotting can take an inordinate amount of time.  Have you ever waited a long time to see if control returns? 

- Did you install Octave from the executable or one of the zip-packages? if teh latter did you follow the post-install instructions? 


Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

Doug Stewart-4
In reply to this post by Ian McCallion


On Mon, Jul 27, 2020 at 6:59 AM Ian McCallion <[hidden email]> wrote:
Is there an Octave command to save the command history?.History is
saved when Octave terminates normally, but all history accumulated
since the last startup is lost if Octave crashes or is killed.

The reason for asking is that Octave 5.2.0 on windows crashes
frequently, especially when using plotting. During development it is
easily possible to request plots that go into a loop and hang. Ctrl-C
is ineffective at that point and the only solution is to use the task
manager to kill Octave and restart it.

I can put up with having to restart Octave occasionally, but it is a
real pain to lose the history and have to reopen all the files that
were open in the editor.

May I respectfully suggest that you should be using script files for your work.
I taught all my students to do all their work in script files, as then they have a
 record of what they did , and in what order they did it. Much easier for me to 
see what they did wrong and to help them.

In your case if it does crash then you still have the script files.
If your system has many steps then break it up into different files
so that you only have to rerun the last part if there is a crash.




 
A command to save history (and list of open files) would save a lot of
frustration.

Cheers... Ian




--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

Ian McCallion
 
May I respectfully suggest that you should be using script files for your work.
I taught all my students to do all their work in script files, as then they have a
 record of what they did , and in what order they did it. Much easier for me to 
see what they did wrong and to help them.

In your case if it does crash then you still have the script files.
If your system has many steps then break it up into different files
so that you only have to rerun the last part if there is a crash.

Agreed. I create scripts when something is right. Before that I rely on command history.

Cheers... Ian



Reply | Threaded
Open this post in threaded view
|

Re: frequent windows crashes, especially with plotting?

nrjank
Administrator
In reply to this post by nrjank
On Mon, Jul 27, 2020 at 1:06 PM Ian McCallion <[hidden email]> wrote:
On Mon, 27 Jul 2020 at 16:19, Nicholas Jankowski <[hidden email]> wrote:
>>
>> The reason for asking is that Octave 5.2.0 on windows crashes
>> frequently, especially when using plotting. During development it is
>> easily possible to request plots that go into a loop and hang. Ctrl-C
>> is ineffective at that point and the only solution is to use the task
>> manager to kill Octave and restart it.
>>
>
> This is actually a separate important issue.  I've been running Octave on Windows and very rarely suffer crashes like you describe.  I've edited the subject line to start a separate thread on the discussion. Could you provide feedback on the following:
>
> - Can you summarize what you're doing that results in frequent crashes? Is it repeatable?

I think it is repeatable, though for obvious reasons I have not actually tried!

> - Are you ever getting an actual 'crash' that exits without your intervention, or is it always a program 'hang' where everything becomes unresponsive?

Probably not, I don't recall directly.

> - We've previously seen issues where windows plotting can take an inordinate amount of time.  Have you ever waited a long time to see if control returns?

I think this might be the explanation. I waited long enough once for
Octave to stop hogging a CPU core and for gnuplot to start processing.
At that point closing the gnuplot window using the X in the top right
corner, and once that was done the command completed.

Simple x-y plots even with a million points are very fast. Sometimes I
plot two or more curves on the same graph and this is fast too
provided I get it right, but mistakes in this are where the problem
lies.Having just done a couple of experiments I realise I am
inadvertently asking Octave to combine the vectors into points in a
space and draw lines from one to the other. e.g.

plot([1:10000;2:10001]') % is what I want
plot([1:10000;2:10001]) % Please don't try this at home

This also works:
plot(1:10000, [1:10000;2:10001])

Ability to kill the current command from the GUI would generally solve
such problems.
> - Did you install Octave from the executable or one of the zip-packages? if teh latter did you follow the post-install instructions?

From the executable.

(please reply all to keep the help list cc'd, as this might involve more knowledge than I possess.)


Reply | Threaded
Open this post in threaded view
|

Re: frequent windows crashes, especially with plotting?

Ian McCallion
.

(please reply all to keep the help list cc'd, as this might involve more knowledge than I possess.)

Sorry! Finger problem! 


Reply | Threaded
Open this post in threaded view
|

Re: Command to save command history

Ian McCallion
In reply to this post by mmuetzel
On Mon, 27 Jul 2020 at 13:09, Markus Mützel <[hidden email]> wrote:

>
> Am 27. Juli 2020 um 12:59 Uhr schrieb "Ian McCallion":
> > Is there an Octave command to save the command history?.History is
> > saved when Octave terminates normally, but all history accumulated
> > since the last startup is lost if Octave crashes or is killed.
> >
> > The reason for asking is that Octave 5.2.0 on windows crashes
> > frequently, especially when using plotting. During development it is
> > easily possible to request plots that go into a loop and hang. Ctrl-C
> > is ineffective at that point and the only solution is to use the task
> > manager to kill Octave and restart it.
> >
> > I can put up with having to restart Octave occasionally, but it is a
> > real pain to lose the history and have to reopen all the files that
> > were open in the editor.
> >
> > A command to save history (and list of open files) would save a lot of
> > frustration.
> >
> > Cheers... Ian
> >
>
> doc history
>
> -w file
> Write the current history to the file file. If the name is omitted, use the default history file (normally ~/.octave_hist).

Hi Markus,

Many thanks for the tip.

  history -w

works exactly as I would wish.

Cheers... Ian