Russ P.
--
[It is] best to confuse only one issue at a time.
-- K&R
(Some people will think this solution overdone, and will suggest smaller
little hacks - like, oh, set this, set that - but the fact is the only
good way to do it that really does ensure that you get the same
environment in crontab as you would logging in)
Setup the cron job to run an Expect script, that ssh's into the box
(using private key authentication so that no password is necessary),
then runs your script in the logged in session. I did this a long time
ago, and it worked out real well. Took a while to get all the pieces
working right (redirecting all of the stdio to /dev/null, so I didn't
get an email from every job). Nice also, because Expect provides
logging (as a built-in feature), so you get a nice log of your session,
almost for free.
--
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.
CLC in a nutshell.
You're right--that is overdone. Bill's suggestion to source the
appropriate login file(s) is much cleaner, and really does ensure that
you get a login environment, without having to learn Expect or configure
ssh keys.
--keith
--
kkeller...@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
I tried that, but I can't seem to get it to load. I put
source ~/.cshrc
in the crontab file, but I got this reply:
crontab: installing new crontab
"/tmp/crontab.XXXXCGDs5E":4: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? y
What is the proper syntax? Thanks.
Russ P.
Thanks for the suggestion, but I don't that is an option here. The
program I am trying to compile is heavily embedded in a csh
environment, and that is what I need to use.
I normally use bash, but in this case I am stuck with csh.
Russ P.
Don't put it in your crontab. Write a script wrapper that does what you
want done, and call that from crontab. You can even test your script
from a nonlogin shell (which will emulate the crontab environment,
though not completely).
I am really confused.
You're *compiling* something in a crontab?
And the compilation is somehow able to depend on csh?
This sounds like a disaster-in-waiting to begin with. In any event, try
running "env" at a prompt (redirected to a file), then nuke any lines you're
sure don't matter, change the rest from
FOO=bar
to
setenv FOO bar
and append it to the script in question. That may do it.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
What is confusing about that? It seems to me like a rather
straightforward thing to do.
Here's my situation. I am writing software that needs to communicate
through a socket with another large program. The other large program
is maintained in ClearCase, and I need to be able to compile it in my
ClearCase "view." That takes something like 10 to 20 minutes. So
rather than sit and wait for it, I figure I'll just have a cron job do
it for me in the middle of the night every night. Now, this large
program apparently depends on may environment variables that were set
up using csh. We have a "standard" cshrc file that others use, but I
use bash myself.
I took Keith Keller's suggestion to source .cshrc in the compilation
startup script, but that didn't solve my problem. I'm about ready to
just say to hell with it and just compile it from the command line.
Something is f***ed up -- maybe me. In any case, I certainly
appreciate the suggestions that were offered here.
Russ P.
> And the compilation is somehow able to depend on csh?
>
> This sounds like a disaster-in-waiting to begin with. In any event, try
> running "env" at a prompt (redirected to a file), then nuke any lines you're
> sure don't matter, change the rest from
> FOO=bar
> to
> setenv FOO bar
> and append it to the script in question. That may do it.
>
> -s
> --
> Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
> What is confusing about that? It seems to me like a rather
> straightforward thing to do.
I guess automated builds exist, but it seems odd. Normally I use crontabs
for regular maintenance tasks, like *running* programs, but I build them
with a person there to watch the build.
Unless the source is changing, why compile it repeatedly?
> Here's my situation. I am writing software that needs to communicate
> through a socket with another large program. The other large program
> is maintained in ClearCase, and I need to be able to compile it in my
> ClearCase "view." That takes something like 10 to 20 minutes. So
> rather than sit and wait for it, I figure I'll just have a cron job do
> it for me in the middle of the night every night.
Ahhh!
> Now, this large
> program apparently depends on may environment variables that were set
> up using csh. We have a "standard" cshrc file that others use, but I
> use bash myself.
Okay.
Here's what I'd probably do:
#!/bin/sh
csh -c 'source /standard/cshrc; cd /path/to/source; make'
> I took Keith Keller's suggestion to source .cshrc in the compilation
> startup script, but that didn't solve my problem. I'm about ready to
> just say to hell with it and just compile it from the command line.
> Something is f***ed up -- maybe me. In any case, I certainly
> appreciate the suggestions that were offered here.
I'd mess around with env. Run a cron job to the effect of:
env | mail -s "cron environment" $yourname
and compare it with running 'env' in an environment where the build
succeeds.
-s
--
> On May 6, 11:54 am, Bill Marcum <marcumb...@bellsouth.net> wrote:
<snip>
>> Include commands to set the environment variables in your script, or
>> source your .login or .cshrc files.
<snip>
> I tried that, but I can't seem to get it to load. I put
>
> source ~/.cshrc
>
> in the crontab file, but I got this reply:
>
> crontab: installing new crontab
> "/tmp/crontab.XXXXCGDs5E":4: bad minute
> errors in crontab file, can't install.
> Do you want to retry the same edit? y
>
> What is the proper syntax? Thanks.
The error message say that something is wrong with the minute field --
that's first one. I suspect you have an entry in the crontab file that
spans more than one line. This is not usually permitted (though there
are several of different cron implementations).
When the action is anything more than a simple command, it's usually
better to put the whole thing in a script and run that:
0 3 * * * /home/you/bin/my-compile-script
--
Ben.
> I put
>
> source ~/.cshrc
>
> in the crontab file [...]
>
The original instruction was, of course:
> Include commands to set the environment variables in your script [...]
>