Need help getting data into legible format...maybe awk?

Good morning,

I am still learning the powers of awk and perl. I am in need of a bit of help.

I have a script on one of my launch systems...if that is even the word for it. Basically you can only ssh to a system if you are connected to this system due to firewalls.

So from that system, I have an SSHTool script that I can execute commands on remote machines or copy files out to them so I don't have to ssh to 150+ systems one at a time.

When I type in the command, it returns to standard out on my system.

I typed the 'script' command first so that it would send all output to a typescript file for me to sort through.

What I am trying to do is create a list of all scripts that are in cron on those systems for a particular user. I am not sure what I want the output to look like. I was thinking either this:

script
-----
name of server
name of server
name of server

So the above would list each script in one column and then all servers that are running that in cron underneath.

Or I was thinking:

server
-----
name of script
name of script
name of script

So the above would list all servers and then under that the scripts running on it.

I would also like some sort of output that lists the servers that are different...meaning that they either have less or more scripts than the others. For example, let's say that every server has 5 standard scripts in cron; but there is one server that only has 3 or maybe it has 6.

Please let me know if this is possible.

Here is a sample of my typescript file:

username@10.10.10.10's password:   1   0   *   * 1-5   /randomdir/cron/zonefile_checks.sh
   1   0   *   *   *   /randomdir/DNS_Stats.sh -m
 */5   *   *   *   *   /randomdir/cron/File_Handle_Monitor.sh
 */5   *   *   *   *   /randomdir/cron/Random_Status_Monitor.sh
   0   5   *   *   *   /randomdir/cron/AMQ_reset.sh -s 1800
*/10   *   *   *   *   /randomdir/cron/named_stats.sh
Connecting to: 10.10.10.54...
spawn /bin/ssh username@10.10.10.54 crontab -l ^M
^M
******************************************************************^M
******************************************************************^M
**               N O T I C E  T O  U S E R S                    **^M
******************************************************************^M
******************************************************************^M
** security banner **
** security banner **
** security banner **
** security banner **
** security banner **
** security banner **
** security banner **
******************************************************************^M
******************************************************************^M
**               N O T I C E  T O  U S E R S                    **^M
******************************************************************^M
******************************************************************^M
^M
username@10.10.10.54's password:   1   0   *   * 1-5   /randomdir/cron/zonefile_checks.sh
   1   0   *   *   *   /randomdir/DNS_Stats.sh -m
 */5   *   *   *   *   /randomdir/cron/File_Handle_Monitor.sh
 */5   *   *   *   *   /randomdir/cron/Random_Status_Monitor.sh
   0   5   *   *   *   /randomdir/cron/AMQ_reset.sh -s 1800
*/10   *   *   *   *   /randomdir/cron/named_stats.sh
Connecting to: 10.10.10.37...

Notice that in the above it connects to the server and executes the command. The first line of 'crontab -l' is on the same line as "username@balh's password".

Thank you in advance.

First I would try to modify your "crontab -l" command so that information is easy to extract from this bit messy file, adding hostname for later convenience in parsing. Try running this instead of plain "crontab -l":

crontab -l | cat <(echo "CRONTAB HEAD"; echo "SERVER: "`hostname`) - <(echo "CRONTAB TAIL")
1 Like

Thanks bartus. let me run it like that and see.