Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Dominik_Wasiele
Explorer

FWM Command in bash script

Hello,

I try to run a bash script as a schedules task (admin user) via Gaia on a R77.30 management server. The purpose of the script is to use the "fwm logexport" command to convert log files to ascii format and then move the file over scp to a Linux server. 

Everything works as expected when calling the script on the command line via expert mode. When the script runs from the cron job everything works the same except that the fwm command cannot be found. 

When I just use "fwm" as command in the script I get this error: "fwm: command not found"

When I try to specify the whole path "/opt/CPsuite-R77/fw1/bin/fwm" I get this error: "/opt/CPsuite-R77/fw1/bin/fwm: error while loading shared libraries: libcplic_cntrct.so: cannot open shared object file: No such file or directory"

Thanks in advanced,

Dominik

0 Kudos
6 Replies
Timothy_Hall
Champion
Champion

Do you have the following early on in your script to properly set the different Check Point environment variables including PATH:

source /opt/CPshrd-R77/tmp/.CPprofile.sh

or

source /opt/CPshrd-R77/tmp/.CPprofile.csh

--
Second Edition of my "Max Power" Firewall Book
Now Available at http://www.maxpowerfirewalls.com

Gateway Performance Optimization R81.20 Course
now available at maxpowerfirewalls.com
Dominik_Wasiele
Explorer

Many thanks this solved my issue.

0 Kudos
Danny
Champion Champion
Champion

I recommend to add the line below on top of your script:

source /etc/profile.d/CP.sh;‍

In case you also wish to create similar scripts on VSX systems, just add this line as well:

source /etc/profile.d/vsenv.sh;‍
Bryce_Myers
Collaborator

At the top of my cronjobs that require Checkpoint Environment Variables I use:

#Load Checkpoint Environment Variables
source /etc/profile.d/CP.sh
if [[ -e /etc/profile.d/vsenv.sh ]]; then
    source /etc/profile.d/vsenv.sh
fi

The outcome should be the same as what Tim provided.

Joseph_Audet
Ambassador
Ambassador

Thanks Bryce - this helped me out finishing a script today and having issues with the same error Dominik had, but on R80.20.

0 Kudos
dprimiceri
Explorer

Hi Guys

i've just updated VSX R80.30 to R80.40 but the script doesn't work into crontab

Here the script:

#!/bin/bash -f
#
#
source /etc/profile.d/vsenv.sh;
vsenv 4
cphaprob state | grep local | grep ACTIVE >> /dev/null

if [ $? -eq 0 ]; then

echo "--- Vpn user counter ---" > /tmp/userc_users
fw tab -t userc_users -s > /tmp/userc_users

source /etc/profile.d/vsenv.sh;
vsenv 0
# Leggo il file temporaneo e mando il contenuto via mail
cat /tmp/userc_users | $FWDIR/bin/sendmail -s 'Test' -t 10.79.226.17 -f xxxx@yyy.it wwww@yyy.it

else
exit
fi

 

If i launc manually works

thanks in advance

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events