Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Running Linux PovRay, Shell's okay but cron won't play

by true (Pilgrim)
on May 21, 2004 at 21:59 UTC ( [id://355474]=perlquestion: print w/replies, xml ) Need Help??

true has asked for the wisdom of the Perl Monks concerning the following question:

My beloved monks, blessed are the ignorant for they shall inherit the answer. Been playing with PovRay, a kickingly cool open source 3d renderer. http://povray.org

My goal is to have perl run povray every hour on my remote linux server and render a live 3d image of the server. With buildings for folder structures, and lights for log filed activity in certain folders, etc. A fun dabble in 3d with perl outputting dynamic povray code.

After installing povray, i set myself up a perl script to run the program, everything is great. Perl starts povray no problem and prints out povray's output as it should. I am running my perl script via a remote ssh window ala Putty.

This code below works as expected via a remote ssh window: I just type perl render.pl

#!/usr/bin/perl -w #render.pl use strict; #Cwd and chdir for cron friendly run use Cwd; print chdir("/homepath/3d/")."\n"; print getcwd()."\n"; print "Rendering Gigtown\n"; print system("povray ./gigtown.pov +W600 +H300"); exit;

Now the hourly part. I edit my crontab. adding perl render.pl to the list. Waiting patiently. Cron runs. My cron log file shows the povray command, but with NO parameters, nada zippo zilch.

More precisely, PovRay seems to not be accepting my parameter input unless i run it by hand via ssh.

To me this whole thing sounds like a silly oversight. And could still be. I also tried making a bash script to do the same thing. The bash run is reporting a segmentation fault which is waaay off topic. I have done everything but recompile povray from source (i don't know how to uninstall it first :))

Anybody know a work around for faking an ssh session via perl??

thanks for reading,

James

jtrue

Replies are listed 'Best First'.
Re: Running Linux PovRay, Shell's okay but cron won't play
by Plankton (Vicar) on May 21, 2004 at 22:15 UTC
    Anybody know a work around for faking an ssh session via perl? You mean like ...
    system("ssh -l theuser thehost povray ./gigtown.pov +W600 +H300");
    Is povray going to pop-up a window that is 600x300 or is it going to generate a image file of some sorts? If it is going to popup a window you might need to set the DISPLAY environment variable because I bet that is not set for cronjobs.

    Plankton: 1% Evil, 99% Hot Gas.
      hmm, i tried this but was unable to login via a system command. Looked at help for ssh but no password accept method. Thanks for showing me that ssh was right in front of me though.

      I take it maybe open2 will allow me to negotiate this? trying to pass ssh a password yields me errors of "Pseudo-terminal will not be allocated because stdin is not a terminal." or "Broken Pipe". :(

      Thanks for info, i do not know how to set the DISPLAY environment variable. PovRay is outputting the render to a png file, i only need it to do that. I have set povary variables for non display. Still problem is before that, in accepting parameters via automated perl. thanks for help.

      jtrue
        funny story, a monk said to me yesterday "the answer is so obvious i'm not going to tell you". well, the answer was "use_pty", and it took me 12 hours to find it :) I solved this by using the Net::SSH::Perl of important note is use_pty to get povray to work right. This sets a pseudo tty on your remote machine. Without a proper tty, povray will not render. So if you are trying to emulate a shell, for any reason, this may be a solution for you.
        #!/usr/bin/perl-w use strict; use Net::SSH::Perl; my $host = "111.111.111.111"; my $user = "usernm"; my $pass = "passwd"; my $cmd = "povray +I/mypath/gigtown.pov"; my $ssh = Net::SSH::Perl->new($host,use_pty=>1); $ssh->login($user, $pass); print $ssh->cmd($cmd); exit;
        Final recap for povray/perl folks If you want to automate povray from outside your system. The hurdle is faking a shell. My solution involves running the above perl code inside a root crontab. This was the only solution i could come up with save from recompiling povray.
        jtrue

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://355474]
Approved by Happy-the-monk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-23 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found