I try to write variable in end of file, but write it into STDOUT in local server some code:
$num = <STDIN>
my $cmd = "echo $dep_keys{$num} >> /root/1";
#$ssh->system({stdin_data =>$dep_keys{$num} },"echo >> /root/1");
#$ssh->error die "Couldn't establish SSH connection: ". $ssh->error;
#$ssh->system("echo $dep_keys{$num} >> /root/1");
$ssh->system($cmd);
I expect that the file will contain new line in the end of file.
use String::ShellQuote qw( shell_quote );
defined( my $num = <STDIN> )
or die("Invalid input");
chomp($num);
defined($dep_keys{$num})
or die("Invalid input");
my $cmd = shell_quote('printf', '%s\n', $dep_keys{$num}) . ' >>/root/1';
$ssh->system($cmd);
Fixes:
$num
(if any).echo
because echo
makes impossible to output some strings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.