in reply to How to wait for putty to finish before proceeding.

It looks to me like pageant is exiting successfully once it has loaded the keys and kicked off the putty command (but before putty has finished. I don't see anything in the docs for pageant to control this behavior. Have you considered something like this? (It looks like all three keys would be loaded for the second putty call anyway.)

#!/usr/bin/perl use strict; use warnings; system('pageant F:\.keys\acuroot_1_8_12_rsa.ppk F:\.keys\acuroot_1_8_1 +3_rsa.ppk F:\.keys\operations_rsa.ppk'); system('putty -ssh -l root 192.168.100.2 -t -m C:\Users\JWSIMP~1\AppDa +ta\Local\Temp\BoKFVjf1B9'); system('putty -ssh -l operations 192.168.10.245 -t -m C:\Users\JWSIMP~ +1\AppData\Local\Temp\d60NPopq6A');

Replies are listed 'Best First'.
Re^2: How to wait for putty to finish before proceeding.
by SwaJime (Scribe) on Feb 11, 2016 at 18:30 UTC

    I think I got it now, thanks to your post Mr. Muskrat. I found that I had to insert an extra parameter to the system call to tell it not to wait for pageant to finish. Otherwise it was hanging because pageant doesn't exit when run without the -c.

    Thanks bunches :-)

    #!/usr/bin/perl # use strict; use warnings; system(1,'pageant F:\.keys\acuroot_1_8_12_rsa.ppk F:\.keys\acuroot_1_8 +_13_rsa.ppk'); system('putty -ssh -l root 192.168.100.2 -t -m C:\Users\JWSIMP~1\AppDa +ta\Local\Temp\BoKFVjf1B9'); system(1,'pageant F:\.keys\operations_rsa.ppk'); system('putty -ssh -l operations 192.168.10.245 -t -m C:\Users\JWSIMP~ +1\AppData\Local\Temp\d60NPopq6A');

      I don't program much on Windows these days and tend to forget about that trick. Nice.