Re: Command scripts in NA (426 Views)
Reply
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 1 of 8 (426 Views)
Accepted Solution

Command scripts in NA

Hi,

How can we make ssh connection with perl in command scripts in NA ?
Please use plain text.
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 2 of 8 (426 Views)

Re: Command scripts in NA

Hi i get the below error.
It seems it makes the ssh connection but script stops with error.

Undefined subroutine &main::sendln called at C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t112507.t1547 line 24.



Successful snapshot taken.


Session log:
Created temporary file C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t112507.t1547
Executing command: C:\Perl64\bin\perl.exe C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t112507.t1547
Undefined subroutine &main::sendln called at C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t112507.t1547 line 24.
Deleted temporary file C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t112507.t1547
--- Script ---
001 #
002
003 # Sample Script to set all FastEthernet interfaces
004
005 # to full duplex on Cisco 2600s and 7200s
006
007 #
008
009 use Socket;
010
011
012 $iaddr = gethostbyname("5.5.5.2");
013
014 $ssh_port = 22;
015
016 $sin = sockaddr_in($ssh_port, $iaddr);
017
018 socket(DEV, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
019
020 connect(DEV, $sin) || die "Can't connect to R1: $!\n";
021
022
023
024 sendln("****");
025
026 sendln("****");
027
028 sendln("en");
029
030 sendln("****");
031
032
033 sendln("show ver");
034
035 sendln("conf t");
--- End of Script---
HP Network Automation: Script result code = 25 (Failed)
Please use plain text.
Frequent Advisor
Amit Kumar HPOV
Posts: 62
Registered: ‎12-10-2008
Message 3 of 8 (426 Views)

Re: Command scripts in NA

Hi,

Probably sendln command is not the perl command. If you will make use of print command instead of sendln it will run perfectly fine. I have tested the same at my own system.

Thanks & Regds,
Amit Kumar
Please use plain text.
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 4 of 8 (426 Views)

Re: Command scripts in NA

Hi my friend,

Thank you very much. You are right. It works.
One more thing to finish this topic.
print command prints something to screen.
What i want is to send a command to the router. So which command is used for this ? For example i want to send "show version" command to router.
Please use plain text.
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 5 of 8 (426 Views)

Re: Command scripts in NA

Hi my friend.
Can we use vbscript or wscript ?
Please use plain text.
Frequent Advisor
Amit Kumar HPOV
Posts: 62
Registered: ‎12-10-2008
Message 6 of 8 (426 Views)

Re: Command scripts in NA

yes, we can make use of vbscript too.
Over net you will find plenty of tools which converts the perl code to vbscript code. Search for that and get this perl script converted to vbscript.

Thanks & Regds,
Amit Kumar
Please use plain text.
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 7 of 8 (426 Views)

Re: Command scripts in NA

Thanks my friend,

How can i run the vb scripts.
How will i show the path to NA ?
Is it C:\Windows\System32\wscript.exe

When i write a script. It continues running. It does not stop.
Please use plain text.
Super Advisor
Click
Posts: 560
Registered: ‎03-29-2010
Message 8 of 8 (426 Views)

Re: Command scripts in NA

Hi,

When i try to use wscript.exe or cscript.exe as path it gives the below error.

There is no script engine for file extension ".t901".
Deleted temproray file C:\Windows\system32\config\systemprofile\AppData\Local\Temp\t095812.t901
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation