I have a situation where i have to execute a Batch script on Remote Windows Machine (MACH2) from my local machine (MACH1). I was able to do this from windows machine to Linux machine but not able to do this from windows machine to windows machine.
Because when i coonect to windows machine MACH1 to anothe windows machine MACH2 using telnet , it ask for a (y/n) from the user , which i'm not able to provide in script (written below ) -
push(@INC,'E:\perl\Net-Telnet-3.03\blib\lib\Net');
-
use Net::Telnet ();
-
-
$t = new Net::Telnet(
-
Timeout => 10,
-
Prompt => '/\$ $/',
-
);
-
$t->open("X.X.X.X");
-
$t->login('"abc", 'abc');
-
$cd = $t->cmd("cd ajay");
-
$comp = $t->cmd("ls");
-
-
print @lines;
-
7 14113
I'm not sure about that module but your code isn't valid, like this line: - $t->login('"abc", 'abc');
the quotes are off, should be:
read the module documentation if you haven't already, there is some info about login problems in the "login" section.
I'm able to connect to remote windows machine using the Perl script.
Using that perl script i was able to execute a batch script present on the remote windows machine.
But one complication is still there , i was able to send only one command to that machine , and i have to send many ,.
I have this script -
push(@INC,'E:\perl\Net-Telnet-3.03\blib\lib\Net');
-
use Net::Telnet();
-
-
$t = new Net::Telnet (
-
Timeout => 20,
-
Prompt => '/C:\\\\>$/i',
-
Input_log => 'abc.txt',
-
Output_log => 'def.txt'
-
);
-
-
$t->open("x.x.x.x");
-
-
$user = 'xxxxx';
-
$password = 'xxxxxx';
-
-
$t->waitfor('/login: $/i');
-
$t->print($user);
-
-
$t->waitfor('/password: $/i');
-
$t->print($password);
-
-
$t->waitfor('/.*C.*$/i');
-
$t->print ("C:\\\\");
-
-
print $t->cmd('testing.bat');
-
$t-Waitfor('D:\\\\saurabh\\\\test\\\\Source.out\\\\arm\\\\lib');
-
-
$t->print('pwd');
-
I'm not able to execute that last line of the above script.Means i was not able to execute any command after
print $t->cmd('testing.bat');
Kindly suggest
Sorry, I don't know. Maybe someone else will.
actully after print $t->cmd('testing.bat');
line it sends a message on the command line :
command timed-out at windows_telnet.pl line 50
Has anybody tried running multiple commands on the remote windows machine
using the Batch script.
Because i'm able to run only one command on the remote window machine.
Kindly suggest , Looking forward to replies
Hi Ajay,
I am facing the same problem....
I have to do telnet on remote machine and it asks to enter (y/n). How did u solve the problem???
following is my code....
use strict;
use Net::Telnet;
my $HOST = "xxx.xxx.xxx.xxx";
print "$HOST\n";
my $USER = "abc";
my $PASS ="xyz";
my $telnet = Net::Telnet->new($HOST);
$telnet->login($USER,$PASS);
my @lines = $telnet->cmd('dir');
print @lines;
when i run this script i get an error "login failed: bad name or password at tel.pl line 12"
Hi Ajay,
I am facing the same problem....
I have to do telnet on remote machine and it asks to enter (y/n). How did u solve the problem???
following is my code....
use strict;
use Net::Telnet;
my $HOST = "xxx.xxx.xxx.xxx";
print "$HOST\n";
my $USER = "abc";
my $PASS ="xyz";
my $telnet = Net::Telnet->new($HOST);
$telnet->login($USER,$PASS);
my @lines = $telnet->cmd('dir');
print @lines;
when i run this script i get an error "login failed: bad name or password at tel.pl line 12"
Here I would also like to add that the ip address is of my local machine only..... and the username and password are also correct.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jean-Marc Molina |
last post by:
Hello,
I can't find a way to execute a Windows application, whose directory path
contains blank spaces, from a PHP script. I also wonder if the problem
happens under Linux and other OS.
...
|
by: Jon Maz |
last post by:
Hi All,
To allow myself to make development changes directly on a remote server
*without* having to compile on my local dev machine and then upload the
dll's to remote, I have created a...
|
by: Doug at SAU |
last post by:
I need to run a batch file on a remote machine from an ASP page. I dummied
up a test ASP page as follows:
<%
Set WshShell = Server.CreateObject("Wscript.Shell")
wshshell.run...
|
by: Sinex |
last post by:
Hi,
I am triggering a batch file from my C# code. There are no echo commands
in the batch file...yet the console window/command prompt window pops up
every time the batch file is triggerred. Is...
|
by: David R. |
last post by:
Hello all,
I would like to generate a Sql-Script-File and a Batch-File to execute the
Batch-File over C#-Code and use the SQL-File as an Input-File for the command
"osql" in the Batch-File.
I...
|
by: RajeevSekar |
last post by:
Hi Experts,
I am trying to invoke a batch(reside in my local machine) file from
asp.net using System.diagnostics.process.start("path\filename") method, it
is working fine, but when i try to...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
hello Everyone,
I created this batch file that executes the taskKill command to kill the
process on the remote server. When I call this batch file from the console
applications, it runs fine and...
|
by: jamesd0142 |
last post by:
Hi,
I have a batch file on a remote server. if i use remote desktop to connect to this server and run the batch file it runs as i would expect.
However i need to run this batch file from my...
|
by: =?Utf-8?B?UnVzdHlfUm9zZXI=?= |
last post by:
Hi everyone,
I'm having some issues figuring out how to complete certain tasks
with a batch file, whether it be not knowing the right syntax or if it can
even be accomplished with a batch file....
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |