bash - ssh login verification in perl -
i running following lines of code in perl script find df output of remote machines. works fine , gather info in @df_ret untill until ssh key uptodate. if public corrupted or changed, not showing sign of error in script. if run manually asked password.
@df_ret = split /\n/, `ssh -q $server 'df -hp'`;
is there way can verify if ssh login successful perl script line should executed else not. been finding many searches on not reach one. help?
i have got 1 solution working below; #!/usr/local/bin/perl
my $line = `ssh $server -o 'batchmode=yes' -o 'connectionattempts=1' true`; $error = `echo $?`; print "error = $error"; if($error == 0 ) { print "this good"; @df_ret = split /\n/, `ssh -q $server 'df -hp'`; } else { print "this bad"; }
Comments
Post a Comment