ssh login verification in perl

I am running following lines of code in perl script to find a df output of remote machines. this works fine and gather a info in @df_ret untill until ssh key is uptodate. if public is corrupted or changed, its not showing any sign of error in script. if i run manually then i will be asked for the password.

@df_ret = split /\n/, `ssh -q $server 'df -hP'`;

Is there any way i can verify that if ssh login is successful then this perl script line should be executed else not. been finding many searches on it but could not reach to the ONE. any help?

Answers


I have got one solution working as below; #!/usr/local/bin/perl

my $line  = `ssh $server -o 'BatchMode=yes' -o 'ConnectionAttempts=1' true`;
my $error = `echo $?`;

print "Error = $error";

if($error == 0 )
{
    print "This is good";
    @df_ret = split /\n/, `ssh -q $server 'df -hP'`;
}
else
{
    print "This is bad";
}

Need Your Help

Is there any way of making this function more efficient in a standard browser?

javascript jquery performance

While profiling my web app in Chrome I found that the following function function was taking a large percentage of the total runtime for my app (which is reasonable considering how often it is used -

how to add a complete folder to a jar file by ant

ant jar

I'd like to create like a "fat" jar with ant where I have, not only the usual classes, manifest files, etc, but also my 'libs' folder too.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.