- 论坛徽章:
- 0
|
我需要的是两段代码哦。
先说下写文件的代码:
这个是我摘取的一段代码,但是这段代码,是分别写入三个文档,分别写入host.log,user.log和passwd.log,而且后面再写会覆盖前面的
我想要的是将host, username, password 写到一个文档中, 并写到一行。
然后后面再写,不会覆盖前面的
my $log_output_host = "host.log";
my $log_output_username = "user.log";
my $log_output_password = "passwd.log";
if ($level eq "config") {
print "Enter your host ip:\n";
$inputip = <STDIN>;
chomp($inputip);
open(FILE,">$log_output_host");
syswrite(FILE,$inputusername);
close(FILE);
print "Enter your host username:\n";
$inputusername = <STDIN>;
chomp($inputusername);
open(FILE,">$log_output_username");
syswrite(FILE,$inputusername);
close(FILE);
system "stty -echo";
print "Enter your host password:\n";
$inputpasswd = <STDIN>;
chomp($inputpasswd);
$encryppasswd = encode_base64($inputpasswd);
system "stty echo";
open(FILE,">$log_output_password");
syswrite(FILE,$encryppasswd);
close(FILE);
exit;
} |
|