Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« on: May 14, 2009, 01:16:05 AM » |
|
how can i stop batch/cmd from erasing old lines? i have a command line utility that runs a simulation and Evey 1000 steps it displays the stats of the simulation however the sim can run for a long time (a day or more if i want to) is there any way of stopping command prompt from erazing old things and if this can't be done how can i save to a .txt everything it writes. more about the batch file i am using is here http://www.computerhope.com/forum/index.php/topic,83182.0.html
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Reno
Thanked: 32 Posts: 323

|
 |
« Reply #1 on: May 16, 2009, 02:33:39 AM » |
|
adamas, if you intent to save a log to txt file:
example: program.exe>log.txt (this will create or overwrite existing log.txt everytime program run) program.exe>>log.txt (this will append program.exe screen output to the end of existinglog.txt)
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #2 on: May 17, 2009, 02:12:32 AM » |
|
i am not sure what i need to do with that, but it does not sound like what i want i would like to save all of the text in this image to a .txt or pervent the cmd from erasing old lines (the list of info can git very long)  [attachment deleted by admin]
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Dias de verano Guest
|
 |
« Reply #3 on: May 17, 2009, 04:55:10 AM » |
|
pervent the cmd from erasing old lines (the list of info can git very long)
Sounds like you need to set the command window screen buffer height to a larger number of lines.
|
|
|
|
|
Batcher
Thanked: 5 Posts: 46
|
 |
« Reply #4 on: May 17, 2009, 08:10:34 AM » |
|
how can i save to a .txt everything it writes. YourBatch.bat>a.txt
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #5 on: May 19, 2009, 01:03:49 AM » |
|
it only saves the first line not all of it. 
|
you're just jealous because the voices talk to me, and not you.
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #7 on: May 20, 2009, 12:16:10 AM » |
|
i tried it that way and it still only saves the first line here is the batch file it is called evolve_b.bat
@echo off & setlocal & set c=n title evolve_b
if not exist save.txt goto skip :setup set c=&set/p c=do you want to start from where you left off [y\n] : echo.%c%|findstr/ix "y n yes no">nul || goto:setup
:skip if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a if /i %c:~,1%.==n. ( set/p var_time=time : set/p var_in=input : ) set/p var_out=output :
:validateYesNo echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve set c=&set/p c=are the time,input and output correct [y/n] : echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo
if /i %c:~,1%.==n. goto:setup >save.txt echo var_time=%var_time% >>save.txt echo var_in=%var_out% cd C:\Program Files\Evolve evolve_batch evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve evolve_b.bat>%var_in% %var_out% %var_time%.txt
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Dias de verano Guest
|
 |
« Reply #8 on: May 20, 2009, 12:18:15 AM » |
|
If you echo everything to a file by using the batch name and > the result is that you will see nothing on the screen and it will halt at the first set /p command
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #9 on: May 20, 2009, 12:30:08 AM » |
|
If you echo everything to a file by using the batch name and > the result is that you will see nothing on the screen and it will halt at the first set /p command
how do i remedy that?
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Dias de verano Guest
|
 |
« Reply #10 on: May 20, 2009, 12:44:39 AM » |
|
You seem to know a lot about batch coding from the file you have posted. But you don't know about redirection.  Also... cd C:\Program Files\Evolve Try to remember that thing about paths with spaces! I see something strange. That batch file is called evolve_b.bat, and in the code you posted, the last line runs... evolve_b.bat! Have you thought through the implications of this?
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #11 on: May 20, 2009, 01:24:50 AM » |
|
the others that had posted toled me to put YourBatch.bat>a.txt
so i put ... evolve_b.bat>%var_in% %var_out% %var_time%.txt
and i didn't make this batch, read this carefully http://www.computerhope.com/forum/index.php/topic,83182.0.htmland what is it about paths with spaces?
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Reno
Thanked: 32 Posts: 323

|
 |
« Reply #12 on: May 20, 2009, 06:39:40 AM » |
|
now that's the trouble. the code has set/p which wait for user input, and the output of evolvebatch seems to be real-time. couple of solutions i can think off: 1. - double up every echo statement and set/p string, eg. "echo blablabla 1>&2" - save output of evolve_batch to temp.txt eg. "evolve_batch>temp.txt", - then when finish running, output to screen with double-type command: type temp.txt & type temp.txt 1>&2 - then when running batchfile you from command prompt. "script.bat 2>log.txt" 2. convert the code to vbscript, and use wscript.stdout.read method??? 3. should be a something more simpler solution exist, but my brain stuck 
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #13 on: May 20, 2009, 09:01:47 AM » |
|
Important to know the difference between > and >>
|
|
|
|
|
Reno
Thanked: 32 Posts: 323

|
 |
« Reply #14 on: May 20, 2009, 09:28:36 AM » |
|
Important to know the difference between > and >>
answer: post #2
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #15 on: May 20, 2009, 10:15:13 AM » |
|
answer: post #2
Worth repeating
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #16 on: May 21, 2009, 02:00:18 AM » |
|
i chaged the
evolve_b.bat>a.txt
to
evolve_batch.exe>a.txt
and it now writes this to the .txt
Usage: evolve_batch s <time-spec> <infile.evolve> <outfile.evolve>
evolve_batch p <infile.evolve>
evolve_batch k <kforth_file>
evolve_batch = <file1.evolve> <file2.evolve>
evolve_batch rc <file.evolve> [x y]
evolve_batch 1s <infile.evolve> <outfile.evolve>
ERROR: No arguments.
which is some of the text i want to copy i would like to copy this and what is put below it
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Reno
Thanked: 32 Posts: 323

|
 |
« Reply #17 on: May 21, 2009, 06:46:37 AM » |
|
@echo off & setlocal & set c=n title evolve_b
if not exist save.txt goto skip :setup set c=&set/p c=do you want to start from where you left off [y\n] : echo.%c%|findstr/ix "y n yes no">nul || goto:setup
:skip if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a if /i %c:~,1%.==n. ( set/p var_time=time : set/p var_in=input : ) set/p var_out=output :
:validateYesNo echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve set c=&set/p c=are the time,input and output correct [y/n] : echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo
if /i %c:~,1%.==n. goto:setup >save.txt echo var_time=%var_time% >>save.txt echo var_in=%var_out% cd C:\Program Files\Evolve >temp.txt evolve_batch.exe type temp.txt type temp.txt>>a.txt >temp.txt evolve_batch.exe s %var_time% %var_in%.evolve %var_out%.evolve type temp.txt type temp.txt>>a.txt
notes: with this method, you will lose the real-time display of evolvebatch.exe
|
|
|
|
|
Ädamas Topic Starter
Thanked: 1 Posts: 64
|
 |
« Reply #18 on: May 22, 2009, 03:14:39 AM » |
|
thank you for helping me Reno and i don't care that it does not display the info when it's run i usually leave it going unattended for an hour or so unless i want to save the info (by copying and pasting it in to excel for graphing which i don't have to do any more) so thank you again for helping me
|
you're just jealous because the voices talk to me, and not you.
|
|
|
Reno
Thanked: 32 Posts: 323

|
 |
« Reply #19 on: May 22, 2009, 03:40:29 AM » |
|
no problem.  glad the script works well
|
|
|
|
|