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

Hello:

I have a script that I have written to be run out of cron. The script will be running a java program that for some dumb reason needs to attach to an Xserver even though I'm not displaying anything.

I can't seem to figure out how to set the DISPLAY variable from perl. If I run the script by hand it works fine because it picks up my environment. However I need to run it from cron.

Can anybody help me please 8)

thx

Replies are listed 'Best First'.
Re: Set Display Variable
by Abigail-II (Bishop) on May 30, 2002 at 17:37 UTC
    The special hash %ENV is used to read/set environment variables. Environment variables are propagated to any child processes, so if you do
    $ENV {DISPLAY} = "192.168.1.1:0.0";
    before spawning the Java program, the variable should be set.

    See also the perlvar manual page.

    Abigail

Re: Set Display Variable
by dsheroh (Monsignor) on May 30, 2002 at 17:32 UTC
    $ENV{'DISPLAY'} = ':0.0'

    Update: VSarkiss pointed out that I forgot to quote the :0.0.

      Thank you for your help! You guys are great 8)
      -K