We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Console, syslogd, println and infinite loops
Page Index Toggle Pages: 1
Console, syslogd, println and infinite loops (Read 1571 times)
Console, syslogd, println and infinite loops
Jan 28th, 2008, 12:01am
 
So, not sure if this is a bug, but I wanted to share with you.

I've noticed recently that my mac would often have a process (syslogd), take up an unusual ammount of my CPU. After digging into this a little, I discovered it's due to Processing sending out messages to the console when I mistakenly do a println() that floods the display window.  
As the system log fills up, I guess this other process tries to clean it up, but fails or hangs if the log is over a certain size.

My question is, is there a way to disable Processing from sending to the Console the output of println()?


Re: Console, syslogd, println and infinite loops
Reply #1 - Jan 28th, 2008, 2:57pm
 
If you start your program up and redirect standard out to somewhere, then it shouldn't go to the log.

On linux and so possibly OsX I'd guess that if you run "myApp >/dev/null" then the println() stuff should just dissappear.
Re: Console, syslogd, println and infinite loops
Reply #2 - Jan 28th, 2008, 3:59pm
 
Huh! JohnG,
it is a first time I heard about this.. redirecting the output?
Iam wondering if its possible on other platforms.. I mean like a printing directly to shell on wins? ..somehow

...
Just imagine, super-sophisticated macros completely controlling a computer to rule a whole world.. etc. :)

Should be better than a beanshell!

I am not mac user, can you please clarify this?
thanks, kof


Re: Console, syslogd, println and infinite loops
Reply #3 - Jan 28th, 2008, 4:39pm
 
Answering myslef; its dirty, but working..

Code:

String[] commands = {"@echo off\r","start .\r","exit\r"};
saveStrings("cmds.bat",commands);
link(sketchPath+"/cmds.bat","_new");
exit();


Im still not sure how to control a world with this and the script is not even very "super-sophisticated" :)

kof
Re: Console, syslogd, println and infinite loops
Reply #4 - Jan 28th, 2008, 4:48pm
 
On windows I believe the magic runes would be to change the shortcut of the progra to be
Code:
"c:\whatever\myApp\myApp.exe" >NUL 



Even though this article (http://en.wikipedia.org/wiki/Standard_streams ) talks entirely about UNIX, windows uses the same concepts of the standard streams

Basically any program that prints to a console (e.g. programs that open a "command prompt" window) does so through "standard out", which is also what processing does. However you don't get a command prompt window to see this standard out text, so it ends up somewhere else.

There is also the concept of "standard input" which is rarely used in windows programming, which enables programs to get input from a user (again normally in a command prompt window).

The redirecting means that you can change where the output goes, and it is possible to get the output from one program into the input of another. But only if it uses standard input.

Now on unix you have /dev/null and windows you have NUL both of which are just special identifiers meaning discard the data.  So "myapp > /dev/null" (or "myapp > NUL) means take the standard out from this program and discard it.
Re: Console, syslogd, println and infinite loops
Reply #5 - Jan 28th, 2008, 5:42pm
 
Hmm...  I think I may have been somewhat unclear.

When i said 'console' I didn't mean the command line/shell/terminal.

If you're on OSX, and you just have a simple println() statement, it displays it in the output section of Processing's window. But it also dumps it to the system log (viewed with a program named Console)

Anway, not really sure how you can run a Processing sketch and redirect the output to /dev/null... unless i launched processing from the command line, but that's not gonna fix my problem, because there is no output sent to the command line interface.
Re: Console, syslogd, println and infinite loops
Reply #6 - Jan 28th, 2008, 9:22pm
 
Right, I have also tried to listen what is processing saying with no success.

It seems that he is completely silent.. outputting to textfile via Code:
.../processing.exe > listen.txt 2>NUL 

leaves the file untouched..
There could be a mistake, command line is not my favourite tool.

Maybe there is something Ive missed, but it doesnt matter, for my use it is enough to run scripts via *.bat files..

For instance it help me to shutdown a computer {good for installations}, even another computer on net, sending netsend msgs, emails - {ok, like java can}, simly everything you can write into commandline, quite funny.

Really wonderful would be to get an feedback from a commands typed to bash.. But as I understand it is a same issue as above..

Anyway thanks for help, kof.
Re: Console, syslogd, println and infinite loops
Reply #7 - Jan 28th, 2008, 9:57pm
 
kof - what you're describing could easily be accomplish with Windows Scripting Host... executing commands and getting their output for parsing.

For other platforms, perl or apple script might do the trick, but I'm not sure.

Sounds like you're trying to use processing for system administration, and that sounds like overkill. On windows, there's nothing better than WSH.
Re: Console, syslogd, println and infinite loops
Reply #8 - Jan 29th, 2008, 12:24am
 
Thanks alecks, it seems to be quite interesting one.
But for my purposes, its enough to run just simple shell scripts, just for few commands only.
..
As I read WSH is quite limited under XPs, well I do not ask why.. it seems to be complete tool for virus/malware architects.

So thats not a reason why I want to automate processes on my machine. :)

I remember one of my installation called "Sysifos; suicide code", which I just cant really force to do any serious damage to itself.. it just be able to made self-shutdown (so boring), if I knew this before, it could be much better, in a symbolic way.

So in fact, i do not need better administration for a computer just discovering new possibilities for use of processing..

 ...

 selfCopier.pde

:)

..could be even more simple loadStrings(parseName(sketchPath)+".pde")..

Thanks for suggestion, Ill be digging around when I will have more time.

kof  



Page Index Toggle Pages: 1