CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Plink command hangs in perl?

 



bornwildnfree
New User

Mar 2, 2011, 11:01 AM

Post #1 of 6 (4614 views)
Plink command hangs in perl? Can't Post

I have this problem across several Perl scripts. I have to use plink to ssh into a device. I am running Active Perl 5.10.0 Build 1004 on Windows Server 2003 with Putty release .056.

If I run the command this way:
$svctask = "plink.exe -ssh -l $user -i $svckey -2 $IP svcinfo lshost -delim :";
@shstlist = qx ($svctask) or die "Unable to open SVC\n";
print "Enter a \n";
print "\t1) WWPN\n";
print "\t2) Server name\n";
print "\n\t ?";
do
{
chomp($choice = <>);
$choice = uc($choice);
}until($choice =~ m/[0-9]{1}/);
The script hangs and I can not make a choice. I have to CTRL C out which does me no good. If I move the plink command below the until statement, I am able to make a choice and the script continues until I have another pause for answer section and again it hangs. Is there a perl command that exits out of plink? I have used this same bit of code in other scripts that don't require SSH and it works just fine.


FishMonger
Veteran / Moderator

Mar 2, 2011, 12:48 PM

Post #2 of 6 (4609 views)
Re: [bornwildnfree] Plink command hangs in perl? [In reply to] Can't Post

Is there a reason you can't use one of Perl's ssh modules?


bornwildnfree
New User

Mar 2, 2011, 12:49 PM

Post #3 of 6 (4607 views)
Re: [FishMonger] Plink command hangs in perl? [In reply to] Can't Post

That's looking like what I'm going to have to do although perl's SSH modules on Windows have been difficult to configure.


FishMonger
Veteran / Moderator

Mar 2, 2011, 1:17 PM

Post #4 of 6 (4606 views)
Re: [bornwildnfree] Plink command hangs in perl? [In reply to] Can't Post

Net::SSH is easiy to install


Quote
C:\Users\RKB>ppm install Net::SSH
Downloading Net-SSH-0.09...done
Unpacking Net-SSH-0.09...done
Generating HTML for Net-SSH-0.09...done
Updating files in site area...done
2 files installed



bornwildnfree
New User

Mar 15, 2011, 1:57 PM

Post #5 of 6 (4575 views)
Re: [bornwildnfree] Plink command hangs in perl? [In reply to] Can't Post

cpan - Net::SSH does not play well with the device I'm trying to SSH into because we have to use keys. We actually solved this by having the perl script write the command to a .cmd file and running it that way.
open(MyFile,">","svc.cmd") or die "Unable to create file svc.cmd\n";
$svctask = "ECHO OFF\nplink.exe -batch -t -ssh -l $user -i $svckey -2 $IP svcinfo lshostvdiskmap -delim : $hostid";
print MyFile "$svctask";
close MyFile;
@svcvdisklist = qx ("svc.cmd") or die "Unable to open SVC\n";


FishMonger
Veteran / Moderator

Mar 15, 2011, 4:38 PM

Post #6 of 6 (4574 views)
Re: [bornwildnfree] Plink command hangs in perl? [In reply to] Can't Post

The list form of the system call should have worked as well without the extra steps of creating and executing a .cmd file.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives