GHMON has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: problem in loop break
by Corion (Patriarch) on Dec 01, 2020 at 15:02 UTC

    Where is the loop in the code you posted?

Re: problem in loop break
by bliako (Abbot) on Dec 01, 2020 at 19:17 UTC
    if (shapcs($MyIP , $MyUser , $MyPass , $MyPass2 , $com +mand1)) { print shapcs($MyIP , $MyUser , $MyPass , $MyPass2 +, $command1) , "\n" ; }

    That's really bad (sorry for being harsh). You execute the command twice if successful. Consider saving the return code of shapcs() somewhere and THEN check if it was success and print messages appropriately.

    Note that shapcs() can fail in a number of ways which ideally must all be checked and appropriate error codes be returned so that the caller knows exactly what went wrong and not just blame "Authentication Failed" which is only 1 of the error cases.

    bw, bliako

Re: problem in loop break
by perlfan (Parson) on Dec 03, 2020 at 17:55 UTC
    This is no loop, this is recursion. And at some point you're gonna get the dreaded "deep recursion" warning. Your sub shapcs should accept 2 and 2 things only: an already connected ssh handle and the command.
Re: problem in loop break
by Anonymous Monk on Dec 01, 2020 at 14:53 UTC