surajsam has asked for the wisdom of the Perl Monks concerning the following question:
I have the following code that picks up zz.txt and when it comes to destination, it should be copied as zz_hostname.txt and instead it copies as zz_hostname?.txt. No idea how to get rid of that extra '?'.
#!/usr/bin/perl use strict; use warnings; my @array=(); my $diff_file="/tmp/diff.txt"; while (<STDIN>) { last if ($_ =~ /^\s*$/); # Exit if it was just spaces (or just + an enter) print "You typed: $_"; push @array,$_; } print "\@array = @array\n"; foreach my $i (@array) { #print $i system('/usr/bin/scp', "user\@$i:/tmp/zz.txt", "/tmp/zz_$i\.txt"); } foreach my $i (@array) { system('diff /tmp/zz.txt /tmp/zz_$i\.txt |tee -a $diff_file'); }
When it does the scp, it would create files like - zz_host1?.txt, zz_host2?.txt. .. Dont know where that extra '?' is coming from. Eventually, the diff also fails. The goal is to gather the diffs for a given file, across 10 hosts. The email should give the diff per host basis but one email should contain all the diffs.
First, how do I avoid that extra ? after scp ing the file. I played with escape chars but could not go ahead. thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: scp command in perl introduces extra character while copying
by chromatic (Archbishop) on Nov 09, 2011 at 20:31 UTC | |
by surajsam (Initiate) on Nov 09, 2011 at 21:07 UTC | |
by ikegami (Patriarch) on Nov 09, 2011 at 21:25 UTC | |
by surajsam (Initiate) on Nov 10, 2011 at 03:30 UTC |