in reply to Re^3: Read File into array and split
in thread Read File into array and split

Let me make this clear this script below is working fine. the only thing is instead of getting dir and hostnames from the script itself i need to read from text file. testfile
mshostname1
"/etc/init.d/"
"/var/logs/"
mshostname2"
"/whatever/"
"/more/"
This is the working script
#!/usr/bin/perl my $server = 'nfserver'; my $scp = '/usr/bin/scp'; my $time = localtime; my @mshost1 = ( "msname1", "/local/home/gloob", "/var/spool/cron/crontabs", "/local/home/admin/service.etc" ); my @mshost2 = ( "msname2", "/local/p0/home/gob", "/var/spool/cron/crontabs", "/local/p0/home/admin/service.etc" ); sub backup { my $client = shift; if ($client eq $client) { print "About to tar and scp the following folders: @dir\n\n"; system("ssh", $client, "tar -cvvf $client\.tar.gz @dir"); print("===============================\n"); system("ssh", $client, "scp $client\.tar.gz root\@$server:/export/prod +ucts/backup/"); } else { print "could not backup $client\n"; } } sub get_dir_msd { $client = shift(@mshost1); @dir = @mshost1; print "@dir\n"; print "$client\n"; backup($client); } sub get_dir_msd2 { $client = shift(@mshost2); @dir = @mshost2; print "@dir\n"; print "$client\n"; backup($client); } get_dir_msd("mshost2"); get_dir_msd2("mshost1");

Replies are listed 'Best First'.
Re^5: Read File into array and split
by ikegami (Patriarch) on Mar 08, 2008 at 05:52 UTC

    Let me make this clear this script below is working fine.

    So use it.

    the only thing is instead of getting dir and hostnames from the script itself i need to read from text file.

    I guess you do want to use mine after all.