Network Automation Support and News Forum
Showing results for 
Search instead for 
Do you mean 

Command scripts in NA

SOLVED
Go to Solution
Super Advisor

Command scripts in NA

[ Edited ]

Hi,

How can we make ssh connection with perl in command scripts in NA ?

 

 

P.S. This thread has been moved from Network Management / (OpenView-NNM) Support and News Forum to Network Automation Support and News Forum. - Hp Forum Moderator

1 ACCEPTED SOLUTIONS
Frequent Advisor

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
7 REPLIES
Super Advisor

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)
Frequent Advisor

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
Super Advisor

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.
Super Advisor

Re: Command scripts in NA

Hi my friend.
Can we use vbscript or wscript ?
Highlighted
Frequent Advisor

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
Super Advisor

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.
Super Advisor

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