Forum Moderators: open

Message Too Old, No Replies

Cron Job Can Not Run Command that contains space

         

aculates

2:48 am on Mar 23, 2002 (gmt 0)

10+ Year Member



How to run the cron job to execute command that contains space. Please help?

I receive error after i edit the cron job, "command not found".

Duckula

2:57 am on Mar 23, 2002 (gmt 0)

10+ Year Member



Enclose the command name with " "?

Another option would be to escape the spaces: '\ ' where the space should be.

Anyway. why has spaces the command name? Because they are options? Most usually the command to run under cron is not a command but a shell script, then it needs no options nor spaces.

aculates

3:06 am on Mar 23, 2002 (gmt 0)

10+ Year Member



It's actually the "fw logexport" command from checkpoint firewall where it converts the log file into ascii file.

The command is $fwdir/bin/ fw logexport -i <input file> -o <output file>.

After the use the cron job the run the command, i receive error, "sh:fw: not found"

Please advice. Thanks.

Duckula

3:25 am on Mar 23, 2002 (gmt 0)

10+ Year Member



If you have shell access use 'which fw' to determine where is the fw command and change the path accordingly. Should 'which' fail because the executable is not on the path, try 'locate "bin/fw" '.

If fw is not installed contact your administrator :)

Note: On the example you put an space just before 'fw'. That should not be there.
If that was your question on the first place and the system is brain damaged enough to allow such a bizarre filename, then execute it as

$fwdir/bin/\ fw logexport -i <input file> -o <output file>

but that would be very, very wrong

aculates

4:29 am on Mar 23, 2002 (gmt 0)

10+ Year Member



hi,
i can run the "fw logexport" command interactively.

i got some hints from fw mailing list archives. But i do not know how to resolve the problem. Maybe you can help me.

According to the mailling list, Checkpoint has set the LD_LIBRARY_PATH in the enviroment. And the default enviroment of the cron job does not include the environment variables that checkpoint need.

The question is how to set the environment variable for cron job which includes the environment variables of checkpoint to run the "fw logexport" command.

regards

Duckula

4:56 am on Mar 23, 2002 (gmt 0)

10+ Year Member



A bit hardcore for a webmastering forum, don't you think?

Get your admin to do that dirty work. From here, that sounds like the program is badly installed. Or not configured to be run that way. Or whatever.

To set environment variables as another user is simply not allowed. You can try to put

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/library/path $fwdir/bin/fw logexport -i <input file> -o <output file>

and pray for the best. But you didn't heard this from me. If it breaks you keep both pieces. Please ask to the soul responsible of the box where the program is installed, since you are trying to change fundamental configurations.

bird

4:11 pm on Mar 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe this question would be more suitable for the *nix forum...

There's an extremely high probability that the space before the "fw" in "$fwdir/bin/ fw" is wrong. Otherwise, that would mean that someone installed the program with a space character in its name (which is technically possible). If this really should be the case, then you need to have a very serious talk with that person...

The other thing is, that cron may not have access to the $fwdir variable. You may want to use the full path to the fw binary instead (found with "which fw" as Duckula suggested). The LD_LIBRARY_PATH environment variable is irrelevant, as long as the program itself isn't found at all. You'll only need it once you should get errors that "ld.so" can't find some shared libraries.