Incomplete output from crontab email: running shell scripts from a perl script

Incomplete output from crontab email: running shell scripts from a perl script

Post by tenpercent » Fri, 27 Jul 2001 05:51:48



I am running a perl script from my crontab.  The perl script that I
run executes shell scripts at the command line.  My crontab sends me
the output from this perl script that runs shell scripts.  However, if
I run the shell scripts directly from the crontab itself I get a
different output (the output that I want).

Why would a perl script that runs a shell script give me a different
"cron job" output then the shell script itself?

I don't think it is a perl problem but I am running the shell scripts
from perl with the following command: `$shell_script`.

Any help would be greatly appreciated.

 
 
 

Incomplete output from crontab email: running shell scripts from a perl script

Post by John Gord » Fri, 27 Jul 2001 05:56:27



> I am running a perl script from my crontab.  The perl script that I
> run executes shell scripts at the command line.  My crontab sends me
> the output from this perl script that runs shell scripts.  However, if
> I run the shell scripts directly from the crontab itself I get a
> different output (the output that I want).
> Why would a perl script that runs a shell script give me a different
> "cron job" output then the shell script itself?

jobs executed by cron can have a different environment than the same
job executed in an interactive shell:

  + different $PATH
  + different current working directory
  + different shell (cron executes its jobs with sh.  is sh your shell?)

---
"... What with you being his parents and all, I think that you could
be trusted not to shaft him."  -- Robert Chang, rec.games.board



 
 
 

Incomplete output from crontab email: running shell scripts from a perl script

Post by David Efflan » Fri, 27 Jul 2001 12:20:33



Quote:> I am running a perl script from my crontab.  The perl script that I
> run executes shell scripts at the command line.  My crontab sends me
> the output from this perl script that runs shell scripts.  However, if
> I run the shell scripts directly from the crontab itself I get a
> different output (the output that I want).

> Why would a perl script that runs a shell script give me a different
> "cron job" output then the shell script itself?

> I don't think it is a perl problem but I am running the shell scripts
> from perl with the following command: `$shell_script`.

That assigns the STDOUT of the script to $_ unless you assign it to a
variable and/or print that at some point.  Does it work like you expect if
you do:  print `shell_script`; [or maybe you want to use system()]?

--
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/

 
 
 

Incomplete output from crontab email: running shell scripts from a perl script

Post by Benjamin Goldber » Mon, 30 Jul 2001 05:00:47




> > I am running a perl script from my crontab.  The perl script that I
> > run executes shell scripts at the command line.  My crontab sends me
> > the output from this perl script that runs shell scripts.  However,
> > if I run the shell scripts directly from the crontab itself I get a
> > different output (the output that I want).

> > Why would a perl script that runs a shell script give me a different
> > "cron job" output then the shell script itself?

> jobs executed by cron can have a different environment than the same
> job executed in an interactive shell:

>   + different $PATH
>   + different current working directory
>   + different shell (cron executes its jobs with sh.  is sh your
>     shell?)

Also:

  + no controlling terminal [tty or pty or whatever].
  + current uid, gid, and euid may be different (not sure on this).

The lack of a terminal is unlikely to cause problems, but you may have
permissions problems.  This would be similar to when a program is called
via CGI.

--
I need more taglines. This one is getting old.

 
 
 

1. Shell script to run script to record output from a program

I am trying to record all output from a program by using script.  Having recently
learned a little shell programming, I though that this would be a good chance to
combine two commands into one shell script:

script -a myscriptfile
run.program

The problem is that script seems to start a subshell and I never get to the run
program line until I type exit to leave the script subshell.
I would use tee except that the program makes heavy use of buffering so I think I can
not afford a pipe.

Is there any way to call record a session of a program without having to type two
commands?  I thought perl maybe, but to learn enough may take a while.

2. Sharing PPP service

3. Execute a sh script under perl and sh: sh script; perl script?

4. reading dos files from floppy disk

5. How could I run a perl script by crontab?

6. Partition help please

7. Can a Crontab run perl script

8. newbie question

9. script run by crontab sends empty e-mail??

10. Question: Use a Perl Script to Make a Call to a Bourne Shell Script?

11. Passing a variable between shell script and perl script

12. Passing a variable from a Perl script to a shell script

13. PERL script vs SHELL script