cron & Java command line file writing/output

cron & Java command line file writing/output

Post by lfy.. » Fri, 22 Dec 2000 09:50:17



Hi all,

 I have a simple java command line program that writes out a file at a
given path location on disk using PrintWriter().

 I have a csh script that just executes this program a couple of times
with different arguments, e.g.:
 --
 #!/bin/csh

 setenv FOO_HOME /foo1/foo2/etc/

 setenv CLASSPATH /foo/classes.zip:/foo/etc.zip

 /local/usr/bin/java foo arg1 arg2
 /local/usr/bin/java foo arg3 arg4
 --

 Running this shell script manually from the command line produces the
 expected results, with the output file(s) at the proper location(s).

 However, setting the crontab file to schedule the very same shell
 script results in no output files being created (yes, I used crontab
-e).

I have redirected the output to a log file so I can see a list of
process ids recorded each time the java program spawns a process, so I
know 'foo' is getting called by cron.

 Does anyone have any idea why I'm seeing this behavior? My only guess
 right now is that it has something to do with read/write permissions,
 and the privileges under which the cron job is running, but I really
 have no clue as to the specifics.

 Also, this is all running on Solaris 2.6 (SunOS 5.6). I have a similar
 NT batch file that does what I want without problem, but I need this
 running in a Solaris environment.

 Any ideas on how to defeat this problem would be greatly appreciated,
as I've been searching for a solution for a while.

 Thanks in advance,
 Lionel

Sent via Deja.com
http://www.deja.com/

 
 
 

cron & Java command line file writing/output

Post by Bob Dempse » Fri, 22 Dec 2000 23:22:20


The environment passed on to a script by cron is not necessarily the same
as the environment your login session passes to the script. Try adding the
command 'env' to your crontab file and, after it runs, look at the e-mail
you get showing you the environment that the script will run in. Also,
just to remove any other issues, and since the script is so simple,
re-write it for /bin/sh.


> Hi all,

>  I have a simple java command line program that writes out a file at a
> given path location on disk using PrintWriter().

>  I have a csh script that just executes this program a couple of times
> with different arguments, e.g.:
>  --
>  #!/bin/csh

>  setenv FOO_HOME /foo1/foo2/etc/

>  setenv CLASSPATH /foo/classes.zip:/foo/etc.zip

>  /local/usr/bin/java foo arg1 arg2
>  /local/usr/bin/java foo arg3 arg4
>  --

>  Running this shell script manually from the command line produces the
>  expected results, with the output file(s) at the proper location(s).

>  However, setting the crontab file to schedule the very same shell
>  script results in no output files being created (yes, I used crontab
> -e).

> I have redirected the output to a log file so I can see a list of
> process ids recorded each time the java program spawns a process, so I
> know 'foo' is getting called by cron.

>  Does anyone have any idea why I'm seeing this behavior? My only guess
>  right now is that it has something to do with read/write permissions,
>  and the privileges under which the cron job is running, but I really
>  have no clue as to the specifics.

>  Also, this is all running on Solaris 2.6 (SunOS 5.6). I have a similar
>  NT batch file that does what I want without problem, but I need this
>  running in a Solaris environment.

>  Any ideas on how to defeat this problem would be greatly appreciated,
> as I've been searching for a solution for a while.

>  Thanks in advance,
>  Lionel

> Sent via Deja.com
> http://www.deja.com/

--
-------------------------------------------------------------------------
Bob Dempsey                                         972-550-1133x104(V)
The VE Group, LLC                                   972-753-4407(F)

1231 Greenway Drive, Suite 300                      Las Colinas, TX 75038

 
 
 

1. take file name from command line arguement and write to file

Hi,

I want to write a script of this format

./myScript.sh fileWhereThereIsData newFileToBeWritten param1 param2
param3... paramN

When this script is run, it takes everything in fileWhereThereIsData
writes it to a new file, newFileToBeWritten and appends param1,
param2... paramN to newFileToBeWritten

I am a java programmer and am trying to learn shell scripting.

Help is much appreciated.

Thank You.

2. opinions on mb sought

3. .bashrc file - write command output

4. Sendmail forward

5. How to write the output of a command to both a FILE and the SCREEN !

6. etho/arp/screwy

7. Directing Shell Script output to a file from command line

8. what is err = 22?

9. Question about reading the output of a command line by line

10. sed: output modified lines only with command file input

11. Can a script output a command to the Command line as though typed

12. Perl script log file output has duplicate copies of output lines

13. awk-outputting input line in specified output line