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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -