Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: system call in crontab

by graff (Chancellor)
on Jul 20, 2009 at 04:23 UTC ( [id://781519]=note: print w/replies, xml ) Need Help??


in reply to system call in crontab

In addition to answering the question about what error message you get (if any), it might also help to know what this means:

... I can [get] my perl script to work in shell and crontab until I add this line...

What exactly did it do before you added that line? (That is, how do you know it worked, and was the addition of that one line really the only change you made?) And what result does it produce when you run it manually from your shell?

(Do you have any environment variables in your shell that affect the "feh" command? If so, you'll need to set those via %ENV in the perl script, because cron only gives you a minimal environment.)

Replies are listed 'Best First'.
Re^2: system call in crontab
by naildownx (Beadle) on Jul 20, 2009 at 04:28 UTC
    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
      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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found