This project is read-only.

HP Procurve hangs after SSH logon just after "Press any key" message

Sep 17, 2012 at 4:44 PM

I'm building a PowerShell tool to do some tasks with HP Procurve Switches.

The problem seems that i can't handle correctly the interactive TTY and i was unable to send a carraige return or something after the "press any key" message.

I've instanced a SshNet.ShellStream into a variable (with the CreateShellStream method), so i've sucesfully used the method .Expect('Press any key to continue') to get the response of the SSH conection printing the whole thing into my local host.

But if i try with a .WriteLine() method includng any key or CarriageReturn codes, it doesn't seem to interactively pressa a key for the HP Procurve side... so, my SSH ShellStream hangs if i try to invoke the .ReadLine() method just after the "Press any key" message displayed by de HP Procurve switch.

Any ideas about how to bypass this problem?.

Thanks in advance...



Sep 17, 2012 at 5:37 PM
Edited Sep 17, 2012 at 5:53 PM

Just the Piece of PowerShell code that i did:

function execSshProcurve ([string]$command) {
	$IP_ProcurveSwitch = '172.xx.xx.xx';
	$ssh_user = [Environment]::UserName;
	New-SShSession -Computername $IP_ProcurveSwitch -Username $ssh_user;
	$ProcurveConsole = $SshSessions.$IP_ProcurveSwitch.CreateShellStream("procurve", 80, 24, 800, 600, 1024)
	$Reply = $ProcurveConsole.Expect('Press any key to continue');
	Write-Host $Reply;
	start-sleep -m 1000;
	Write-Host 'Print Carriage Return code in powershell or VT100 ESC sequences'		
	start-sleep -m 1000;
	Write-Host 'Can I still read? ' + $ProcurveConsole.CanRead; 
	# It says "true" for CanRead
	$Line = $ProcurveConsole.ReadLine();
	Write-Host $Line;
	Remove-SshSession -Computername $IP_ProcurveSwitch;

The thing hangs in the .ReadLine() method

Sep 17, 2012 at 11:50 PM

you try this?

you should be able to do new-sshsession and then invoke-sshcommand, first time just send a space to get past the "press any key"


try it in an interactive PS console first, to help account for delays in the SSH part..

Aug 15, 2013 at 6:43 AM
did you get this to work?