abazoskib Posted July 10, 2009 Share Posted July 10, 2009 PHP 5.2.6 (cli) (built: May 8 2008 08:53:44) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies I am running the command php scrubber.php > /tmp/scrub_output.txt & to run this script and output the contents into that file. Here is my output: while($row=mysql_fetch_assoc($result)){ if(isset($status)){ $backLength = strlen($status) + 1; for($i=0;$i<$backLength;$i++) echo chr(; } $rowsLeft = $rowTotal-$scrubbedRows; $status = "Total Rows: ".$rowTotal." | Scrubbed Rows: ".$scrubbedRows." | Rows Left to Scrub:".$rowsLeft." | Scrub Started on ".$now." "; echo $status; [...] In my output file, I am getting a ton of "^H" in between each echo. I am echoing BACKSPACES, which I think may be being written to the file as "^H" What is causing this and how can I fix it? Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/ Share on other sites More sharing options...
rhodesa Posted July 10, 2009 Share Posted July 10, 2009 why are you echoing backspaces? Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873057 Share on other sites More sharing options...
kenrbnsn Posted July 10, 2009 Share Posted July 10, 2009 A backspace character will show as a ^H in many utilities that display text files. What are you trying to accomplish? Ken Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873059 Share on other sites More sharing options...
abazoskib Posted July 10, 2009 Author Share Posted July 10, 2009 I am trying to limit the file size of my output file. At any point in running this script, there can be hundreds of thousands of rows left to process. I want to simply go to this file and see one sentence of information. I do not need to store an output line for each row of data, I just need the information at the point in time when I open that file. Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873067 Share on other sites More sharing options...
rhodesa Posted July 10, 2009 Share Posted July 10, 2009 OH...i see what you are trying to do. if you are trying to show progress, why don't you do a simple progress indicator, like so: 0% 100% ||||||||||||||||||||||||| that way you don't need to do any backspace characters Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873077 Share on other sites More sharing options...
abazoskib Posted July 10, 2009 Author Share Posted July 10, 2009 Very good alternative. However, I was looking for something a little more specific, as I have shown above. Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873086 Share on other sites More sharing options...
rhodesa Posted July 10, 2009 Share Posted July 10, 2009 it's a case where you can't have your cake and eat it too i think. the backspaces make it look pretty when it's just a normal output to the terminal...but if you pipe it to a file you will get those ^H characters. the other alternative is to specify the output file as an argument...then you have full control to read, write, and delete the contents of that file Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873093 Share on other sites More sharing options...
abazoskib Posted July 10, 2009 Author Share Posted July 10, 2009 Thanks for the help. Here's the code down and dirty, look good? $percent = (($scrubbedRows/$rowTotal)*100); if(($percent%5) == 0) echo "|"; Of course I already echo 0% and 100% within 20 spaces of each other. Link to comment https://forums.phpfreaks.com/topic/165525-solved-output-to-file-echo-backspace-problem/#findComment-873103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.