嗨,我正在尝试按照使用 perl 的答案中所述执行此操作,但它不起作用。
#!/usr/bin/perl -w
$pipe="data";
$username="mukesh";
$password="mukesh";
open my $pipe, '|chpasswd' or die "can't open pipe: $!";
print {$pipe} "$username:$password";
close $pipe
[root@testgfs2 user_mgmt]# ./tess3.sh
Name "main::pipe" used only once: possible typo at ./tess3.sh line 2.
chpasswd: line 1: line too long
chpasswd: error detected, changes ignored
任何机构都可以提出建议。出了什么问题。
因为 --stdin 在所有 *nix 上都不可用,所以我正在尝试使用它
编辑:C 中是否有任何程序可以执行此操作。因为如果 *nixes 可能对所有版本都有用