Hi guys, I need your help. I have a line in my code, listed below, that gave me Possible unintended interpolation, my @servers array has a list of servers and to use ssh-copy-id I need pass user@hostname in my function I am using ("ssh-copy-id $user\@@servers"). Is it correct this? Thanks
open SERVERS, "./test_server" or die $!; while (my $line=<SERVERS>) { my @regex = ($line =~ /(\d+\.\d+\.\d+\.\d+|[a-z0-9\-]+)(?:\ +.[a-z\.]+)?/g); foreach (@regex){ push(@servers, $_); &test; ©rsa($scp, $user, $pass, @servers); } } sub copyrsa() { my $scp_exp = new Expect; # Run the copy command. $scp_exp->spawn("ssh-copy-id $user\@@servers") or die "Cannot spawn + ssh-copy-id: $!\n"; $scp_exp->log_file("./autossh-copy-id.log"); $scp_exp->expect(5, [qr/\(yes\/no\)\?\s*$/ => sub { $scp_exp->send(" +yes\n"); exp_continue } ], [qr/assword:\s*$/ => sub { $scp_exp->send("$pass\ +n"); exp_continue; } ], );
In reply to Possible unintended interpolation by edualfaia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |