#!/usr/bin/perl my $username = "gdanko"; my $infile = "/Users/$username/hosts.txt"; my $hostfile = "/Users/$username/Desktop/jellyfiSSHr12_bm.xml"; my $groupfile = "/Users/$username/Desktop/jellyfiSSHr1_groups.xml"; my @groups; # Open the infile for reading open INFILE, $infile or die ("Could not open $infile for reading\n");; # Open the hostfile for writing open HOSTFILE, ">$hostfile" or die ("Could not open $hostfile for writing\n"); # Open the groupfile for writing open GROUPFILE, ">$groupfile" or die ("Could not open $groupfile for writing\n");; # Print the hostfile header print HOSTFILE "\n"; print HOSTFILE "\n"; print HOSTFILE "\n"; print HOSTFILE "\n"; # Print the groupfile header print GROUPFILE "\n"; print GROUPFILE "\n"; print GROUPFILE "\n"; print GROUPFILE "\n"; # Populate the host entries my @lines = ; foreach(@lines) { my $host_entry = $_; chomp($host_entry); @host_entry_array = split(/,/, $host_entry); $protocol = lc($host_entry_array[0]); $hostname = lc($host_entry_array[1]); if ($protocol eq "ssh1") { $protocol = "SSH 1"; $port = "22"; } elsif ($protocol eq "ssh2") { $protocol = "SSH 2"; $port = "22"; } elsif ($protocol eq "telnet") { $port = "23"; } elsif ($protocol eq "ftp") { $port = "21"; } elsif ($protocol eq "sftp") { $port = "22"; } else { $protocol = "SSH 2"; $port = "22"; } if ($hostname =~ /^([a-zA-Z]+)/) { $hostgroup = $1; if (!grep /^$hostgroup$/, @groups) { push(@groups, $hostgroup); } } else { $hostgroup = "Main"; } print HOSTFILE " \n"; print HOSTFILE " $hostname (" . lc($protocol) . ")\n"; print HOSTFILE " $hostname\n"; print HOSTFILE " $username\n"; print HOSTFILE " $protocol\n"; print HOSTFILE " 3des\n"; print HOSTFILE " 80\n"; print HOSTFILE " 25\n"; print HOSTFILE " 1\n"; print HOSTFILE " 0\n"; print HOSTFILE " 0\n"; print HOSTFILE " 0\n"; print HOSTFILE " 1\n"; print HOSTFILE " 1\n"; print HOSTFILE " 1\n"; print HOSTFILE " 0\n"; print HOSTFILE " $port\n"; print HOSTFILE " Monaco\n"; print HOSTFILE " 10\n"; print HOSTFILE " /bin/bash\n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " 0\n"; print HOSTFILE " Unicode (UTF-8)\n"; print HOSTFILE " YES\n"; print HOSTFILE " $hostgroup\n"; print HOSTFILE " 0\n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " \n"; print HOSTFILE " 0\n"; print HOSTFILE " \n"; print HOSTFILE " \n"; } # Populate the group entries foreach(@groups) { $group = $_; chomp $group; print GROUPFILE " $group\n"; } # Print the hostfile footer print HOSTFILE "\n"; print HOSTFILE "\n"; # Print the groupfile footer print GROUPFILE "\n"; print GROUPFILE "\n"; # Close the file handles close (INFILE); close (HOSTFILE); close (GROUPFILE); print "Done! There should be two XML files on your Desktop. Copy them to ~/Library/Preferences/JellyfiSSH and launch JellyfiSSH.\n";