Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: system call in crontab

by naildownx (Beadle)
on Jul 20, 2009 at 04:28 UTC ( #781521=note: print w/replies, xml ) Need Help??


in reply to Re: system call in crontab
in thread system call in crontab

It sounds like you understand what I need to do...
Ok I told perl to do this as a test...send my variable name to a test.txt file and it worked:
system("echo $pic > test.txt");

so that is how I know cron is working and it is running the perl script...but I think it has a problem with me running feh...can you elaborate more on how I can set these variables and where?
The early bird gets the worm but the second mouse gets the cheese.
pretendeavor

Replies are listed 'Best First'.
Re^3: system call in crontab
by graff (Chancellor) on Jul 20, 2009 at 04:53 UTC
    I don't know anything about what "/usr/bin/feh" does or how it works. I've never heard of it before. But you say you are able to run it (and run the perl script that runs it via "system()") using your shell (though not via cron). So I'm hoping you know what it does.

    If you do the shell command "env" (which will list all your environment variables), do you see anything that seems to relate to this "feh" program (e.g. any variables that have "feh" or "FEH" as part of the variable name)? Is there a man page for "feh" that explains the environment setup for using it?

    If, for example, your normal login-shell environment includes a variable like FEH_CONFIG=... then your perl script just has to include a line like:

    $ENV{FEH_CONFIG} = ...;
    to match whatever is in your shell environment. The point is that cron only runs jobs under a limited shell, leaving out a lot of settings that you might take for granted in your interactive login sessions.

    Just for grins, try running a cron job that just does "env", to see what is in your run-time environment under cron. Or if you like, you could have cron run a perl script like this:

    #!/usr/bin/perl print "$0: Environment\n"; print " $_ = $ENV{$_}\n" for ( sort keys %ENV );
    Comparing that output to what you get from an interactive shell might be informative.
      1. feh is a program that replaces your background
      2. I ran env in my shell and did not see anything to do with feh anywhere...oh well...maybe there is an easier way to do what I am trying to do...
      I have created a perl script that when you log in to your computer it randomly chooses a wallpaper, however if I want it to change say every 30 minutes or so I was going to let cron run my script every thirty minutes...seemed to make sense, but has turned into a nightmare..
      I am open to other ideas to accomplish this.
      The early bird gets the worm but the second mouse gets the cheese.
      pretendeavor
        If you want to change your X Windows background, feh will need to know the name of the X Windows display to use. It will expect that name to be in the DISPLAY environment variable. If you only have one display on your local system, its value will be ":0.0" so you could use this:
        system("DISPLAY=:0.0 /usr/bin/feh --bg-center /home/user/Pictures/rota +te/1.jpg");
        or better
        $ENV{DISPLAY} = ":0.0"; system("/usr/bin/feh --bg-center /home/user/Pictures/rotate/1.jpg");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://781521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2022-08-16 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?