Hi ,
I have a TCL script which i am supposed to run as a cron job..
The script works fine from command line , but when run as a cron job , its unable to find a package,,
my crontab is as follows.
---------------------------
#!/usr/bin/ksh
my tcl script is as follows
-----------------------------
#!/usr/bin/ksh
# \
exec tclsh8.3 "$0" ${1+"$@"}
global env
global auto_path
if { [info exists env(arch)] && $env(arch) == "linux" } {
lappend auto_path "/cm8/auto/Automation/Library/TclLib-Linux"
} elseif {[info exists env(arch)] && $env(arch) == "sunos" } {
lappend auto_path "/cm8/auto/Automation/Library/TclLib"
} else {
puts "arch type not known, defaulting to sunos"
lappend auto_path "/cm8/auto/Automation/Library/TclLib"
}
package require mysqltcl
the o/p of cron is as follows
------------------------------
Your "cron" job on inchesfttu003-c1
/home/users/sudharss/bin/tclsh /home/users/sudharss/AUTO/ontDownload.tcl
produced the following output:
arch type not known, defaulting to sunos
hi
can't find package mysqltcl
while executing
"package require mysqltcl"
(file "/home/users/sudharss/AUTO/ontDownload.tcl" line 17)
Environment when called from cron is different to when called from a shell. These questions regarding cron are so often asked, you might want to use the forum's search function and have a look here:
line ---> exec tclsh8.3
->> Is the complete path required here also ?
add PATH to your crontab. Just add PATH=Bla BLA ... (whatever your path is)
Incase you dont like add PATH to crontab ... then add to your script (different script using different paths in cron) ..
->> Add a line export PATH= BLA BLA (whatever your path is)
Hi , I have added the path also in my crontab...
But still it doesnt work. I have tried out numerous solutions from related posts, but nothing seems to work.
---------- Post updated at 07:07 AM ---------- Previous update was at 07:03 AM ----------
I have this auto_path, a global TCL variable(not an ordinary env variable) in my tcl script, and i have set it to the path where the mysql files are located.
lappend auto_path "/cm8/auto/Automation/Library/TclLib"
But I feel the cron is unable to see that variable!!! I am confused how to make cron identify where to look for the mysqltcl lib files.Because its throwing error at that point where i call "package requires mysqltcl "
---------- Post updated at 07:09 AM ---------- Previous update was at 07:07 AM ----------
It can also be seen that normal TCL commands like puts etc are working..
only when it comes to the "package requires mysqltcl" , its showing error.. The variable auto_path holds the PATH to this lib
#
# This will source your environment into the script. Assuming ksh is your default shell.
# Note there is space between the 1st "." and the "~"
#
. ~/.profile