This is a hypothetical question because I'd like to know if it's even possible before I delve in to scripting it, but is it theoretically possible to have the output of a script/process (in particular one run via cron
for instance) spit out in to terminal on the next ssh
login?
Some pseudocode that I hope illustrates my point:
#!/bin/bash
# Download latest example of a database (updated automatically and periodically)
wget -mirror "http://somedatabase/database_latest
# Run a command that generates an output for a set of files queried against the latest database)
for file in /some/dir/*;
do
command -output $file.txt -database database_latest
done
# Now for the bit I'm more interested in.
# If the database has been updated, the 'output.txt'
# for each file will be different.
# So, using diff...:
if [ diff $file.txt $file_old.txt == 1 ] # where file_old.txt is
# the output of the command the
# last time it ran for that file.
then
mv $file_old ./archive/ # Keep the old file but stash it in a separate dir
else
break
fi
# Make some report file from all of the outputs
cat *.txt > report.txt
So my question being, is it possible to have the script 'inform me' next time I log in to our server, if any differences were found for each file? There are a lot of files, and the 'report.txt' would become large quickly, so I only want to check it if differences are found.