I made a bash script which can tree
a whole directory structure recursively, putting into every directory a HTML file generated by the aha
. The script read the list of directories to be indexed. find
search for every directory inside the directory and generate the complete list of directories. If directory /media/veracrypt1
contains 50 directories in the hierarchical structure, tree
makes a tree of everything in the given directory and "below", write the HTML file with the recorded tree structure inside the directory, then goes down, repeat the action down to the bottom.
I would like the script to be fired on the defined time by the cron
. The script works but the colorization does not and the output of the pipe is black on white. I believe it is the result of cron
not having access to the LS_COLOR
system variable. (This is what I suspect)
How to correct the script to make it produce the desired effect?
The vital fragment of the script:
tree -axC "$file" | aha --title $(basename "${file// /_}") > "$file"/[z9][tree]_$(basename "${file// /_}").html; done
It works also without aha
:
tree -axC "$file" > "$file"/[z9][tree]_$(basename "${file// /_}").html; done
but the same problem with the colorization (only in cron) holds.
The text of the full script:
#!/bin/bash
List_make_R_general=/track/to/location_1.txt
List_R_gen_general=/track/to/location_2.txt
cron_log=/track/to/location_3.txt
echo > $cron_log
cat "$List_make_R_general" | while read file; do find "$file" -type d; done | tee "$List_R_gen_general"
cat "$List_R_gen_general" | while read file; do tree -axC "$file" | aha --title $(basename "${file// /_}") > "$file"/[z9][tree]_$(basename "${file// /_}").html; done
cat "$List_R_gen_general" | while read file; do tree -axC "$file" -I "*.JPG" | aha --title $(basename "${file// /_}") > "$file"/[z9][tree]_$(basename "${file// /_}")_[excl].html; done
echo -e "Tree done successfully: $(date) \n" >> $cron_log
exit